1
2
3
4
5
6
7 package org.astrogrid.store.delegate;
8
9 import java.io.IOException;
10 import java.io.InputStream;
11 import java.io.OutputStream;
12 import java.net.URL;
13 import org.astrogrid.community.User;
14 import org.astrogrid.store.Agsl;
15
16 /***
17 * These are the methods that delegates to storage mechanisms used by Astrogrid must implement.
18 * <p>
19 * StoreClients are those that give a standard access to the various
20 * stores on the net. Amongst there are the AstroGrid MySpace services, but also
21 * a local filestore (eg for intranets), ftp and one day grid ftp delegates.
22 *
23 * This interface defines run-of-the-mill file operations; use StoreAdminClient
24 * for store administration tasks such as adding & removing users
25 *
26 * Note that there is a difference between the user (termed *operator* here) of
27 * this class, and the owner of the files that might be being browsed.
28 */
29
30 public interface StoreClient {
31
32 /***
33 * Returns the user of this delegate - ie the account it is being used by
34 */
35 public User getOperator();
36
37 /***
38 * Returns the Agsl to the service this client is connected to
39 */
40 public Agsl getEndpoint();
41
42 /***
43 * Returns a tree representation of the files that match the expression
44 */
45 public StoreFile getFiles(String filter) throws IOException;
46
47
48
49
50
51
52
53
54
55
56
57 /***
58 * Returns the StoreFile representation of the file at the given path
59 */
60 public StoreFile getFile(String path) throws IOException;
61
62 /***
63 * Puts the given byte buffer from offset of length bytes, to the given target
64 */
65 public void putBytes(byte[] bytes, int offset, int length, String targetPath, boolean append) throws IOException;
66
67 /***
68 * Puts the given string into the given location
69 * @deprecated - use putBytes() or stream to putStream()
70 */
71 public void putString(String contents, String targetPath, boolean append) throws IOException;
72
73 /***
74 * Copies the contents of the file at the given source url to the given location
75 */
76 public void putUrl(URL source, String targetPath, boolean append) throws IOException;
77
78 /***
79 * Streaming output - returns a stream that can be used to output to the given
80 * location
81 */
82 public OutputStream putStream(String targetPath, boolean append) throws IOException;
83
84 /***
85 * Gets a file's contents as a stream
86 */
87 public InputStream getStream(String sourcePath) throws IOException;
88
89 /***
90 * Gets the url to the given source file
91 * @deprecated? don't think we should always publish files as URLs... mch
92 */
93 public URL getUrl(String sourcePath) throws IOException;
94
95 /***
96 * Returns the Agsl for the given source path. This should be sufficient
97 * that we can reach the file for writing to as well; if this requires a
98 * delegate, then the agsl should include the delegate endpoint (eg myspace)
99 * rather than a read-only URL
100 */
101 public Agsl getAgsl(String sourcePath) throws IOException;
102
103 /***
104 * Delete a file
105 */
106 public void delete(String deletePath) throws IOException;
107
108 /***
109 * Copy a file to a target Agsl
110 */
111 public void copy(String sourcePath, Agsl target) throws IOException;
112
113 /***
114 * Copy a file from a source Agsl
115 */
116 public void copy(Agsl source, String targetPath) throws IOException;
117
118 /***
119 * Moves/Renames a file to a target Agsl
120 */
121 public void move(String sourcePath, Agsl target) throws IOException;
122
123 /***
124 * Moves/Renames a file from a source Agsl
125 */
126 public void move(Agsl source, String targetPath) throws IOException;
127
128 /***
129 * Create a container
130 */
131 public void newFolder(String targetPath) throws IOException ;
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