1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package org.astrogrid.filestore.server.repository ;
52
53 import java.net.URL ;
54 import java.io.IOException ;
55 import java.io.InputStream ;
56 import java.io.OutputStream ;
57
58 import org.astrogrid.filestore.common.file.FileProperty ;
59 import org.astrogrid.filestore.common.file.FileProperties ;
60 import org.astrogrid.filestore.common.file.FileIdentifier ;
61 import org.astrogrid.filestore.common.exception.FileStoreServiceException ;
62 import org.astrogrid.filestore.common.exception.FileStoreNotFoundException ;
63 import org.astrogrid.filestore.common.exception.FileStoreTransferException ;
64
65 /***
66 * Public interface for a file container.
67 *
68 */
69 public interface RepositoryContainer
70 {
71
72 /***
73 * Access to our identifier.
74 * @return The internal identifier for the file.
75 *
76 */
77 public FileIdentifier ident() ;
78
79 /***
80 * Access to our properties.
81 * @return The info for the file.
82 *
83 */
84 public FileProperties properties() ;
85
86 /***
87 * Import an array of bytes.
88 * @param bytes The array of bytes to import into the container.
89 * @throws FileStoreServiceException If unable to complete the action.
90 *
91 */
92 public void importBytes(byte[] bytes)
93 throws FileStoreServiceException ;
94
95 /***
96 * Export our contents as bytes.
97 * @return An array of bytes from the container contents.
98 * @throws FileStoreNotFoundException If unable to locate the file.
99 * @throws FileStoreServiceException If unable to complete the action.
100 *
101 */
102 public byte[] exportBytes()
103 throws FileStoreServiceException, FileStoreNotFoundException ;
104
105 /***
106 * Append an array of bytes.
107 * @param bytes The array of bytes to append to the container.
108 * @throws FileStoreNotFoundException If unable to locate the file.
109 * @throws FileStoreServiceException If unable to complete the action.
110 *
111 */
112 public void appendBytes(byte[] bytes)
113 throws FileStoreServiceException, FileStoreNotFoundException ;
114
115 /***
116 * Delete the contents of the container.
117 * @throws FileStoreNotFoundException If unable to locate the file.
118 * @throws FileStoreServiceException If unable to complete the action.
119 *
120 */
121 public void delete()
122 throws FileStoreServiceException, FileStoreNotFoundException ;
123
124 /***
125 * Get an input stream to the container contents.
126 * @throws FileStoreNotFoundException If unable to locate the file.
127 * @throws FileStoreServiceException If unable to open the file.
128 *
129 */
130 public InputStream getDataInputStream()
131 throws FileStoreServiceException, FileStoreNotFoundException ;
132
133 /***
134 * Get an output stream to the container contents.
135 * @throws FileStoreServiceException If unable to open the local file.
136 *
137 */
138 public OutputStream getDataOutputStream()
139 throws FileStoreServiceException ;
140
141 /***
142 * Import our data from a URL.
143 * @param url The URL to import the data from.
144 * @throws FileStoreTransferException If unable to complete the action.
145 * @throws FileStoreServiceException If unable to open the local file.
146 *
147 */
148 public void importData(URL url)
149 throws FileStoreTransferException, FileStoreServiceException ;
150
151 /***
152 * Import our data from an InputStream.
153 * @param stream The input stream to import the data from.
154 * @throws FileStoreTransferException If unable to complete the action.
155 * @throws FileStoreServiceException If unable to open the local file.
156 *
157 */
158 public void importData(InputStream stream)
159 throws FileStoreTransferException, FileStoreServiceException ;
160
161 /***
162 * Export our data to an OutputStream.
163 * @param stream The output stream to export the data to.
164 * @throws FileStoreTransferException If unable to complete the action.
165 * @throws FileStoreServiceException If unable to open the local file.
166 *
167 */
168 public void exportData(OutputStream stream)
169 throws FileStoreServiceException, FileStoreNotFoundException, FileStoreTransferException ;
170
171 /***
172 * Update the container properties.
173 * Note - if you change the underlying data file you must update the properties.
174 *
175 */
176 public void update()
177 throws FileStoreServiceException ;
178
179 }
180