source: other-projects/FileTransfer-WebSocketPair/testGXTWithGreenstone/src/com/gs3/testGXT/server/Greenstone/GWTFileJob.java@ 33053

Last change on this file since 33053 was 33053, checked in by ak19, 5 years ago

I still had some stuff of Nathan Kelly's (FileTransfer-WebSocketPair) sitting on my USB. Had already commited the Themes folder at the time, 2 years back. Not sure if he wanted this additional folder commited. But I didn't want to delete it and decided it will be better off on SVN. When we use his project, if we find we didn't need this test folder, we can remove it from svn then.

File size: 4.9 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *########################################################################
26 */
27package com.gs3.testGXT.server.Greenstone;
28
29/** This object encapsulates all the information about a certain file movement job. This job be to create a copy of a file from one place to another, or to simply delete a file.
30 * @author John Thompson
31 * @version 2.3c
32 */
33public class GWTFileJob {
34 /** true to mark that this file has already been copied, false otherwise. */
35 public boolean done = false;
36
37 /** Origin of the operation - ie, files to be moved/deleted*/
38 private GWTFileNode origin = null;
39 /** Destination of the operation: ie, destination of file move */
40 private GWTFileNode destination = null;
41
42 /** The type of this movement as an byte. */
43 public byte type = 0;
44 /** The unique identifier shared by all jobs created by the same action. */
45 private long id = 0;
46 /** An element of the job type enumeration indicating a copy action. */
47 static final public byte COPY = 1;
48 /** An element of the job type enumeration indicating a delete action. */
49 static final public byte DELETE = 2;
50 /** An element of the job type enumeration indicating a move action. */
51 static final public byte MOVE = 3;
52 /** An element of the job type enumeration indicating a new folder action. */
53 static final public byte NEW_FOLDER = 4;
54 /** An element of the job type enumeration indicating an empty folder delete action. */
55 static final public byte DELETE_EMPTY_DIRECTORY = 5;
56 /** An element of the job type enumeration indicating a rename action. */
57 static final public byte RENAME = 6;
58 /** An element of the job type enumeration indicating a replace action. */
59 static final public byte REPLACE = 7;
60 /** An element of the job type enumeration indicating a copy action (but don't look for metadata. */
61 static final public byte COPY_FILE_ONLY = 8;
62
63 /** Constructor.
64 * @param id A unique identifier for this job (and others created with a single gesture) as a long.
65 * @param source The DragComponent source of this file, most likely a GTree.
66 * @param orig The FileNode you wish to mode.
67 * @param target The DragComponent to move the file to, again most likely a GTree.
68 * @param dest The files new FileNode parent within the target.
69 * @param type The type of this movement as an int, either COPY or DELETE.
70 */
71 public GWTFileJob(long id, GWTFileNode orig, GWTFileNode dest, byte type) {
72 this.id = id;
73 this.type = type;
74
75 this.origin = orig;
76 this.destination = dest;
77 ///System.err.println("New Job: " + type + ", " + source + ", " + target);
78 // Dont store FileNodes which can go stale. Store paths instead, which are used to locate current 'fresh' versions of nodes.
79 }
80
81 /** Retrieve the destination node. Watch out for stale versions by always attempting to load the node at destination_path first. */
82 public GWTFileNode getDestination() {
83 return destination;
84 }
85
86 /** Retrieve the origin node. Watch out for stale versions by always attempting to load the node at origin_path first. */
87 public GWTFileNode getOrigin() {
88 return origin;
89 }
90
91 /** Retrieve the id for this job. */
92 public long ID() {
93 return id;
94 }
95
96 public String toString() {
97 StringBuffer text = new StringBuffer("");
98 switch(type) {
99 case COPY:
100 text.append("copy ");
101 break;
102 case DELETE:
103 text.append("delete ");
104 break;
105 case MOVE:
106 text.append("move ");
107 break;
108 case DELETE_EMPTY_DIRECTORY:
109 text.append("empty directory delete ");
110 break;
111 default:
112 text.append("unknown ");
113 }
114 GWTFileNode origin = getOrigin();
115 if(origin != null) {
116 text.append(origin.getFile().getAbsolutePath());
117 }
118 else {
119 text.append("ERROR!");
120 }
121 if (type != DELETE && type != DELETE_EMPTY_DIRECTORY) {
122 text.append(" -> ");
123 GWTFileNode destination = getDestination();
124 if(destination != null) {
125 text.append(destination.getFile().getAbsolutePath());
126 }
127 else {
128 text.append("Recycle Bin");
129 }
130 }
131 return text.toString();
132 }
133}
Note: See TracBrowser for help on using the repository browser.