1 |
8810
|
leinfelder
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2000-2011 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
*
|
6 |
|
|
* '$Author$'
|
7 |
|
|
* '$Date$'
|
8 |
|
|
*
|
9 |
|
|
* This program is free software; you can redistribute it and/or modify
|
10 |
|
|
* it under the terms of the GNU General Public License as published by
|
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
12 |
|
|
* (at your option) any later version.
|
13 |
|
|
*
|
14 |
|
|
* This program is distributed in the hope that it will be useful,
|
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
* GNU General Public License for more details.
|
18 |
|
|
*
|
19 |
|
|
* You should have received a copy of the GNU General Public License
|
20 |
|
|
* along with this program; if not, write to the Free Software
|
21 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22 |
|
|
*/
|
23 |
|
|
|
24 |
|
|
package edu.ucsb.nceas.metacat.dataone.v1;
|
25 |
|
|
|
26 |
9389
|
tao
|
import java.io.IOException;
|
27 |
8810
|
leinfelder
|
import java.io.InputStream;
|
28 |
9032
|
tao
|
import java.sql.SQLException;
|
29 |
8810
|
leinfelder
|
import java.util.Date;
|
30 |
|
|
|
31 |
|
|
import javax.servlet.http.HttpServletRequest;
|
32 |
|
|
|
33 |
9600
|
tao
|
import org.apache.commons.io.IOUtils;
|
34 |
8810
|
leinfelder
|
import org.apache.log4j.Logger;
|
35 |
|
|
import org.dataone.service.exceptions.IdentifierNotUnique;
|
36 |
|
|
import org.dataone.service.exceptions.InsufficientResources;
|
37 |
|
|
import org.dataone.service.exceptions.InvalidRequest;
|
38 |
|
|
import org.dataone.service.exceptions.InvalidSystemMetadata;
|
39 |
|
|
import org.dataone.service.exceptions.InvalidToken;
|
40 |
|
|
import org.dataone.service.exceptions.NotAuthorized;
|
41 |
|
|
import org.dataone.service.exceptions.NotFound;
|
42 |
|
|
import org.dataone.service.exceptions.NotImplemented;
|
43 |
|
|
import org.dataone.service.exceptions.ServiceFailure;
|
44 |
|
|
import org.dataone.service.exceptions.SynchronizationFailed;
|
45 |
|
|
import org.dataone.service.exceptions.UnsupportedType;
|
46 |
|
|
import org.dataone.service.mn.tier1.v1.MNCore;
|
47 |
|
|
import org.dataone.service.mn.tier1.v1.MNRead;
|
48 |
|
|
import org.dataone.service.mn.tier2.v1.MNAuthorization;
|
49 |
|
|
import org.dataone.service.mn.tier3.v1.MNStorage;
|
50 |
|
|
import org.dataone.service.mn.tier4.v1.MNReplication;
|
51 |
|
|
import org.dataone.service.mn.v1.MNQuery;
|
52 |
|
|
import org.dataone.service.types.v1.Checksum;
|
53 |
|
|
import org.dataone.service.types.v1.DescribeResponse;
|
54 |
|
|
import org.dataone.service.types.v1.Event;
|
55 |
|
|
import org.dataone.service.types.v1.Identifier;
|
56 |
|
|
import org.dataone.service.types.v1.Log;
|
57 |
|
|
import org.dataone.service.types.v1.Node;
|
58 |
|
|
import org.dataone.service.types.v1.NodeReference;
|
59 |
|
|
import org.dataone.service.types.v1.ObjectFormatIdentifier;
|
60 |
|
|
import org.dataone.service.types.v1.ObjectList;
|
61 |
|
|
import org.dataone.service.types.v1.Permission;
|
62 |
|
|
import org.dataone.service.types.v1.Session;
|
63 |
|
|
import org.dataone.service.types.v1.SystemMetadata;
|
64 |
|
|
import org.dataone.service.types.v1_1.QueryEngineDescription;
|
65 |
|
|
import org.dataone.service.types.v1_1.QueryEngineList;
|
66 |
9304
|
tao
|
import org.dataone.service.types.v2.TypeFactory;
|
67 |
8810
|
leinfelder
|
|
68 |
9032
|
tao
|
import edu.ucsb.nceas.metacat.IdentifierManager;
|
69 |
9074
|
tao
|
import edu.ucsb.nceas.metacat.dataone.convert.LogV2toV1Converter;
|
70 |
9032
|
tao
|
|
71 |
8810
|
leinfelder
|
/**
|
72 |
|
|
* Represents Metacat's implementation of the DataONE Member Node
|
73 |
|
|
* service API, v1. Methods typically pass through to the current
|
74 |
|
|
* version implementation performing type conversion as needed.
|
75 |
|
|
*
|
76 |
|
|
*/
|
77 |
|
|
public class MNodeService
|
78 |
|
|
implements MNAuthorization, MNCore, MNRead, MNReplication, MNStorage, MNQuery {
|
79 |
|
|
|
80 |
|
|
/**
|
81 |
|
|
* current version implementation
|
82 |
|
|
*/
|
83 |
|
|
edu.ucsb.nceas.metacat.dataone.MNodeService impl = null;
|
84 |
|
|
|
85 |
|
|
/* the logger instance */
|
86 |
|
|
private Logger logMetacat = null;
|
87 |
|
|
|
88 |
|
|
/**
|
89 |
|
|
* Singleton accessor to get an instance of MNodeService.
|
90 |
|
|
*
|
91 |
|
|
* @return instance - the instance of MNodeService
|
92 |
|
|
*/
|
93 |
|
|
public static MNodeService getInstance(HttpServletRequest request) {
|
94 |
|
|
return new MNodeService(request);
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* Constructor, private for singleton access
|
99 |
|
|
*/
|
100 |
|
|
private MNodeService(HttpServletRequest request) {
|
101 |
|
|
logMetacat = Logger.getLogger(MNodeService.class);
|
102 |
|
|
impl = edu.ucsb.nceas.metacat.dataone.MNodeService.getInstance(request);
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
public void setSession(Session session) {
|
106 |
|
|
impl.setSession(session);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
public boolean isAdminAuthorized(Session session) throws ServiceFailure, InvalidToken, NotAuthorized, NotImplemented {
|
110 |
|
|
return impl.isAdminAuthorized(session);
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
@Override
|
114 |
|
|
public QueryEngineDescription getQueryEngineDescription(String engine)
|
115 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
116 |
|
|
NotFound {
|
117 |
|
|
return impl.getQueryEngineDescription(null, engine);
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
@Override
|
121 |
|
|
public QueryEngineList listQueryEngines() throws InvalidToken,
|
122 |
|
|
ServiceFailure, NotAuthorized, NotImplemented {
|
123 |
|
|
return impl.listQueryEngines(null);
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
@Override
|
127 |
|
|
public InputStream query(String engine, String query) throws InvalidToken,
|
128 |
|
|
ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented,
|
129 |
|
|
NotFound {
|
130 |
|
|
return impl.query(null, engine, query);
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
@Override
|
134 |
|
|
public Identifier archive(Identifier pid) throws InvalidToken,
|
135 |
|
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
136 |
9050
|
tao
|
String serviceFailure = "2912";
|
137 |
|
|
String notFound = "2911";
|
138 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
139 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
140 |
8810
|
leinfelder
|
return impl.archive(null, pid);
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
@Override
|
144 |
|
|
@Deprecated
|
145 |
|
|
public Identifier archive(Session session, Identifier pid)
|
146 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
147 |
|
|
NotImplemented {
|
148 |
9050
|
tao
|
String serviceFailure = "2912";
|
149 |
|
|
String notFound = "2911";
|
150 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
151 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
152 |
8810
|
leinfelder
|
return impl.archive(session, pid);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
@Override
|
156 |
|
|
public Identifier create(Identifier pid, InputStream object,
|
157 |
|
|
SystemMetadata sysmeta) throws IdentifierNotUnique,
|
158 |
|
|
InsufficientResources, InvalidRequest, InvalidSystemMetadata,
|
159 |
|
|
InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
160 |
|
|
UnsupportedType {
|
161 |
|
|
return this.create(null, pid, object, sysmeta);
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
@Override
|
165 |
|
|
@Deprecated
|
166 |
|
|
public Identifier create(Session session, Identifier pid, InputStream object,
|
167 |
|
|
SystemMetadata sysmeta) throws IdentifierNotUnique,
|
168 |
|
|
InsufficientResources, InvalidRequest, InvalidSystemMetadata,
|
169 |
|
|
InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
170 |
|
|
UnsupportedType {
|
171 |
|
|
//convert sysmeta to newer version
|
172 |
|
|
org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
|
173 |
|
|
try {
|
174 |
9304
|
tao
|
v2Sysmeta = TypeFactory.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
|
175 |
8810
|
leinfelder
|
} catch (Exception e) {
|
176 |
9600
|
tao
|
IOUtils.closeQuietly(object);
|
177 |
8810
|
leinfelder
|
// report as service failure
|
178 |
|
|
ServiceFailure sf = new ServiceFailure("1190", e.getMessage());
|
179 |
|
|
sf.initCause(e);
|
180 |
|
|
throw sf;
|
181 |
|
|
}
|
182 |
|
|
|
183 |
|
|
return impl.create(session, pid, object, v2Sysmeta);
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
@Override
|
187 |
|
|
public Identifier delete(Identifier pid) throws InvalidToken,
|
188 |
|
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
189 |
9050
|
tao
|
String serviceFailure = "2902";
|
190 |
|
|
String notFound = "2901";
|
191 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
192 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
193 |
8810
|
leinfelder
|
return impl.delete(null, pid);
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
@Override
|
197 |
|
|
@Deprecated
|
198 |
|
|
public Identifier delete(Session session, Identifier pid)
|
199 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
200 |
|
|
NotImplemented {
|
201 |
9050
|
tao
|
String serviceFailure = "2902";
|
202 |
|
|
String notFound = "2901";
|
203 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
204 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
205 |
8810
|
leinfelder
|
return impl.delete(session, pid);
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
@Override
|
209 |
|
|
public Identifier generateIdentifier(String scheme, String fragment)
|
210 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
211 |
|
|
InvalidRequest {
|
212 |
|
|
return impl.generateIdentifier(null, scheme, fragment);
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
@Override
|
216 |
|
|
@Deprecated
|
217 |
|
|
public Identifier generateIdentifier(Session session, String scheme, String fragment)
|
218 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
219 |
|
|
InvalidRequest {
|
220 |
|
|
return impl.generateIdentifier(session, scheme, fragment);
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
@Override
|
224 |
|
|
public Identifier update(Identifier pid, InputStream object,
|
225 |
|
|
Identifier newPid, SystemMetadata sysmeta) throws IdentifierNotUnique,
|
226 |
|
|
InsufficientResources, InvalidRequest, InvalidSystemMetadata,
|
227 |
|
|
InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
228 |
|
|
UnsupportedType, NotFound {
|
229 |
|
|
return this.update(null, pid, object, newPid, sysmeta);
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
@Override
|
233 |
|
|
@Deprecated
|
234 |
|
|
public Identifier update(Session session, Identifier pid, InputStream object,
|
235 |
|
|
Identifier newPid, SystemMetadata sysmeta) throws IdentifierNotUnique,
|
236 |
|
|
InsufficientResources, InvalidRequest, InvalidSystemMetadata,
|
237 |
|
|
InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
238 |
|
|
UnsupportedType, NotFound {
|
239 |
9043
|
tao
|
//check if the pid exists and not a sid
|
240 |
|
|
String serviceFailure = "1310";
|
241 |
|
|
String notFound = "1280";
|
242 |
9600
|
tao
|
try {
|
243 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
244 |
9043
|
tao
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
245 |
9600
|
tao
|
} catch (Exception e) {
|
246 |
|
|
IOUtils.closeQuietly(object);
|
247 |
|
|
throw e;
|
248 |
|
|
}
|
249 |
8810
|
leinfelder
|
//convert sysmeta to newer version
|
250 |
|
|
org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
|
251 |
|
|
try {
|
252 |
9304
|
tao
|
v2Sysmeta = TypeFactory.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
|
253 |
8810
|
leinfelder
|
} catch (Exception e) {
|
254 |
9600
|
tao
|
IOUtils.closeQuietly(object);
|
255 |
8810
|
leinfelder
|
// report as service failure
|
256 |
|
|
ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
|
257 |
|
|
sf.initCause(e);
|
258 |
|
|
throw sf;
|
259 |
|
|
}
|
260 |
|
|
return impl.update(session, pid, object, newPid, v2Sysmeta);
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
@Override
|
264 |
|
|
public boolean replicate(SystemMetadata sysmeta, NodeReference sourceNode)
|
265 |
|
|
throws NotImplemented, ServiceFailure, NotAuthorized,
|
266 |
|
|
InvalidRequest, InvalidToken, InsufficientResources,
|
267 |
|
|
UnsupportedType {
|
268 |
|
|
return this.replicate(null, sysmeta, sourceNode);
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
@Override
|
272 |
|
|
@Deprecated
|
273 |
|
|
public boolean replicate(Session session, SystemMetadata sysmeta,
|
274 |
|
|
NodeReference sourceNode) throws NotImplemented, ServiceFailure,
|
275 |
|
|
NotAuthorized, InvalidRequest, InvalidToken, InsufficientResources,
|
276 |
|
|
UnsupportedType {
|
277 |
|
|
//convert sysmeta to newer version
|
278 |
|
|
org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
|
279 |
|
|
try {
|
280 |
9304
|
tao
|
v2Sysmeta = TypeFactory.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
|
281 |
8810
|
leinfelder
|
} catch (Exception e) {
|
282 |
|
|
// report as service failure
|
283 |
|
|
ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
|
284 |
|
|
sf.initCause(e);
|
285 |
|
|
throw sf;
|
286 |
|
|
}
|
287 |
|
|
return impl.replicate(session, v2Sysmeta, sourceNode);
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
@Override
|
291 |
|
|
public DescribeResponse describe(Identifier pid) throws InvalidToken,
|
292 |
|
|
NotAuthorized, NotImplemented, ServiceFailure, NotFound {
|
293 |
9036
|
tao
|
String serviceFailure = "1030";
|
294 |
|
|
String notFound = "1020";
|
295 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
296 |
|
|
"No system metadata could be found for given PID: "+pid.getValue());
|
297 |
8810
|
leinfelder
|
return impl.describe(null, pid);
|
298 |
|
|
}
|
299 |
|
|
|
300 |
|
|
@Override
|
301 |
|
|
@Deprecated
|
302 |
|
|
public DescribeResponse describe(Session session, Identifier pid)
|
303 |
|
|
throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
304 |
|
|
NotFound {
|
305 |
9036
|
tao
|
String serviceFailure = "1030";
|
306 |
|
|
String notFound = "1020";
|
307 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
308 |
|
|
"No system metadata could be found for given PID: "+pid.getValue());
|
309 |
8810
|
leinfelder
|
return impl.describe(session, pid);
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
@Override
|
313 |
|
|
public InputStream get(Identifier pid) throws InvalidToken, NotAuthorized,
|
314 |
|
|
NotImplemented, ServiceFailure, NotFound, InsufficientResources {
|
315 |
9033
|
tao
|
String serviceFailure = "1030";
|
316 |
|
|
String notFound = "1020";
|
317 |
9036
|
tao
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
318 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
319 |
8810
|
leinfelder
|
return impl.get(null, pid);
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
@Override
|
323 |
|
|
@Deprecated
|
324 |
|
|
public InputStream get(Session session, Identifier pid) throws InvalidToken,
|
325 |
|
|
NotAuthorized, NotImplemented, ServiceFailure, NotFound,
|
326 |
|
|
InsufficientResources {
|
327 |
9033
|
tao
|
String serviceFailure = "1030";
|
328 |
|
|
String notFound = "1020";
|
329 |
9036
|
tao
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
330 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
331 |
8810
|
leinfelder
|
return impl.get(session, pid);
|
332 |
|
|
}
|
333 |
|
|
|
334 |
|
|
@Override
|
335 |
|
|
public Checksum getChecksum(Identifier pid, String algorithm)
|
336 |
|
|
throws InvalidRequest, InvalidToken, NotAuthorized, NotImplemented,
|
337 |
|
|
ServiceFailure, NotFound {
|
338 |
|
|
return impl.getChecksum(null, pid, algorithm);
|
339 |
|
|
}
|
340 |
|
|
|
341 |
|
|
@Override
|
342 |
|
|
@Deprecated
|
343 |
|
|
public Checksum getChecksum(Session session, Identifier pid, String algorithm)
|
344 |
|
|
throws InvalidRequest, InvalidToken, NotAuthorized, NotImplemented,
|
345 |
|
|
ServiceFailure, NotFound {
|
346 |
|
|
return impl.getChecksum(session, pid, algorithm);
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
@Override
|
350 |
|
|
public InputStream getReplica(Identifier pid) throws InvalidToken,
|
351 |
|
|
NotAuthorized, NotImplemented, ServiceFailure, NotFound,
|
352 |
|
|
InsufficientResources {
|
353 |
|
|
return impl.getReplica(null, pid);
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
@Override
|
357 |
|
|
@Deprecated
|
358 |
|
|
public InputStream getReplica(Session session, Identifier pid)
|
359 |
|
|
throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
360 |
|
|
NotFound, InsufficientResources {
|
361 |
9091
|
tao
|
return impl.getReplica(session, pid);
|
362 |
8810
|
leinfelder
|
}
|
363 |
|
|
|
364 |
|
|
@Override
|
365 |
|
|
public SystemMetadata getSystemMetadata(Identifier pid)
|
366 |
|
|
throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
367 |
|
|
NotFound {
|
368 |
8829
|
leinfelder
|
|
369 |
|
|
return this.getSystemMetadata(null, pid);
|
370 |
|
|
|
371 |
8810
|
leinfelder
|
}
|
372 |
|
|
|
373 |
|
|
@Override
|
374 |
|
|
@Deprecated
|
375 |
|
|
public SystemMetadata getSystemMetadata(Session session, Identifier pid)
|
376 |
|
|
throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
377 |
|
|
NotFound {
|
378 |
9037
|
tao
|
String serviceFailure = "1090";
|
379 |
|
|
String notFound = "1060";
|
380 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
381 |
|
|
"No system metadata could be found for given PID: "+pid.getValue());
|
382 |
8829
|
leinfelder
|
org.dataone.service.types.v2.SystemMetadata sysMeta = impl.getSystemMetadata(session, pid);
|
383 |
|
|
SystemMetadata retSysMeta = null;
|
384 |
|
|
try {
|
385 |
9304
|
tao
|
retSysMeta = TypeFactory.convertTypeFromType(sysMeta, SystemMetadata.class);
|
386 |
8829
|
leinfelder
|
} catch (Exception e) {
|
387 |
|
|
// report as service failure
|
388 |
|
|
ServiceFailure sf = new ServiceFailure("4801", e.getMessage());
|
389 |
|
|
sf.initCause(e);
|
390 |
|
|
throw sf;
|
391 |
|
|
}
|
392 |
|
|
return retSysMeta;
|
393 |
8810
|
leinfelder
|
}
|
394 |
|
|
|
395 |
|
|
@Override
|
396 |
|
|
public ObjectList listObjects(Date startTime, Date endTime,
|
397 |
|
|
ObjectFormatIdentifier objectFormatId, Boolean replicaStatus, Integer start,
|
398 |
|
|
Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
|
399 |
|
|
NotImplemented, ServiceFailure {
|
400 |
|
|
return this.listObjects(null, startTime, endTime, objectFormatId, replicaStatus, start, count);
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
@Override
|
404 |
|
|
@Deprecated
|
405 |
|
|
public ObjectList listObjects(Session session, Date startTime, Date endTime,
|
406 |
|
|
ObjectFormatIdentifier objectFormatId, Boolean replicaStatus, Integer start,
|
407 |
|
|
Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
|
408 |
|
|
NotImplemented, ServiceFailure {
|
409 |
|
|
return impl.listObjects(session, startTime, endTime, objectFormatId, null, replicaStatus, start, count);
|
410 |
|
|
}
|
411 |
|
|
|
412 |
|
|
@Override
|
413 |
|
|
public boolean synchronizationFailed(SynchronizationFailed syncFailed)
|
414 |
|
|
throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure {
|
415 |
|
|
return impl.synchronizationFailed(null, syncFailed);
|
416 |
|
|
}
|
417 |
|
|
|
418 |
|
|
@Override
|
419 |
|
|
@Deprecated
|
420 |
|
|
public boolean synchronizationFailed(Session session,
|
421 |
|
|
SynchronizationFailed syncFailed) throws InvalidToken, NotAuthorized,
|
422 |
|
|
NotImplemented, ServiceFailure {
|
423 |
|
|
return impl.synchronizationFailed(session, syncFailed);
|
424 |
|
|
}
|
425 |
|
|
|
426 |
|
|
@Override
|
427 |
|
|
public Node getCapabilities() throws NotImplemented, ServiceFailure {
|
428 |
|
|
org.dataone.service.types.v2.Node node = impl.getCapabilities();
|
429 |
|
|
Node retNode = null;
|
430 |
|
|
try {
|
431 |
9304
|
tao
|
retNode = TypeFactory.convertTypeFromType(node, Node.class);
|
432 |
8810
|
leinfelder
|
} catch (Exception e) {
|
433 |
|
|
// report as service failure
|
434 |
|
|
ServiceFailure sf = new ServiceFailure("4801", e.getMessage());
|
435 |
|
|
sf.initCause(e);
|
436 |
|
|
throw sf;
|
437 |
|
|
}
|
438 |
|
|
return retNode;
|
439 |
|
|
}
|
440 |
|
|
|
441 |
|
|
@Override
|
442 |
|
|
public Log getLogRecords(Date fromDate, Date toDate, Event event,
|
443 |
|
|
String pidFilter, Integer start, Integer count) throws InvalidRequest, InvalidToken,
|
444 |
|
|
NotAuthorized, NotImplemented, ServiceFailure {
|
445 |
|
|
return this.getLogRecords(null, fromDate, toDate, event, pidFilter, start, count);
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
@Override
|
449 |
|
|
@Deprecated
|
450 |
|
|
public Log getLogRecords(Session session, Date fromDate, Date toDate, Event event,
|
451 |
|
|
String pidFilter, Integer start, Integer count) throws InvalidRequest, InvalidToken,
|
452 |
|
|
NotAuthorized, NotImplemented, ServiceFailure {
|
453 |
9062
|
tao
|
Log retLog = new Log();
|
454 |
9063
|
tao
|
if(pidFilter != null && !pidFilter.trim().equals("")) {
|
455 |
9062
|
tao
|
String serviceFailure = "1490";
|
456 |
|
|
String notFound = "1020";
|
457 |
|
|
Identifier pid = new Identifier();
|
458 |
|
|
pid.setValue(pidFilter);
|
459 |
|
|
try {
|
460 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
461 |
|
|
"The given PID: "+pid.getValue()+" doesn't exist in this node");
|
462 |
|
|
} catch (NotFound e) {
|
463 |
|
|
//return 0 record since the pid doesn't exist
|
464 |
|
|
logMetacat.info(e.getMessage());
|
465 |
|
|
return retLog;
|
466 |
|
|
}
|
467 |
|
|
|
468 |
|
|
}
|
469 |
|
|
|
470 |
9057
|
tao
|
String eventValue = null;
|
471 |
|
|
if(event != null) {
|
472 |
|
|
eventValue = event.xmlValue();
|
473 |
|
|
}
|
474 |
|
|
org.dataone.service.types.v2.Log log = impl.getLogRecords(session, fromDate, toDate, eventValue, pidFilter, start, count);
|
475 |
9062
|
tao
|
|
476 |
8810
|
leinfelder
|
try {
|
477 |
9317
|
tao
|
retLog = TypeFactory.convertTypeFromType(log, Log.class);
|
478 |
|
|
//LogV2toV1Converter converter = new LogV2toV1Converter();
|
479 |
|
|
// retLog = converter.convert(log);
|
480 |
8810
|
leinfelder
|
} catch (Exception e) {
|
481 |
|
|
// report as service failure
|
482 |
|
|
ServiceFailure sf = new ServiceFailure("1490", e.getMessage());
|
483 |
|
|
sf.initCause(e);
|
484 |
|
|
throw sf;
|
485 |
|
|
}
|
486 |
|
|
return retLog;
|
487 |
|
|
}
|
488 |
|
|
|
489 |
|
|
@Override
|
490 |
|
|
public Date ping() throws NotImplemented, ServiceFailure,
|
491 |
|
|
InsufficientResources {
|
492 |
|
|
return impl.ping();
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
@Override
|
496 |
|
|
public boolean isAuthorized(Identifier pid, Permission permission)
|
497 |
|
|
throws ServiceFailure, InvalidRequest, InvalidToken, NotFound,
|
498 |
|
|
NotAuthorized, NotImplemented {
|
499 |
9051
|
tao
|
String serviceFailure = "1760";
|
500 |
|
|
String notFound = "1800";
|
501 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
502 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
503 |
8810
|
leinfelder
|
return impl.isAuthorized(null, pid, permission);
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
@Override
|
507 |
|
|
@Deprecated
|
508 |
|
|
public boolean isAuthorized(Session session, Identifier pid, Permission permission)
|
509 |
|
|
throws ServiceFailure, InvalidRequest, InvalidToken, NotFound,
|
510 |
|
|
NotAuthorized, NotImplemented {
|
511 |
9051
|
tao
|
String serviceFailure = "1760";
|
512 |
|
|
String notFound = "1800";
|
513 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
514 |
|
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
515 |
8810
|
leinfelder
|
return impl.isAuthorized(session, pid, permission);
|
516 |
|
|
}
|
517 |
|
|
|
518 |
|
|
@Override
|
519 |
|
|
public boolean systemMetadataChanged(Identifier pid, long serialVersion, Date dateSysMetaLastModified)
|
520 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
521 |
|
|
InvalidRequest {
|
522 |
9051
|
tao
|
String serviceFailure = "1333";
|
523 |
|
|
String notFound = "1800";
|
524 |
|
|
try {
|
525 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata of the object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
526 |
|
|
"The system metadata of the object specified by "+pid.getValue()+" does not exist at this node.");
|
527 |
|
|
} catch (NotFound e) {
|
528 |
|
|
throw new ServiceFailure(serviceFailure, e.getMessage());
|
529 |
|
|
}
|
530 |
9340
|
tao
|
boolean needCheckAuthoriativeNode = false;
|
531 |
|
|
return impl.systemMetadataChanged(needCheckAuthoriativeNode, null, pid, serialVersion, dateSysMetaLastModified);
|
532 |
8810
|
leinfelder
|
|
533 |
|
|
}
|
534 |
|
|
|
535 |
|
|
@Override
|
536 |
|
|
@Deprecated
|
537 |
|
|
public boolean systemMetadataChanged(Session session, Identifier pid,
|
538 |
|
|
long serialVersion, Date dateSysMetaLastModified) throws InvalidToken, ServiceFailure,
|
539 |
|
|
NotAuthorized, NotImplemented, InvalidRequest {
|
540 |
9051
|
tao
|
String serviceFailure = "1333";
|
541 |
|
|
String notFound = "1800";
|
542 |
|
|
try {
|
543 |
|
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata of the object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
544 |
|
|
"The system metadata of the object specified by "+pid.getValue()+" does not exist at this node.");
|
545 |
|
|
} catch (NotFound e) {
|
546 |
|
|
throw new ServiceFailure(serviceFailure, e.getMessage());
|
547 |
|
|
}
|
548 |
9340
|
tao
|
boolean needCheckAuthoriativeNode = false;
|
549 |
|
|
return impl.systemMetadataChanged(needCheckAuthoriativeNode,session, pid, serialVersion, dateSysMetaLastModified);
|
550 |
8810
|
leinfelder
|
}
|
551 |
|
|
|
552 |
|
|
// methods not defined in v1, but implemented in metacat pre-v2 release
|
553 |
|
|
|
554 |
|
|
public Identifier publish(Session session, Identifier originalIdentifier)
|
555 |
9389
|
tao
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented, InvalidRequest, NotFound, IdentifierNotUnique, UnsupportedType, InsufficientResources, InvalidSystemMetadata, IOException {
|
556 |
9077
|
tao
|
String serviceFailure = "1030";
|
557 |
|
|
String notFound = "1020";
|
558 |
|
|
impl.checkV1SystemMetaPidExist(originalIdentifier, serviceFailure, "The system metadata of the object specified by "+originalIdentifier.getValue()+" couldn't be identified if it exists", notFound,
|
559 |
|
|
"The system metadata of the object specified by "+originalIdentifier.getValue()+" does not exist at this node.");
|
560 |
8810
|
leinfelder
|
return impl.publish(session, originalIdentifier);
|
561 |
|
|
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
public InputStream view(Session session, String format, Identifier pid)
|
565 |
|
|
throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest,
|
566 |
|
|
NotImplemented, NotFound {
|
567 |
9076
|
tao
|
String serviceFailure = "2831";
|
568 |
|
|
String notFound = "2835";
|
569 |
9077
|
tao
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata of the object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
570 |
9076
|
tao
|
"The system metadata of the object specified by "+pid.getValue()+" does not exist at this node.");
|
571 |
9077
|
tao
|
|
572 |
8810
|
leinfelder
|
return impl.view(session, format, pid);
|
573 |
|
|
}
|
574 |
|
|
|
575 |
|
|
public InputStream getPackage(Session session, ObjectFormatIdentifier formatId,
|
576 |
|
|
Identifier pid) throws InvalidToken, ServiceFailure,
|
577 |
|
|
NotAuthorized, InvalidRequest, NotImplemented, NotFound {
|
578 |
9076
|
tao
|
String serviceFailure = "2871";
|
579 |
|
|
String notFound = "2875";
|
580 |
9077
|
tao
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata of the object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
581 |
9076
|
tao
|
"The system metadata of the object specified by "+pid.getValue()+" does not exist at this node.");
|
582 |
9077
|
tao
|
|
583 |
8810
|
leinfelder
|
return impl.getPackage(session, formatId, pid);
|
584 |
|
|
}
|
585 |
|
|
|
586 |
|
|
|
587 |
|
|
|
588 |
|
|
|
589 |
|
|
}
|