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 com.google.gwt.json.client.JSONObject;
22 import com.google.gwt.json.client.JSONParser;
29 public class UploadStatusResource extends RestResource{
30 long bytesTransferred;
33 public UploadStatusResource(String aUri) {
38 * Retrieve the bytesTransferred.
40 * @return the bytesTransferred
42 public long getBytesTransferred() {
43 return bytesTransferred;
47 * Modify the bytesTransferred.
49 * @param newBytesTransferred the bytesTransferred to set
51 public void setBytesTransferred(long newBytesTransferred) {
52 bytesTransferred = newBytesTransferred;
56 * Retrieve the fileSize.
58 * @return the fileSize
60 public long getFileSize() {
65 * Modify the fileSize.
67 * @param newFileSize the fileSize to set
69 public void setFileSize(long newFileSize) {
70 fileSize = newFileSize;
74 return new Long(bytesTransferred * 100 / fileSize).intValue();
78 public void createFromJSON(String text) {
79 JSONObject json = (JSONObject) JSONParser.parse(text);
80 if(json.get("bytesTotal") != null)
81 fileSize = new Long(json.get("bytesTotal").toString());
82 if(json.get("bytesUploaded") != null)
83 bytesTransferred = new Long(json.get("bytesUploaded").toString());