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;
34 public class SearchResource extends RestResource {
36 public SearchResource(String aUri) {
40 List<FileResource> files = new ArrayList<FileResource>();
41 List<String> filePaths = new LinkedList<String>();
48 public List<String> getFilePaths() {
55 * @param newFilePaths the files to set
57 public void setFilePaths(List<String> newFilePaths) {
58 filePaths = newFilePaths;
66 public List<FileResource> getFiles() {
73 * @param newFiles the files to set
75 public void setFiles(List<FileResource> newFiles) {
80 public void createFromJSON(String text) {
81 JSONArray subs = JSONParser.parse(text).isArray();
83 for (int i = 0; i < subs.size(); i++) {
84 JSONObject fo = subs.get(i).isObject();
86 String fname = unmarshallString(fo, "name");
87 String fowner = unmarshallString(fo, "owner");
88 String fcontent = unmarshallString(fo, "content");
89 String fpath = unmarshallString(fo, "path");
90 fpath = URL.decodeComponent(fpath);
91 Integer fversion = null;
92 if (fo.get("version") != null)
93 fversion = new Integer(fo.get("version").toString());
94 boolean fdeleted = unmarshallBoolean(fo, "deleted");
95 Date fcreationDate = null;
96 if (fo.get("creationDate") != null)
97 fcreationDate = new Date(new Long(fo.get("creationDate").toString()));
98 String furi = unmarshallString(fo,"uri");
100 if(fo.get("size") != null)
101 fsize = new Long(fo.get("size").toString());
103 FileResource fs = new FileResource(furi);
106 fs.setVersion(fversion);
107 fs.setContentLength(fsize);
108 fs.setDeleted(fdeleted);
109 fs.setCreationDate(fcreationDate);
110 fs.setContentType(fcontent);