Skip to content

Commit bcce961

Browse files
use localID everywhere, it is now long instead of String
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 44d25ee commit bcce961

File tree

8 files changed

+40
-50
lines changed

8 files changed

+40
-50
lines changed

src/main/java/com/owncloud/android/lib/resources/activities/GetActivitiesRemoteOperation.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ public class GetActivitiesRemoteOperation extends RemoteOperation {
7575

7676
private int lastGiven = -1;
7777

78-
private String fileId = "";
78+
private long fileId = -1;
7979

8080
public GetActivitiesRemoteOperation() {
8181
}
8282

83-
public GetActivitiesRemoteOperation(String fileId) {
83+
public GetActivitiesRemoteOperation(long fileId) {
8484
this.fileId = fileId;
8585
}
86-
87-
public GetActivitiesRemoteOperation(String fileId, int lastGiven) {
86+
87+
public GetActivitiesRemoteOperation(long fileId, int lastGiven) {
8888
this.fileId = fileId;
8989
this.lastGiven = lastGiven;
9090
}
@@ -102,7 +102,7 @@ public RemoteOperationResult run(NextcloudClient client) {
102102
String url = client.getBaseUri() + OCS_ROUTE_V12_AND_UP;
103103

104104
// add filter for fileId, if available
105-
if (!fileId.isEmpty()) {
105+
if (fileId > 0) {
106106
url = url + "/filter";
107107
}
108108

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

122-
if (!fileId.isEmpty()) {
122+
if (fileId > 0) {
123123
parameters.put("sort", "desc");
124124
parameters.put("object_type", "files");
125-
parameters.put("object_id", fileId);
125+
parameters.put("object_id", String.valueOf(fileId));
126126
}
127127

128128
get.setQueryString(parameters);
@@ -172,7 +172,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
172172
String url = client.getBaseUri() + OCS_ROUTE_V12_AND_UP;
173173

174174
// add filter for fileId, if available
175-
if (!fileId.isEmpty()) {
175+
if (fileId > 0) {
176176
url = url + "/filter";
177177
}
178178

@@ -190,10 +190,10 @@ protected RemoteOperationResult run(OwnCloudClient client) {
190190
parameters.add(new NameValuePair("since", String.valueOf(lastGiven)));
191191
}
192192

193-
if (!fileId.isEmpty()) {
193+
if (fileId > 0) {
194194
parameters.add(new NameValuePair("sort", "desc"));
195195
parameters.add(new NameValuePair("object_type", "files"));
196-
parameters.add(new NameValuePair("object_id", fileId));
196+
parameters.add(new NameValuePair("object_id", String.valueOf(fileId)));
197197
}
198198

199199
get.setQueryString(parameters.toArray(new NameValuePair[]{}));

src/main/java/com/owncloud/android/lib/resources/comments/CommentFileRemoteOperation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public class CommentFileRemoteOperation extends RemoteOperation {
5858
private static final String VERB_VALUE = "comment";
5959
private static final String MESSAGE = "message";
6060

61-
private String message;
62-
private String fileId;
61+
private final String message;
62+
private final long fileId;
6363

6464
/**
6565
* Constructor
6666
*
6767
* @param message Comment to store
6868
*/
69-
public CommentFileRemoteOperation(String message, String fileId) {
69+
public CommentFileRemoteOperation(String message, long fileId) {
7070
this.message = message;
7171
this.fileId = fileId;
7272
}

src/main/java/com/owncloud/android/lib/resources/comments/MarkCommentsAsReadRemoteOperation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
public class MarkCommentsAsReadRemoteOperation extends RemoteOperation {
4848
private static final String COMMENTS_URL = "/comments/files/";
4949

50-
private String fileId;
50+
private final long fileId;
5151

52-
public MarkCommentsAsReadRemoteOperation(String fileId) {
52+
public MarkCommentsAsReadRemoteOperation(long fileId) {
5353
this.fileId = fileId;
5454
}
5555

src/main/java/com/owncloud/android/lib/resources/files/ReadFileVersionsRemoteOperation.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343

4444
import java.util.ArrayList;
4545

46-
import androidx.annotation.NonNull;
47-
4846
/**
4947
* Remote operation performing the read of remote trashbin folder on Nextcloud server.
5048
*/
@@ -53,16 +51,16 @@ public class ReadFileVersionsRemoteOperation extends RemoteOperation {
5351

5452
private static final String TAG = ReadFileVersionsRemoteOperation.class.getSimpleName();
5553

56-
private String fileId;
54+
private final long localId;
5755
private ArrayList<Object> versions;
5856

5957
/**
6058
* Constructor
6159
*
6260
* @param fileId FileId of the file.
6361
*/
64-
public ReadFileVersionsRemoteOperation(@NonNull String fileId) {
65-
this.fileId = fileId;
62+
public ReadFileVersionsRemoteOperation(long fileId) {
63+
this.localId = fileId;
6664
}
6765

6866
/**
@@ -76,7 +74,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
7674
PropFindMethod query = null;
7775

7876
try {
79-
String uri = client.getNewWebdavUri() + "/versions/" + client.getUserId() + "/versions/" + fileId;
77+
String uri = client.getNewWebdavUri() + "/versions/" + client.getUserId() + "/versions/" + localId;
8078
DavPropertyNameSet propSet = WebdavUtils.getFileVersionPropSet();
8179

8280
query = new PropFindMethod(uri, propSet, DavConstants.DEPTH_1);
@@ -109,16 +107,16 @@ protected RemoteOperationResult run(OwnCloudClient client) {
109107

110108
if (result == null) {
111109
result = new RemoteOperationResult(new Exception("unknown error"));
112-
Log_OC.e(TAG, "Synchronized file with id " + fileId + ": failed");
110+
Log_OC.e(TAG, "Synchronized file with id " + localId + ": failed");
113111
} else {
114112
if (result.isSuccess()) {
115-
Log_OC.i(TAG, "Synchronized file with id " + fileId + ": " + result.getLogMessage());
113+
Log_OC.i(TAG, "Synchronized file with id " + localId + ": " + result.getLogMessage());
116114
} else {
117115
if (result.isException()) {
118-
Log_OC.e(TAG, "Synchronized with id " + fileId + ": " + result.getLogMessage(),
119-
result.getException());
116+
Log_OC.e(TAG, "Synchronized with id " + localId + ": " + result.getLogMessage(),
117+
result.getException());
120118
} else {
121-
Log_OC.w(TAG, "Synchronized with id " + fileId + ": " + result.getLogMessage());
119+
Log_OC.w(TAG, "Synchronized with id " + localId + ": " + result.getLogMessage());
122120
}
123121
}
124122
}
@@ -141,7 +139,7 @@ private void readData(MultiStatus remoteData, OwnCloudClient client) {
141139

142140
// loop to update every child
143141
for (int i = 1; i < remoteData.getResponses().length; ++i) {
144-
versions.add(new FileVersion(fileId, new WebdavEntry(remoteData.getResponses()[i], splitElement)));
142+
versions.add(new FileVersion(localId, new WebdavEntry(remoteData.getResponses()[i], splitElement)));
145143
}
146144
}
147145
}

src/main/java/com/owncloud/android/lib/resources/files/RestoreFileVersionRemoteOperation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public class RestoreFileVersionRemoteOperation extends RemoteOperation {
5050
private static final int RESTORE_READ_TIMEOUT = 30000;
5151
private static final int RESTORE_CONNECTION_TIMEOUT = 5000;
5252

53-
private String fileId;
54-
private String fileName;
53+
private final long fileId;
54+
private final String fileName;
5555

5656
/**
5757
* Constructor
5858
*
5959
* @param fileId fileId
6060
* @param fileName version date in unixtime
6161
*/
62-
public RestoreFileVersionRemoteOperation(String fileId, String fileName) {
62+
public RestoreFileVersionRemoteOperation(long fileId, String fileName) {
6363
this.fileId = fileId;
6464
this.fileName = fileName;
6565
}

src/main/java/com/owncloud/android/lib/resources/files/model/FileVersion.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class FileVersion implements Parcelable, ServerFileInterface {
5151
@Getter @Setter private String mimeType;
5252
@Getter @Setter private long fileLength;
5353
@Getter @Setter private long modifiedTimestamp;
54-
@Getter private String remoteId;
54+
@Getter private long localId;
5555

5656
@Override
5757
public boolean isFavorite() {
@@ -68,12 +68,9 @@ public String getRemotePath() {
6868
return "";
6969
}
7070

71-
/**
72-
* For file version this is the same as remoteId
73-
*/
7471
@Override
75-
public String getLocalId() {
76-
return getRemoteId();
72+
public String getImageKey() {
73+
return String.valueOf(localId);
7774
}
7875

7976
public boolean isFolder() {
@@ -84,8 +81,8 @@ public boolean isHidden() {
8481
return getFileName().startsWith(".");
8582
}
8683

87-
public FileVersion(String fileId, WebdavEntry we) {
88-
remoteId = fileId;
84+
public FileVersion(long fileId, WebdavEntry we) {
85+
localId = fileId;
8986
setMimeType(we.getContentType());
9087

9188
if (isFolder()) {

src/main/java/com/owncloud/android/lib/resources/files/model/ServerFileInterface.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ public interface ServerFileInterface {
88

99
String getRemotePath();
1010

11-
String getLocalId();
12-
13-
String getRemoteId();
11+
String getImageKey();
1412

1513
boolean isFavorite();
1614

src/main/java/com/owncloud/android/lib/resources/trashbin/model/TrashbinFile.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ public class TrashbinFile implements Parcelable, Serializable, ServerFileInterfa
6161
private String originalLocation;
6262
private long deletionTimestamp;
6363

64-
/**
65-
* For trashbin this is the same as remoteId
66-
*/
67-
@Override
68-
public String getLocalId() {
69-
return getRemoteId();
70-
}
71-
7264
@Override
7365
public boolean isFolder() {
7466
return DIRECTORY.equals(mimeType);
@@ -78,14 +70,19 @@ public boolean isHidden() {
7870
return getFileName().startsWith(".");
7971
}
8072

73+
@Override
74+
public String getImageKey() {
75+
return remoteId;
76+
}
77+
8178
@Override
8279
public boolean isFavorite() {
8380
return false;
8481
}
8582

8683
public TrashbinFile(WebdavEntry we, String userId) {
8784
String path = we.decodedPath();
88-
85+
8986
if (path == null || path.length() <= 0 || !path.startsWith(FileUtils.PATH_SEPARATOR)) {
9087
throw new IllegalArgumentException("Trying to create a TrashbinFile with a non valid remote path: " + path);
9188
}

0 commit comments

Comments
 (0)