Commit 7766d560 authored by Raimbek Egemberdiev's avatar Raimbek Egemberdiev

перенесены методы StorageManager

parent 7e3cc3c2
......@@ -91,4 +91,66 @@ public class StorageService {
}
return JsonUtils.read(restHttpQuery.doQuery(query), new TypeReference<List<SynergyFile>>() {});
}
public SynergyFile findInStorage(String parentId, String fileName) throws IOException {
List<SynergyFile> synergyFiles = storageList(parentId);
for (SynergyFile synergyFile : synergyFiles) {
if (synergyFile.getName().equals(fileName)) {
return synergyFile;
}
if (synergyFile.isFolder()) {
SynergyFile result = findInStorage(synergyFile.getIdentifier(), fileName);
if (result != null) {
return result;
}
}
}
return null;
}
public String copy(String identifier, String documentId) throws IOException {
Query query = Query.newInstance()
.methodPost()
.url("/rest/api/storage/copy")
.formParam("fileID", identifier)
.formParam("documentID", documentId);
String result = restHttpQuery.doQuery(query);
return JsonUtils.getValueByKey(result, "fileID");
}
public String add(String identifier, String tmpFileName, String synergyFileName) throws IOException {
Query query = Query.newInstance().url("/rest/api/storage/add")
.methodPost()
.formParam("folderID", identifier)
.formParam("path", tmpFileName)
.formParam("name", synergyFileName);
String result = restHttpQuery.doQuery(query);
return JsonUtils.getValueByKey(result, "fileID");
}
public String move(String fileIdentifier, String folderID) throws IOException {
Query query = Query.newInstance()
.methodPost()
.url("/rest/api/storage/move")
.formParam("elementID", fileIdentifier)
.formParam("folderID", folderID);
return restHttpQuery.doQuery(query);
}
public String createFolder(String parent, String name) throws IOException {
Query query = Query.newInstance()
.methodPost()
.url("/rest/api/storage/create")
.formParam("folderID", parent)
.formParam("folderName", name);
return restHttpQuery.doQuery(query);
}
public byte[] downloadFile(String identifier) throws IOException {
Query query = Query.newInstance()
.url("/rest/api/storage/file/get")
.queryParam("identifier", identifier)
.queryParam("inline", "true");
return restHttpQuery.doQueryAndReturnBytes(query);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment