1
2
3
4
5
6
7
8
9
10 package org.astrogrid.store.delegate.myspace;
11 import java.net.MalformedURLException;
12 import java.net.URL;
13 import org.astrogrid.store.Agsl;
14 import org.astrogrid.store.delegate.StoreFile;
15 import java.util.Date;
16
17 /***
18 * Represents a file in myspace (it04). There is also MySpaceFolder to represent
19 * a folder.
20 * It04 MySpace delegate only has one method for returning the files, and that
21 * method returns the whole tree. So we can assume getParent() getChildren()
22 * etc are always fully populated
23 *
24 * @author mch
25 */
26
27
28 public class MySpaceFile implements StoreFile {
29
30 long size ;
31 String name , owner, created, expires, permissions = null;
32 URL url = null;
33
34 MySpaceFileType type = null;
35 MySpaceFolder parentFolder = null;
36
37 public MySpaceFile(MySpaceFolder parent, String child) {
38 this.name = child;
39 this.parentFolder = parent;
40 }
41
42 public MySpaceFile(MySpaceFolder parent, String aFilename, String anOwner, String aCreatedDate, String anExpiryDate, long aSize, String somePermissions, MySpaceFileType aType) {
43 this(parent, aFilename);
44
45 this.owner = anOwner;
46 this.created = aCreatedDate;
47 this.expires = anExpiryDate;
48 this.size = aSize;
49 this.permissions = somePermissions;
50 this.type = aType;
51 }
52
53 /***
54 * constructor taking URL too - for historical purposes - URLs should be deprecated
55 */
56 public MySpaceFile(MySpaceFolder parent, String aFilename, String anOwner, String aCreatedDate, String anExpiryDate, long aSize, String somePermissions, MySpaceFileType aType, URL aUrl) {
57 this(parent, aFilename);
58
59 this.owner = anOwner;
60 this.created = aCreatedDate;
61 this.expires = anExpiryDate;
62 this.size = aSize;
63 this.permissions = somePermissions;
64 this.type = aType;
65 this.url = aUrl;
66 }
67
68 public String getType() { return type.toString(); }
69
70 public String toString() { return getName(); }
71
72 public String getOwner() { return owner; }
73
74 /*** Returns the date the file was created */
75 public Date getCreated() { return new Date(created); }
76
77 public String getExpires() { return expires; }
78
79 public long getSize() { return size; }
80
81 public String getPermissions() { return permissions; }
82
83 /*** Returns the mime type (null if unknown) */
84 public String getMimeType() {
85 return null;
86 }
87
88 /*** Returns the date the file was last modified (null if unknown) */
89 public Date getModified() { return null; }
90
91 /*** Returns URL to the file */
92 public URL getUrl() { return url; }
93
94 /*** Returns the path to this file on the server */
95 public String getPath() {
96 return getParent().getPath()+getName();
97 }
98
99 public String getName() { return name; }
100
101 /*** Returns the parent folder */
102 public StoreFile getParent() {
103 return parentFolder;
104 }
105
106
107 /*** Lists children files if this is a container - returns null otherwise */
108 public StoreFile[] listFiles() { return null; }
109
110 /*** Returns true if this is a container that can hold other files/folders */
111 public boolean isFolder() { return false; }
112
113 /*** Returns true if this is a self-contained file. For example, a database
114 * table might be represented as a StoreFile but it is not a file */
115 public boolean isFile() { return true; }
116
117 /*** Returns true if this represents the same file as the given one */
118 public boolean equals(StoreFile anotherFile) {
119 if (anotherFile instanceof MySpaceFile) {
120 return name.equals( ((MySpaceFile) anotherFile).name) &&
121 parentFolder.equals(((MySpaceFile) anotherFile).parentFolder);
122 }
123 return false;
124 }
125 }
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186