2 * Copyright 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client.rest.resource;
21 import java.util.ArrayList;
22 import java.util.Date;
23 import java.util.LinkedList;
24 import java.util.List;
26 import com.google.gwt.http.client.URL;
27 import com.google.gwt.json.client.JSONArray;
28 import com.google.gwt.json.client.JSONObject;
29 import com.google.gwt.json.client.JSONParser;
30 import com.google.gwt.user.client.ui.TreeItem;
35 public class SearchResource extends RestResource {
37 public SearchResource(String aUri) {
41 List<FileResource> files = new ArrayList<FileResource>();
42 List<String> filePaths = new LinkedList<String>();
49 public List<String> getFilePaths() {
56 * @param newFilePaths the files to set
58 public void setFilePaths(List<String> newFilePaths) {
59 filePaths = newFilePaths;
67 public List<FileResource> getFiles() {
74 * @param newFiles the files to set
76 public void setFiles(List<FileResource> newFiles) {
81 public void createFromJSON(String text) {
82 JSONArray subs = JSONParser.parse(text).isArray();
84 for (int i = 0; i < subs.size(); i++) {
85 JSONObject fo = subs.get(i).isObject();
87 String fname = unmarshallString(fo, "name");
88 String fowner = unmarshallString(fo, "owner");
89 String fcontent = unmarshallString(fo, "content");
90 String fpath = unmarshallString(fo, "path");
91 fpath = URL.decodeComponent(fpath);
92 Integer fversion = null;
93 if (fo.get("version") != null)
94 fversion = new Integer(fo.get("version").toString());
95 boolean fdeleted = unmarshallBoolean(fo, "deleted");
96 Date fcreationDate = null;
97 if (fo.get("creationDate") != null)
98 fcreationDate = new Date(new Long(fo.get("creationDate").toString()));
99 Date fmodificationDate = null;
100 if (fo.get("modificationDate") != null)
101 fmodificationDate = new Date(new Long(fo.get("modificationDate").toString()));
102 String furi = unmarshallString(fo,"uri");
104 if(fo.get("size") != null)
105 fsize = new Long(fo.get("size").toString());
107 FileResource fs = new FileResource(furi);
110 fs.setVersion(fversion);
111 fs.setContentLength(fsize);
112 fs.setDeleted(fdeleted);
113 fs.setCreationDate(fcreationDate);
114 fs.setModificationDate(fmodificationDate);
115 fs.setContentType(fcontent);
123 public String getLastModifiedSince() {
127 * Bugzilla – Bug 371, Add history support for folder navigation
129 public void updateHistoryAbs(TreeItem item, String path){
130 throw new UnsupportedOperationException();