Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() {

assertNotNull(firstResult)
assertEquals(remotePath, firstResult?.remotePath())
assertEquals(fileId, firstResult?.fileId())
assertEquals(fileId.toString(), firstResult?.fileId())
}

@Test
Expand Down
17 changes: 17 additions & 0 deletions library/src/androidTest/java/com/owncloud/android/FileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,21 @@ public void testTwoSharees() {
assertTrue(sharees.contains(user));
}
}

@Test
public void testLocalID() {
// create & verify folder
String path = "/testFolder/";
assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());

RemoteOperationResult result = new ReadFolderRemoteOperation(path).execute(client);
assertTrue(result.isSuccess());

RemoteFile folder = (RemoteFile) result.getData().get(0);

// we do this only here for testing, this might not work on large installations
int localId = Integer.parseInt(folder.getRemoteId().substring(0, 8).replaceAll("^0*", ""));

assertEquals(folder.getLocalId(), localId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testSearchByFileIdSuccess() {
assertTrue(readFile.isSuccess());

RemoteFile remoteFile = ((RemoteFile) readFile.getSingleData());
SearchRemoteOperation sut = new SearchRemoteOperation(remoteFile.getLocalId(),
SearchRemoteOperation sut = new SearchRemoteOperation(String.valueOf(remoteFile.getLocalId()),
SearchRemoteOperation.SearchType.FILE_ID_SEARCH,
false,
capability);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class NextcloudUriDelegate(baseUri: Uri, var userId: String?) : NextcloudUriProv
return "$filesDavUri${WebdavUtils.encodePath(path)}"
}

override fun getCommentsUri(fileId: String): String {
override fun getCommentsUri(fileId: Long): String {
return "$davUri/comments/files/$fileId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ interface NextcloudUriProvider {
val davUri: Uri

fun getFilesDavUri(path: String): String
fun getCommentsUri(fileId: String): String
fun getCommentsUri(fileId: Long): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public Uri getDavUri() {
return nextcloudUriDelegate.getDavUri();
}

public String getCommentsUri(String fileId) {
public String getCommentsUri(long fileId) {
return nextcloudUriDelegate.getCommentsUri(fileId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public class WebdavEntry {

private static final String TAG = WebdavEntry.class.getSimpleName();

public static final String NAMESPACE_OC = "http://owncloud.org/ns";
public static final String NAMESPACE_NC = "http://nextcloud.org/ns";
public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions";
public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id";
public static final String NAMESPACE_OC = "http://owncloud.org/ns";
public static final String NAMESPACE_NC = "http://nextcloud.org/ns";
public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions";
public static final String EXTENDED_PROPERTY_NAME_LOCAL_ID = "fileid";
public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id";
public static final String EXTENDED_PROPERTY_NAME_SIZE = "size";
public static final String EXTENDED_PROPERTY_FAVORITE = "favorite";
public static final String EXTENDED_PROPERTY_IS_ENCRYPTED = "is-encrypted";
Expand Down Expand Up @@ -100,8 +101,12 @@ public class WebdavEntry {
@Getter private String contentType;
@Getter private String eTag;
@Getter private String permissions;
@Getter private String remoteId;
@Getter private String trashbinOriginalLocation;
@Getter
private String remoteId;
@Getter
private long localId;
@Getter
private String trashbinOriginalLocation;
@Getter private String trashbinFilename;
@Getter private long trashbinDeletionTimestamp;
@Getter @Setter private boolean favorite;
Expand Down Expand Up @@ -282,6 +287,12 @@ public WebdavEntry(MultiStatusResponse ms, String splitElement) {
remoteId = prop.getValue().toString();
}

// OC remote id property <oc:fileid>
prop = propSet.get(EXTENDED_PROPERTY_NAME_LOCAL_ID, ocNamespace);
if (prop != null) {
localId = Long.parseLong((String) prop.getValue());
}

// OC size property <oc:size>
prop = propSet.get(EXTENDED_PROPERTY_NAME_SIZE, ocNamespace);
if (prop != null) {
Expand Down Expand Up @@ -531,6 +542,7 @@ public boolean isDirectory() {
private void resetData() {
name = uri = contentType = permissions = null;
remoteId = null;
localId = -1;
contentLength = createTimestamp = modifiedTimestamp = 0;
size = 0;
quotaUsedBytes = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static DavPropertyNameSet getAllPropSet() {
propSet.add(DavPropertyName.CREATIONDATE);
propSet.add(DavPropertyName.GETETAG);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_LOCAL_ID, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_FAVORITE, ocNamespace);
Expand Down Expand Up @@ -145,6 +146,7 @@ public static DavPropertyNameSet getFilePropSet() {
propSet.add(DavPropertyName.CREATIONDATE);
propSet.add(DavPropertyName.GETETAG);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_LOCAL_ID, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, ocNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_FAVORITE, ocNamespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ public class GetActivitiesRemoteOperation extends RemoteOperation {

private int lastGiven = -1;

private String fileId = "";
private long fileId = -1;

public GetActivitiesRemoteOperation() {
}

public GetActivitiesRemoteOperation(String fileId) {
public GetActivitiesRemoteOperation(long fileId) {
this.fileId = fileId;
}
public GetActivitiesRemoteOperation(String fileId, int lastGiven) {

public GetActivitiesRemoteOperation(long fileId, int lastGiven) {
this.fileId = fileId;
this.lastGiven = lastGiven;
}
Expand All @@ -102,7 +102,7 @@ public RemoteOperationResult run(NextcloudClient client) {
String url = client.getBaseUri() + OCS_ROUTE_V12_AND_UP;

// add filter for fileId, if available
if (!fileId.isEmpty()) {
if (fileId > 0) {
url = url + "/filter";
}

Expand All @@ -119,10 +119,10 @@ public RemoteOperationResult run(NextcloudClient client) {
parameters.put("since", String.valueOf(lastGiven));
}

if (!fileId.isEmpty()) {
if (fileId > 0) {
parameters.put("sort", "desc");
parameters.put("object_type", "files");
parameters.put("object_id", fileId);
parameters.put("object_id", String.valueOf(fileId));
}

get.setQueryString(parameters);
Expand Down Expand Up @@ -173,7 +173,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
String url = client.getBaseUri() + OCS_ROUTE_V12_AND_UP;

// add filter for fileId, if available
if (!fileId.isEmpty()) {
if (fileId > 0) {
url = url + "/filter";
}

Expand All @@ -191,10 +191,10 @@ protected RemoteOperationResult run(OwnCloudClient client) {
parameters.add(new NameValuePair("since", String.valueOf(lastGiven)));
}

if (!fileId.isEmpty()) {
if (fileId > 0) {
parameters.add(new NameValuePair("sort", "desc"));
parameters.add(new NameValuePair("object_type", "files"));
parameters.add(new NameValuePair("object_id", fileId));
parameters.add(new NameValuePair("object_id", String.valueOf(fileId)));
}

get.setQueryString(parameters.toArray(new NameValuePair[]{}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public class CommentFileRemoteOperation extends RemoteOperation {
private static final String VERB_VALUE = "comment";
private static final String MESSAGE = "message";

private String message;
private String fileId;
private final String message;
private final long fileId;

/**
* Constructor
*
* @param message Comment to store
*/
public CommentFileRemoteOperation(String message, String fileId) {
public CommentFileRemoteOperation(String message, long fileId) {
this.message = message;
this.fileId = fileId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
public class MarkCommentsAsReadRemoteOperation extends RemoteOperation {
private static final String COMMENTS_URL = "/comments/files/";

private String fileId;
private final long fileId;

public MarkCommentsAsReadRemoteOperation(String fileId) {
public MarkCommentsAsReadRemoteOperation(long fileId) {
this.fileId = fileId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public class GetMetadataRemoteOperation extends RemoteOperation {
private static final String NODE_DATA = "data";
private static final String NODE_META_DATA = "meta-data";

private String fileId;
private final long fileId;

/**
* Constructor
*/
public GetMetadataRemoteOperation(String fileId) {
public GetMetadataRemoteOperation(long fileId) {
this.fileId = fileId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class LockFileRemoteOperation extends RemoteOperation {
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
private static final String LOCK_FILE_URL = "/ocs/v2.php/apps/end_to_end_encryption/api/v1/lock/";

private String localId;
private String token;
private final long localId;
private final String token;

// JSON node names
private static final String NODE_OCS = "ocs";
Expand All @@ -59,12 +59,12 @@ public class LockFileRemoteOperation extends RemoteOperation {
/**
* Constructor
*/
public LockFileRemoteOperation(String localId, String token) {
public LockFileRemoteOperation(long localId, String token) {
this.localId = localId;
this.token = token;
}

public LockFileRemoteOperation(String localId) {
public LockFileRemoteOperation(long localId) {
this.localId = localId;
this.token = "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public class StoreMetadataRemoteOperation extends RemoteOperation {
private static final String NODE_DATA = "data";
private static final String NODE_META_DATA = "meta-data";

private String fileId;
private String encryptedMetadataJson;
private final long fileId;
private final String encryptedMetadataJson;

/**
* Constructor
*/
public StoreMetadataRemoteOperation(String fileId, String encryptedMetadataJson) {
public StoreMetadataRemoteOperation(long fileId, String encryptedMetadataJson) {
this.fileId = fileId;
this.encryptedMetadataJson = encryptedMetadataJson;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public class ToggleEncryptionRemoteOperation extends RemoteOperation {
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
private static final String ENCRYPTED_URL = "/ocs/v2.php/apps/end_to_end_encryption/api/v1/encrypted/";

private String localId;
private String remotePath;
private boolean encryption;
private final long localId;
private final String remotePath;
private final boolean encryption;

/**
* Constructor
*/
public ToggleEncryptionRemoteOperation(String localId, String remotePath, boolean encryption) {
public ToggleEncryptionRemoteOperation(long localId, String remotePath, boolean encryption) {
this.localId = localId;
this.remotePath = remotePath;
this.encryption = encryption;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public class UnlockFileRemoteOperation extends RemoteOperation {
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
private static final String LOCK_FILE_URL = "/ocs/v2.php/apps/end_to_end_encryption/api/v1/lock/";

private String localId;
private String token;
private final long localId;
private final String token;

/**
* Constructor
*/
public UnlockFileRemoteOperation(String localId, String token) {
public UnlockFileRemoteOperation(long localId, String token) {
this.localId = localId;
this.token = token;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public class UpdateMetadataRemoteOperation extends RemoteOperation {
private static final String NODE_DATA = "data";
private static final String NODE_META_DATA = "meta-data";

private String fileId;
private String encryptedMetadataJson;
private String token;
private final long fileId;
private final String encryptedMetadataJson;
private final String token;

/**
* Constructor
*/
public UpdateMetadataRemoteOperation(String fileId, String encryptedMetadataJson, String token) {
public UpdateMetadataRemoteOperation(long fileId, String encryptedMetadataJson, String token) {
this.fileId = fileId;
this.encryptedMetadataJson = URLEncoder.encode(encryptedMetadataJson);
this.token = token;
Expand Down
Loading