import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.FileHeader;
+import gr.ebs.gss.server.domain.FileBody;
import gr.ebs.gss.server.domain.User;
-import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
import java.io.IOException;
import java.net.URLDecoder;
import org.json.JSONException;
import org.json.JSONObject;
-
/**
* A class that handles operations on the 'search' namespace.
*
void serveSearchResults(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String path = getInnerPath(req, PATH_SEARCH);
- path = path.substring(1);
- path = path.substring(0,path.length()-1);
+ if(path.indexOf("/") == 0)
+ path = path.substring(1);
+ if(path.lastIndexOf("/") == path.length()-1)
+ path = path.substring(0,path.length()-1);
if (!isValidResourceName(path)) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
User user = getUser(req);
JSONArray json = new JSONArray();
- List<FileHeaderDTO> fileHeaders = getService().searchFiles(user.getId(), URLDecoder.decode(path,"UTF-8"));
- for (FileHeaderDTO f: fileHeaders) {
+ List<FileHeader> fileHeaders = getService().searchFiles(user.getId(), URLDecoder.decode(path,"UTF-8"));
+ for (FileHeader f: fileHeaders) {
+ FileBody currentBody = f.getCurrentBody();
JSONObject j = new JSONObject();
j.put("name", f.getName()).
put("owner", f.getOwner().getUsername()).
put("deleted", f.isDeleted()).
- put("version", f.getVersion()).
- put("size", f.getFileSize()).
+ put("version", currentBody.getVersion()).
+ put("size", currentBody.getFileSize()).
put("path", f.getFolder().getPath()).
- put("content", f.getMimeType()).
+ put("content", currentBody.getMimeType()).
+ put("shared", f.getShared()).
+ put("versioned",f.isVersioned()).
put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
put("modificationDate", f.getAuditInfo().getModificationDate().getTime()).
put("uri", getApiRoot() + f.getURI());