View Javadoc

1   /*
2    * $Id: MySpaceFile.java,v 1.3 2004/08/27 22:43:15 dave Exp $
3    *
4    * Copyright 2003 AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid Software License,
7    * a copy of which has been included with this distribution in the LICENSE.txt file.
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  $Log: MySpaceFile.java,v $
129  Revision 1.3  2004/08/27 22:43:15  dave
130  Updated filestore and myspace to report file size correctly.
131 
132  Revision 1.2.66.1  2004/08/27 16:16:15  dave
133  Added temp debug ...
134 
135  Revision 1.2  2004/06/14 23:08:52  jdt
136  Merge from branches
137  ClientServerSplit_JDT
138  and
139  MySpaceClientServerSplit_JDT
140  
141  MySpace now split into a client/delegate jar
142  astrogrid-myspace-<version>.jar
143  and a server/manager war
144  astrogrid-myspace-server-<version>.war
145 
146  Revision 1.1.2.1  2004/06/14 22:33:20  jdt
147  Split into delegate jar and server war.  
148  Delegate: astrogrid-myspace-SNAPSHOT.jar
149  Server/Manager: astrogrid-myspace-server-SNAPSHOT.war
150  
151  Package names unchanged.
152  If you regenerate the axis java/wsdd/wsdl files etc you'll need
153  to move some files around to ensure they end up in the client
154  or the server as appropriate.
155  As of this check-in the tests/errors/failures is 162/1/22 which
156  matches that before the split.
157 
158  Revision 1.3  2004/05/03 08:55:53  mch
159  Fixes to getFiles(), introduced getSize(), getOwner() etc to StoreFile
160 
161  Revision 1.2  2004/04/23 11:38:19  mch
162  Fixes to return correct AGSL plus change to File model for It05 delegate
163 
164  Revision 1.1  2004/03/04 12:51:31  mch
165  Moved delegate implementations into subpackages
166 
167  Revision 1.4  2004/03/01 22:38:46  mch
168  Part II of copy from It4.1 datacenter + updates from myspace meetings + test fixes
169 
170  Revision 1.3  2004/03/01 16:38:58  mch
171  Merged in from datacenter 4.1 and odd cvs/case problems
172 
173  Revision 1.2  2004/03/01 15:15:04  mch
174  Updates to Store delegates after myspace meeting
175 
176  Revision 1.1  2004/02/24 15:59:56  mch
177  Moved It04.1 Datacenter VoSpaceClient stuff to myspace as StoreClient stuff
178 
179  Revision 1.2  2004/02/19 23:30:30  mch
180  Added getXxxxx properties
181 
182  Revision 1.1  2004/02/15 23:16:06  mch
183  New-style VoSpace delegates.  Not agreed so private to datacenter for the moment
184 
185  */
186