Skip to content

Commit

Permalink
Merge pull request #141 from nextcloud/userIdForWebdavSearch
Browse files Browse the repository at this point in the history
Use userId for webdav search
  • Loading branch information
AndyScherzinger authored May 22, 2018
2 parents 4c04d44 + f9f8cb2 commit 2c7533c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ArrayList<Object> readData(MultiStatus remoteData,
OwnCloudClient client,
boolean isReadFolderOperation,
boolean isSearchOperation,
String username) {
String userId) {
ArrayList<Object> mFolderAndFiles = new ArrayList<>();

WebdavEntry we;
Expand All @@ -61,8 +61,8 @@ public ArrayList<Object> readData(MultiStatus remoteData,
}

String stripString = client.getWebdavUri().getPath();
if (isSearchOperation && username != null) {
stripString = stripString.substring(0, stripString.lastIndexOf("/")) + "/dav/files/" + username;
if (isSearchOperation && userId != null) {
stripString = stripString.substring(0, stripString.lastIndexOf("/")) + "/dav/files/" + userId;
stripString = stripString.replaceAll(" ", "%20");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ public enum SearchType {
}

private String searchQuery;
private String userId;
private SearchType searchType;
private boolean filterOutFiles;

public SearchOperation(String query, SearchType searchType, boolean filterOutFiles) {
public SearchOperation(String query, SearchType searchType, boolean filterOutFiles, String userId) {
this.searchQuery = query;
this.searchType = searchType;
this.filterOutFiles = filterOutFiles;
this.userId = userId;
}

@Override
Expand Down Expand Up @@ -100,7 +102,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
MultiStatus dataInServer = searchMethod.getResponseBodyAsMultiStatus();
WebDavFileUtils webDavFileUtils = new WebDavFileUtils();
ArrayList<Object> mFolderAndFiles = webDavFileUtils.readData(dataInServer, client, false, true,
client.getCredentials().getUsername());
userId);

// Result of the operation
result = new RemoteOperationResult(true, status, searchMethod.getResponseHeaders());
Expand Down Expand Up @@ -204,7 +206,7 @@ private Document createQuery() {
Element scopeElement = query.createElementNS(DAV_NAMESPACE, "d:scope");
Element hrefElement = query.createElementNS(DAV_NAMESPACE, "d:href");
Element depthElement = query.createElementNS(DAV_NAMESPACE, "d:depth");
Text hrefTextElement = query.createTextNode("/files/" + getClient().getCredentials().getUsername());
Text hrefTextElement = query.createTextNode("/files/" + userId);
Text depthTextElement = query.createTextNode("infinity");
Element whereElement = query.createElementNS(DAV_NAMESPACE, "d:where");
Element folderElement = null;
Expand Down

0 comments on commit 2c7533c

Please sign in to comment.