return share;
}
- public OCShare getShareByPath(String path) {
- Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_PATH, path);
+ public OCShare getFirstShareByPathAndType(String path, ShareType type) {
+ Cursor c = null;
+ if (getContentResolver() != null) {
+ c = getContentResolver().query(
+ ProviderTableMeta.CONTENT_URI_SHARE,
+ null,
+ ProviderTableMeta.OCSHARES_PATH + "=? AND "
+ + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND "
+ + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
+ new String[] { path, Integer.toString(type.getValue()), mAccount.name },
+ null);
+ } else {
+ try {
+ c = getContentProviderClient().query(
+ ProviderTableMeta.CONTENT_URI_SHARE,
+ null,
+ ProviderTableMeta.OCSHARES_PATH + "=? AND "
+ + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND "
+ + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
+ new String[] { path, Integer.toString(type.getValue()), mAccount.name },
+ null);
+
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, "Could not get file details: " + e.getMessage());
+ c = null;
+ }
+ }
OCShare share = null;
if (c.moveToFirst()) {
share = createShareInstance(c);
import com.owncloud.android.lib.network.OwnCloudClient;
import com.owncloud.android.lib.operations.common.OCShare;
import com.owncloud.android.lib.operations.common.RemoteOperationResult;
+import com.owncloud.android.lib.operations.common.ShareType;
import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.operations.remote.ExistenceCheckRemoteOperation;
import com.owncloud.android.lib.operations.remote.RemoveRemoteShareOperation;
RemoteOperationResult result = null;
// Get Share for a file
- OCShare share = getStorageManager().getShareByPath(mRemotePath);
+ OCShare share = getStorageManager().getFirstShareByPathAndType(mRemotePath, ShareType.PUBLIC_LINK);
if (share != null) {
RemoveRemoteShareOperation operation = new RemoveRemoteShareOperation((int) share.getIdRemoteShared());