Revision 5657
Added by berkley about 14 years ago
test/edu/ucsb/nceas/metacat/dataone/CrudServiceTest.java | ||
---|---|---|
93 | 93 |
public static Test suite() |
94 | 94 |
{ |
95 | 95 |
TestSuite suite = new TestSuite(); |
96 |
suite.addTest(new CrudServiceTest("initialize")); |
|
96 |
/*suite.addTest(new CrudServiceTest("initialize"));
|
|
97 | 97 |
suite.addTest(new CrudServiceTest("testSingletonAccessor")); |
98 | 98 |
suite.addTest(new CrudServiceTest("testCreateAndGet")); |
99 | 99 |
suite.addTest(new CrudServiceTest("testGetSystemMetadata")); |
... | ... | |
106 | 106 |
suite.addTest(new CrudServiceTest("testPublicAccess")); |
107 | 107 |
suite.addTest(new CrudServiceTest("testFailedCreate")); |
108 | 108 |
suite.addTest(new CrudServiceTest("testChecksum")); |
109 |
suite.addTest(new CrudServiceTest("testDescribe")); |
|
109 |
suite.addTest(new CrudServiceTest("testDescribe"));*/
|
|
110 | 110 |
suite.addTest(new CrudServiceTest("testDelete")); |
111 | 111 |
return suite; |
112 | 112 |
} |
... | ... | |
131 | 131 |
//but because the data is output in a 2nd thread, the |
132 | 132 |
//exception does not get caught here. See |
133 | 133 |
//https://redmine.dataone.org/issues/1079 |
134 |
cs.get(token, id); |
|
134 |
//cs.get(token, id);
|
|
135 | 135 |
} |
136 | 136 |
catch(Exception e) |
137 | 137 |
{ |
src/loaddtdschema-oracle.sql | ||
---|---|---|
51 | 51 |
VALUES ('Schema', '/schema/RegistryService/RegistryEntryType.xsd', '/schema/RegistryService/RegistryEntryType.xsd'); |
52 | 52 |
|
53 | 53 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
54 |
VALUES ('Schema', 'http://dataone.org/service/types/SystemMetadata/0.5', '/schema/D1_SCHEMA_0_5/systemmetadata.xsd'); |
|
55 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
|
56 |
VALUES ('Schema', 'http://dataone.org/service/types/common/0.5', '/schema/D1_SCHEMA_0_5/common.xsd'); |
|
54 |
VALUES ('Schema', 'http://dataone.org/service/types/0.5.1', '/schema/D1_SCHEMA_0_5_1/dataoneTypes.xsd'); |
|
57 | 55 |
|
58 | 56 |
INSERT INTO db_version (version, status, date_created) |
59 | 57 |
VALUES ('1.10.0',1,CURRENT_DATE); |
src/upgrade-db-to-1.10.0-postgres.sql | ||
---|---|---|
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
22 |
VALUES ('Schema', 'http://dataone.org/service/types/SystemMetadata/0.5', '/schema/D1_SCHEMA_0_5/systemmetadata.xsd'); |
|
23 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
|
24 |
VALUES ('Schema', 'http://dataone.org/service/types/common/0.5', '/schema/D1_SCHEMA_0_5/common.xsd'); |
|
22 |
VALUES ('Schema', 'http://dataone.org/service/types/0.5.1', '/schema/D1_SCHEMA_0_5_1/dataoneTypes.xsd'); |
|
25 | 23 |
|
26 | 24 |
/* |
27 | 25 |
* update the database version |
src/loaddtdschema-postgres.sql | ||
---|---|---|
51 | 51 |
VALUES ('Schema', 'http://ecoinformatics.org/registryentry-1.0.0', '/schema/RegistryService/RegistryEntryType.xsd'); |
52 | 52 |
|
53 | 53 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
54 |
VALUES ('Schema', 'http://dataone.org/service/types/SystemMetadata/0.5', '/schema/D1_SCHEMA_0_5/systemmetadata.xsd'); |
|
55 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
|
56 |
VALUES ('Schema', 'http://dataone.org/service/types/common/0.5', '/schema/D1_SCHEMA_0_5/common.xsd'); |
|
54 |
VALUES ('Schema', 'http://dataone.org/service/types/0.5.1', '/schema/D1_SCHEMA_0_5_1/dataoneTypes.xsd'); |
|
57 | 55 |
|
58 | 56 |
INSERT INTO db_version (version, status, date_created) |
59 | 57 |
VALUES ('1.10.0',1,CURRENT_DATE); |
src/upgrade-db-to-1.10.0-oracle.sql | ||
---|---|---|
17 | 17 |
* Register the DataONE schemas |
18 | 18 |
*/ |
19 | 19 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
20 |
VALUES ('Schema', 'http://dataone.org/service/types/SystemMetadata/0.5', '/schema/D1_SCHEMA_0_5/systemmetadata.xsd'); |
|
21 |
INSERT INTO xml_catalog (entry_type, public_id, system_id) |
|
22 |
VALUES ('Schema', 'http://dataone.org/service/types/common/0.5', '/schema/D1_SCHEMA_0_5/common.xsd'); |
|
20 |
VALUES ('Schema', 'http://dataone.org/service/types/0.5.1', '/schema/D1_SCHEMA_0_5_1/dataoneTypes.xsd'); |
|
23 | 21 |
|
24 | 22 |
/* |
25 | 23 |
* update the database version |
src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java | ||
---|---|---|
87 | 87 |
* the specified <doc-id> in the resource path. For authenticated Get service, a session id must be provided |
88 | 88 |
* in the query string. <br/><br/> |
89 | 89 |
* |
90 |
* <b>REST URL:</b> <code>GET, [context-root]/object/[doc-id]?sessionid=[sessionid] </code><br/>
|
|
90 |
* <b>REST URL:</b> <code>GET, [context-root]/object/[doc-id]?sessionid=[sessionid] </code><br/>
|
|
91 | 91 |
* <b>Returns:</b> data file <br/><br/> |
92 | 92 |
* </li> |
93 | 93 |
* |
... | ... | |
99 | 99 |
* a session id must be provided in the query string. See Earthgrid (a.k.a. Ecogrid) project for XSD files of |
100 | 100 |
* query and resultset documents<br/><br/> |
101 | 101 |
* |
102 |
* <b>REST URL:</b> <code>POST, [context-root]/object?sessionid=[sessionid]</code> <br/>
|
|
102 |
* <b>REST URL:</b> <code>POST, [context-root]/object?sessionid=[sessionid]</code> <br/>
|
|
103 | 103 |
* <b>POST Data:</b> Earthgrid query document , Content-type: <code>text/xml</code><br/> |
104 | 104 |
* <b>Returns:</b> Earthgrid resultset document<br/><br/> |
105 | 105 |
* |
... | ... | |
125 | 125 |
* Receives session Id parameters in querystring and returns xml message, calls |
126 | 126 |
* MetacatHandler's handleLogoutAction function<br/><br/> |
127 | 127 |
* |
128 |
* <b>REST URL:</b> <code>GET, [context-root]/session?op=logout&sessionid=[sessionid]</code> <br/>
|
|
128 |
* <b>REST URL:</b> <code>GET, [context-root]/session?op=logout&sessionid=[sessionid]</code> <br/>
|
|
129 | 129 |
* <b>Returns:</b> message in XML format<br/><br/> |
130 | 130 |
* </li> |
131 | 131 |
* </ul> |
... | ... | |
134 | 134 |
* <h3>EarthGrid Put Service</h3> |
135 | 135 |
* |
136 | 136 |
* <ul> |
137 |
* <li><h3>Update/Insert: </h3>
|
|
137 |
* <li><h3>Update/Insert: </h3>
|
|
138 | 138 |
* <br/> |
139 |
* <b>REST URL:</b> <code>PUT, [context-root]/object/[doc-id]?op={update|insert}&sessionid=[sessionid]</code> <br/>
|
|
139 |
* <b>REST URL:</b> <code>PUT, [context-root]/object/[doc-id]?op={update|insert}&sessionid=[sessionid]</code> <br/>
|
|
140 | 140 |
* <b>POST Data:</b> document object, Content-type: <code>text/xml</code><br/> |
141 | 141 |
* <b>Returns:</b> message in XML format<br/><br/> |
142 | 142 |
* </li> |
143 | 143 |
* |
144 |
* <li><h3>Delete: </h3>
|
|
144 |
* <li><h3>Delete: </h3>
|
|
145 | 145 |
* <br/> |
146 |
* <b>REST URL:</b> <code>DELETE, [context-root]/object/[doc-id]?sessionid=[sessionid]</code> <br/>
|
|
146 |
* <b>REST URL:</b> <code>DELETE, [context-root]/object/[doc-id]?sessionid=[sessionid]</code> <br/>
|
|
147 | 147 |
* <b>Returns:</b> message in XML format<br/><br/> |
148 | 148 |
* </li> |
149 | 149 |
|
... | ... | |
154 | 154 |
* <h3>EarthGrid Identifier Service</h3><br/> |
155 | 155 |
* |
156 | 156 |
* <ul> |
157 |
* <li><h3>isRegistered: </h3> <br/>
|
|
158 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier/[doc-id]?op=isregistered</code> <br/>
|
|
157 |
* <li><h3>isRegistered: </h3> <br/>
|
|
158 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier/[doc-id]?op=isregistered</code> <br/>
|
|
159 | 159 |
* <b>Returns:</b> message in XML format<br/><br/> |
160 | 160 |
* </li> |
161 | 161 |
|
162 |
* <li><h3>getAllDocIds:</h3> <br/>
|
|
163 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier?op=getalldocids</code> <br/>
|
|
162 |
* <li><h3>getAllDocIds:</h3> <br/>
|
|
163 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier?op=getalldocids</code> <br/>
|
|
164 | 164 |
* <b>Returns:</b> document id list in XML format<br/><br/> |
165 | 165 |
* </li> |
166 | 166 |
* |
167 | 167 |
* <li><h3>addLSID Function:</h3> |
168 |
* Metacat does not support this function <br/>
|
|
169 |
* <b>REST URL:</b> <code>PUT, [context-root]/identifier/[doc-id]</code> <br/>
|
|
168 |
* Metacat does not support this function <br/>
|
|
169 |
* <b>REST URL:</b> <code>PUT, [context-root]/identifier/[doc-id]</code> <br/>
|
|
170 | 170 |
* <b>Returns:</b> error message in XML format<br/><br/> |
171 | 171 |
* </li> |
172 | 172 |
* |
173 |
* <li><h3>getNextRevision:</h3> <br/>
|
|
174 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier/[doc-id]?op=getnextrevision</code> <br/>
|
|
173 |
* <li><h3>getNextRevision:</h3> <br/>
|
|
174 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier/[doc-id]?op=getnextrevision</code> <br/>
|
|
175 | 175 |
* <b>Returns:</b> message in XML format<br/><br/> |
176 | 176 |
* </li> |
177 | 177 |
* |
178 |
* <li><h3>getNextObject:</h3> <br/>
|
|
179 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier?op=getnextobject&scope=[scope]</code> <br/>
|
|
178 |
* <li><h3>getNextObject:</h3> <br/>
|
|
179 |
* <b>REST URL:</b> <code>GET, [context-root]/identifier?op=getnextobject&scope=[scope]</code> <br/>
|
|
180 | 180 |
* <b>Returns:</b> message in XML format<br/><br/> |
181 | 181 |
* </li> |
182 | 182 |
* |
... | ... | |
260 | 260 |
loadSessionData(); |
261 | 261 |
|
262 | 262 |
if (resource != null) { |
263 |
resource = request.getServletPath().substring(1);
|
|
263 |
resource = request.getServletPath().substring(1);
|
|
264 | 264 |
|
265 |
params = new Hashtable<String, String[]>();
|
|
266 |
initParams();
|
|
265 |
params = new Hashtable<String, String[]>();
|
|
266 |
initParams();
|
|
267 | 267 |
|
268 |
Timer timer = new Timer();
|
|
269 |
handler = new MetacatHandler(timer);
|
|
268 |
Timer timer = new Timer();
|
|
269 |
handler = new MetacatHandler(timer);
|
|
270 | 270 |
|
271 |
if (resource.equals(RESOURCE_SESSION) &&
|
|
272 |
httpVerb == POST &&
|
|
273 |
params.get(FUNCTION_KEYWORD) != null) {
|
|
274 |
//System.out.println("function_keyword: " + params.get(FUNCTION_KEYWORD)[0]);
|
|
275 |
if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGIN)) {
|
|
276 |
login();
|
|
277 |
status = true;
|
|
278 |
} else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGOUT)) {
|
|
279 |
logout();
|
|
280 |
status = true;
|
|
281 |
} else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_SET_ACCESS)) {
|
|
282 |
setaccess();
|
|
283 |
status = true;
|
|
284 |
//System.out.println("done setting access");
|
|
285 |
}
|
|
286 |
} else if (resource.equals(RESOURCE_META)) {
|
|
287 |
if(params != null && params.get(FUNCTION_KEYWORD) != null &&
|
|
288 |
params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA))
|
|
289 |
{ //generate system metadata for any object that is
|
|
290 |
//a) not system metadata itself
|
|
291 |
//b) does not already have a system metadata id in the systemmetadata table
|
|
292 |
//c) not a BIN object (data)
|
|
293 |
//TODO: check if we need this anymore. Might be superceded
|
|
294 |
//by MetacatPopulator
|
|
295 |
generateMissingSystemMetadata();
|
|
296 |
status = true;
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
String objectId = request.getPathInfo();
|
|
301 |
if (objectId != null && objectId.length() > 1)
|
|
302 |
{
|
|
303 |
objectId = request.getPathInfo().substring(1);
|
|
304 |
}
|
|
305 |
getSystemMetadataObject(objectId);
|
|
306 |
status = true;
|
|
307 |
}
|
|
271 |
if (resource.equals(RESOURCE_SESSION) &&
|
|
272 |
httpVerb == POST &&
|
|
273 |
params.get(FUNCTION_KEYWORD) != null) {
|
|
274 |
//System.out.println("function_keyword: " + params.get(FUNCTION_KEYWORD)[0]);
|
|
275 |
if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGIN)) {
|
|
276 |
login();
|
|
277 |
status = true;
|
|
278 |
} else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_LOGOUT)) {
|
|
279 |
logout();
|
|
280 |
status = true;
|
|
281 |
} else if (params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_SET_ACCESS)) {
|
|
282 |
setaccess();
|
|
283 |
status = true;
|
|
284 |
//System.out.println("done setting access");
|
|
285 |
}
|
|
286 |
} else if (resource.equals(RESOURCE_META)) {
|
|
287 |
if(params != null && params.get(FUNCTION_KEYWORD) != null &&
|
|
288 |
params.get(FUNCTION_KEYWORD)[0].equals(FUNCTION_NAME_GENERATE_MISSING_SYSTEM_METADATA))
|
|
289 |
{ //generate system metadata for any object that is
|
|
290 |
//a) not system metadata itself
|
|
291 |
//b) does not already have a system metadata id in the systemmetadata table
|
|
292 |
//c) not a BIN object (data)
|
|
293 |
//TODO: check if we need this anymore. Might be superceded
|
|
294 |
//by MetacatPopulator
|
|
295 |
generateMissingSystemMetadata();
|
|
296 |
status = true;
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
String objectId = request.getPathInfo();
|
|
301 |
if (objectId != null && objectId.length() > 1)
|
|
302 |
{
|
|
303 |
objectId = request.getPathInfo().substring(1);
|
|
304 |
}
|
|
305 |
getSystemMetadataObject(objectId);
|
|
306 |
status = true;
|
|
307 |
}
|
|
308 | 308 |
|
309 |
} else if (resource.equals(RESOURCE_OBJECTS)) {
|
|
310 |
logMetacat.debug("D1 Rest: Starting resource processing...");
|
|
311 |
loadSessionData();
|
|
309 |
} else if (resource.equals(RESOURCE_OBJECTS)) {
|
|
310 |
logMetacat.debug("D1 Rest: Starting resource processing...");
|
|
311 |
loadSessionData();
|
|
312 | 312 |
|
313 |
String objectId = request.getPathInfo();
|
|
314 |
if (objectId != null && objectId.length() > 1)
|
|
315 |
{
|
|
316 |
objectId = request.getPathInfo().substring(1);
|
|
317 |
}
|
|
318 |
else
|
|
319 |
{
|
|
320 |
objectId = null;
|
|
321 |
}
|
|
313 |
String objectId = request.getPathInfo();
|
|
314 |
if (objectId != null && objectId.length() > 1)
|
|
315 |
{
|
|
316 |
objectId = request.getPathInfo().substring(1);
|
|
317 |
}
|
|
318 |
else
|
|
319 |
{
|
|
320 |
objectId = null;
|
|
321 |
}
|
|
322 | 322 |
|
323 |
logMetacat.debug("verb:" + httpVerb);
|
|
323 |
logMetacat.debug("verb:" + httpVerb);
|
|
324 | 324 |
|
325 |
if (httpVerb == GET) {
|
|
326 |
getObject(objectId);
|
|
327 |
status = true;
|
|
328 |
} else if (httpVerb == POST) {
|
|
329 |
putObject(objectId, FUNCTION_NAME_INSERT);
|
|
330 |
status = true;
|
|
331 |
} else if (httpVerb == PUT) {
|
|
332 |
putObject(objectId, FUNCTION_NAME_UPDATE);
|
|
333 |
status = true;
|
|
334 |
} else if (httpVerb == DELETE) {
|
|
335 |
deleteObject(objectId);
|
|
336 |
status = true;
|
|
337 |
} else if (httpVerb == HEAD) {
|
|
338 |
describeObject(objectId);
|
|
339 |
status = true;
|
|
340 |
}
|
|
341 |
|
|
325 |
if (httpVerb == GET) {
|
|
326 |
getObject(objectId);
|
|
327 |
status = true;
|
|
328 |
} else if (httpVerb == POST) {
|
|
329 |
putObject(objectId, FUNCTION_NAME_INSERT);
|
|
330 |
status = true;
|
|
331 |
} else if (httpVerb == PUT) {
|
|
332 |
putObject(objectId, FUNCTION_NAME_UPDATE);
|
|
333 |
status = true;
|
|
334 |
} else if (httpVerb == DELETE) {
|
|
335 |
deleteObject(objectId);
|
|
336 |
status = true;
|
|
337 |
} else if (httpVerb == HEAD) {
|
|
338 |
describeObject(objectId);
|
|
339 |
status = true;
|
|
340 |
}
|
|
341 |
|
|
342 | 342 |
|
343 |
} else if (resource.equals(RESOURCE_IDENTIFIER)) {
|
|
343 |
} else if (resource.equals(RESOURCE_IDENTIFIER)) {
|
|
344 | 344 |
|
345 |
String identifierId = request.getPathInfo();
|
|
346 |
if (identifierId != null && identifierId.length() > 1)
|
|
347 |
identifierId = request.getPathInfo().substring(1); //trim the slash
|
|
345 |
String identifierId = request.getPathInfo();
|
|
346 |
if (identifierId != null && identifierId.length() > 1)
|
|
347 |
identifierId = request.getPathInfo().substring(1); //trim the slash
|
|
348 | 348 |
|
349 |
if (httpVerb == GET) {
|
|
350 |
String op = params.get(FUNCTION_KEYWORD)[0];
|
|
351 |
if (op.equals(FUNCTION_NAME_ISREGISTERED)) {
|
|
352 |
isRegistered(identifierId);
|
|
353 |
status = true;
|
|
354 |
} else if (op.equals(FUNCTION_NAME_GETALLDOCS)) {
|
|
355 |
getAllDocIds();
|
|
356 |
status = true;
|
|
357 |
} else if (op.equals(FUNCTION_NAME_GETNEXTREV)) {
|
|
358 |
getNextRevision(identifierId);
|
|
359 |
status = true;
|
|
360 |
} else if (op.equals(FUNCTION_NAME_GETNEXTOBJ)) {
|
|
361 |
getNextObject();
|
|
362 |
status = true;
|
|
363 |
}
|
|
349 |
if (httpVerb == GET) {
|
|
350 |
String op = params.get(FUNCTION_KEYWORD)[0];
|
|
351 |
if (op.equals(FUNCTION_NAME_ISREGISTERED)) {
|
|
352 |
isRegistered(identifierId);
|
|
353 |
status = true;
|
|
354 |
} else if (op.equals(FUNCTION_NAME_GETALLDOCS)) {
|
|
355 |
getAllDocIds();
|
|
356 |
status = true;
|
|
357 |
} else if (op.equals(FUNCTION_NAME_GETNEXTREV)) {
|
|
358 |
getNextRevision(identifierId);
|
|
359 |
status = true;
|
|
360 |
} else if (op.equals(FUNCTION_NAME_GETNEXTOBJ)) {
|
|
361 |
getNextObject();
|
|
362 |
status = true;
|
|
363 |
}
|
|
364 | 364 |
|
365 |
} else if (httpVerb == PUT) {
|
|
366 |
//Earthgrid API > Identifier Service > addLSID Function
|
|
367 |
response.setStatus(501);
|
|
368 |
printError(
|
|
369 |
"This method is not supported by metacat. To "
|
|
370 |
+ "add a new LSID, add a document to metacat.",
|
|
371 |
response);
|
|
372 |
status = true;
|
|
373 |
}
|
|
365 |
} else if (httpVerb == PUT) {
|
|
366 |
//Earthgrid API > Identifier Service > addLSID Function
|
|
367 |
response.setStatus(501);
|
|
368 |
printError(
|
|
369 |
"This method is not supported by metacat. To "
|
|
370 |
+ "add a new LSID, add a document to metacat.",
|
|
371 |
response);
|
|
372 |
status = true;
|
|
373 |
}
|
|
374 | 374 |
|
375 |
} else if (resource.equals(RESOURCE_LOG)) {
|
|
376 |
//handle log events
|
|
377 |
if(httpVerb == GET)
|
|
378 |
{
|
|
379 |
getLog();
|
|
380 |
status = true;
|
|
381 |
}
|
|
382 |
else
|
|
383 |
{
|
|
384 |
//change to D1 spec for specifying which http methods are allowed for a resource
|
|
385 |
response.setStatus(501);
|
|
386 |
printError("POST, PUT, DELETE is not supported for logs.", response);
|
|
387 |
status = true;
|
|
388 |
}
|
|
375 |
} else if (resource.equals(RESOURCE_LOG)) {
|
|
376 |
//handle log events
|
|
377 |
if(httpVerb == GET)
|
|
378 |
{
|
|
379 |
getLog();
|
|
380 |
status = true;
|
|
381 |
}
|
|
382 |
else
|
|
383 |
{
|
|
384 |
//change to D1 spec for specifying which http methods are allowed for a resource
|
|
385 |
response.setStatus(501);
|
|
386 |
printError("POST, PUT, DELETE is not supported for logs.", response);
|
|
387 |
status = true;
|
|
388 |
}
|
|
389 | 389 |
|
390 |
} else if(resource.equals(RESOURCE_CHECKSUM)) {
|
|
391 |
//handle checksum requests
|
|
392 |
System.out.println("Handling getChecksum request");
|
|
393 |
if(httpVerb == GET)
|
|
394 |
{
|
|
395 |
String guid = null;
|
|
396 |
String checksumAlgorithm = "MD5";
|
|
397 |
|
|
398 |
try
|
|
399 |
{
|
|
400 |
guid = params.get("id")[0];
|
|
401 |
}
|
|
402 |
catch(Exception e)
|
|
403 |
{
|
|
404 |
throw new InvalidRequest("1402", "Incorrect parameters passed to getChecksum");
|
|
405 |
}
|
|
406 |
|
|
407 |
Identifier guidid = new Identifier();
|
|
408 |
guidid.setValue(guid);
|
|
409 |
AuthToken token = new AuthToken(sessionId);
|
|
410 |
try
|
|
411 |
{
|
|
412 |
checksumAlgorithm = params.get("checksumAlgorithm")[0];
|
|
413 |
}
|
|
414 |
catch(Exception e)
|
|
415 |
{
|
|
416 |
//do nothing. default to MD5
|
|
417 |
}
|
|
418 |
System.out.println("getting checksum for object " + guid +
|
|
419 |
" with algorithm " + checksumAlgorithm);
|
|
420 |
try
|
|
421 |
{
|
|
422 |
Checksum c = CrudService.getInstance().getChecksum(token, guidid, checksumAlgorithm);
|
|
423 |
System.out.println("got checksum " + c.getValue());
|
|
424 |
response.setStatus(200);
|
|
425 |
System.out.println("serializing response");
|
|
426 |
serializeServiceType(Checksum.class, c, response.getOutputStream());
|
|
427 |
System.out.println("done serializing response.");
|
|
428 |
}
|
|
429 |
catch(NotAuthorized na)
|
|
430 |
{
|
|
431 |
na.setDetail_code("1400");
|
|
432 |
serializeException(na, response.getOutputStream());
|
|
433 |
}
|
|
434 |
catch(NotFound nf)
|
|
435 |
{
|
|
436 |
nf.setDetail_code("1420");
|
|
437 |
serializeException(nf, response.getOutputStream());
|
|
438 |
}
|
|
439 |
catch(InvalidRequest ir)
|
|
440 |
{
|
|
441 |
ir.setDetail_code("1402");
|
|
442 |
serializeException(ir, response.getOutputStream());
|
|
443 |
}
|
|
444 |
catch(ServiceFailure sf)
|
|
445 |
{
|
|
446 |
sf.setDetail_code("1410");
|
|
447 |
serializeException(sf, response.getOutputStream());
|
|
448 |
}
|
|
449 |
catch(InvalidToken it)
|
|
450 |
{
|
|
451 |
it.setDetail_code("1430");
|
|
452 |
serializeException(it, response.getOutputStream());
|
|
453 |
}
|
|
454 |
status = true;
|
|
455 |
}
|
|
456 |
}
|
|
457 |
|
|
458 |
if (!status)
|
|
459 |
{
|
|
460 |
response.setStatus(400);
|
|
461 |
printError("Incorrect parameters!", response);
|
|
462 |
}
|
|
390 |
} else if(resource.equals(RESOURCE_CHECKSUM)) {
|
|
391 |
//handle checksum requests
|
|
392 |
System.out.println("Handling getChecksum request");
|
|
393 |
if(httpVerb == GET)
|
|
394 |
{
|
|
395 |
String guid = null;
|
|
396 |
String checksumAlgorithm = "MD5";
|
|
397 |
|
|
398 |
try
|
|
399 |
{
|
|
400 |
guid = params.get("id")[0];
|
|
401 |
}
|
|
402 |
catch(Exception e)
|
|
403 |
{
|
|
404 |
throw new InvalidRequest("1402", "Incorrect parameters passed to getChecksum");
|
|
405 |
}
|
|
406 |
|
|
407 |
Identifier guidid = new Identifier();
|
|
408 |
guidid.setValue(guid);
|
|
409 |
AuthToken token = new AuthToken(sessionId);
|
|
410 |
try
|
|
411 |
{
|
|
412 |
checksumAlgorithm = params.get("checksumAlgorithm")[0];
|
|
413 |
}
|
|
414 |
catch(Exception e)
|
|
415 |
{
|
|
416 |
//do nothing. default to MD5
|
|
417 |
}
|
|
418 |
System.out.println("getting checksum for object " + guid +
|
|
419 |
" with algorithm " + checksumAlgorithm);
|
|
420 |
try
|
|
421 |
{
|
|
422 |
Checksum c = CrudService.getInstance().getChecksum(token, guidid, checksumAlgorithm);
|
|
423 |
System.out.println("got checksum " + c.getValue());
|
|
424 |
response.setStatus(200);
|
|
425 |
System.out.println("serializing response");
|
|
426 |
serializeServiceType(Checksum.class, c, response.getOutputStream());
|
|
427 |
System.out.println("done serializing response.");
|
|
428 |
}
|
|
429 |
catch(NotAuthorized na)
|
|
430 |
{
|
|
431 |
na.setDetail_code("1400");
|
|
432 |
serializeException(na, response.getOutputStream());
|
|
433 |
}
|
|
434 |
catch(NotFound nf)
|
|
435 |
{
|
|
436 |
nf.setDetail_code("1420");
|
|
437 |
serializeException(nf, response.getOutputStream());
|
|
438 |
}
|
|
439 |
catch(InvalidRequest ir)
|
|
440 |
{
|
|
441 |
ir.setDetail_code("1402");
|
|
442 |
serializeException(ir, response.getOutputStream());
|
|
443 |
}
|
|
444 |
catch(ServiceFailure sf)
|
|
445 |
{
|
|
446 |
sf.setDetail_code("1410");
|
|
447 |
serializeException(sf, response.getOutputStream());
|
|
448 |
}
|
|
449 |
catch(InvalidToken it)
|
|
450 |
{
|
|
451 |
it.setDetail_code("1430");
|
|
452 |
serializeException(it, response.getOutputStream());
|
|
453 |
}
|
|
454 |
status = true;
|
|
455 |
}
|
|
456 |
}
|
|
457 |
|
|
458 |
if (!status)
|
|
459 |
{
|
|
460 |
response.setStatus(400);
|
|
461 |
printError("Incorrect parameters!", response);
|
|
462 |
}
|
|
463 | 463 |
} else { |
464 | 464 |
response.setStatus(400); |
465 |
printError("Incorrect resource!", response);
|
|
465 |
printError("Incorrect resource!", response);
|
|
466 | 466 |
} |
467 | 467 |
} catch (Exception e) { |
468 |
logMetacat.error(e.getMessage());
|
|
469 |
e.printStackTrace();
|
|
468 |
logMetacat.error(e.getMessage());
|
|
469 |
e.printStackTrace();
|
|
470 | 470 |
} |
471 | 471 |
} |
472 | 472 |
|
... | ... | |
1088 | 1088 |
StringBuffer result = metacat.createResultDocument(xmlquery, |
1089 | 1089 |
metacatQuery, out, username, groupNames, useXMLIndex); |
1090 | 1090 |
|
1091 |
// create result set transfer
|
|
1091 |
// create result set transfer
|
|
1092 | 1092 |
String saxparser = PropertyService.getProperty("xml.saxparser"); |
1093 | 1093 |
MetacatResultsetParser metacatResultsetParser = new MetacatResultsetParser( |
1094 | 1094 |
new StringReader(result.toString()), saxparser, queryType |
... | ... | |
1295 | 1295 |
{ //we're writing, but we found the boundary in this chunk |
1296 | 1296 |
|
1297 | 1297 |
writeString = s.substring(0, result[0]); |
1298 |
System.out.println("writing1: " + writeString); |
|
1298 |
//System.out.println("writing1: " + writeString);
|
|
1299 | 1299 |
fos.write(writeString.getBytes()); |
1300 | 1300 |
//we're done. break and return; |
1301 | 1301 |
return s.substring(result[0] + result[1], s.length()); |
... | ... | |
1320 | 1320 |
//searchString is not in s |
1321 | 1321 |
if(searchForBoundary) |
1322 | 1322 |
{ |
1323 |
System.out.println("writing2: " + s); |
|
1323 |
//System.out.println("writing2: " + s);
|
|
1324 | 1324 |
fos.write(s.getBytes()); |
1325 | 1325 |
} |
1326 | 1326 |
numread = is.read(b, 0, 1024); |
... | ... | |
1501 | 1501 |
} |
1502 | 1502 |
|
1503 | 1503 |
//clean up the MMP files |
1504 |
parts.get("sysmeta").delete(); |
|
1505 |
parts.get("object").delete(); |
|
1504 |
//parts.get("sysmeta").delete();
|
|
1505 |
//parts.get("object").delete();
|
|
1506 | 1506 |
} catch (NotAuthorized e) { |
1507 | 1507 |
response.setStatus(500); |
1508 | 1508 |
serializeException(e, out); |
... | ... | |
1547 | 1547 |
{ |
1548 | 1548 |
if(parts != null) |
1549 | 1549 |
{ |
1550 |
parts.get("sysmeta").delete(); |
|
1551 |
parts.get("object").delete(); |
|
1550 |
//parts.get("sysmeta").delete();
|
|
1551 |
//parts.get("object").delete();
|
|
1552 | 1552 |
} |
1553 | 1553 |
} |
1554 | 1554 |
} |
1555 | 1555 |
|
1556 | 1556 |
/** |
1557 |
* Earthgrid API > Put Service > Delete Function : calls MetacatHandler > handleDeleteAction |
|
1558 |
* |
|
1557 |
* Handle delete |
|
1559 | 1558 |
* @param guid ID of data object to be deleted |
1560 | 1559 |
* @throws IOException |
1561 | 1560 |
*/ |
1562 | 1561 |
private void deleteObject(String guid) throws IOException |
1563 | 1562 |
{ |
1564 | 1563 |
// Look up the localId for this global identifier |
1564 |
System.out.println("!!!!!!!!!!!!!!!!!deleting object " + guid); |
|
1565 | 1565 |
IdentifierManager im = IdentifierManager.getInstance(); |
1566 | 1566 |
String localId = ""; |
1567 |
OutputStream out = response.getOutputStream(); |
|
1568 |
response.setStatus(200); |
|
1567 | 1569 |
try { |
1568 | 1570 |
localId = im.getLocalId(guid); |
1569 | 1571 |
} catch (McdbDocNotFoundException e) { |
1570 |
// TODO: Need to return the proper DataONE exception |
|
1572 |
NotFound nf = new NotFound("1340", "Document with guid " + guid + " not found."); |
|
1573 |
response.setStatus(404); |
|
1574 |
serializeException(nf, out); |
|
1571 | 1575 |
} |
1572 |
|
|
1573 |
params.put("docid", new String[] { localId }); |
|
1574 |
PrintWriter out = response.getWriter(); |
|
1575 |
response.setStatus(200); |
|
1576 |
response.setContentType("text/xml"); |
|
1577 |
handler.handleDeleteAction(out, params, request, response, username, |
|
1578 |
groupNames); |
|
1576 |
|
|
1577 |
AuthToken token = new AuthToken(sessionId); |
|
1578 |
CrudService cs = CrudService.getInstance(); |
|
1579 |
Identifier id = new Identifier(); |
|
1580 |
id.setValue(guid); |
|
1581 |
try |
|
1582 |
{ |
|
1583 |
System.out.println("Calling delete"); |
|
1584 |
cs.delete(token, id); |
|
1585 |
} |
|
1586 |
catch (NotAuthorized e) { |
|
1587 |
response.setStatus(500); |
|
1588 |
serializeException(e, out); |
|
1589 |
} catch (InvalidToken e) { |
|
1590 |
response.setStatus(500); |
|
1591 |
serializeException(e, out); |
|
1592 |
} catch (ServiceFailure e) { |
|
1593 |
response.setStatus(500); |
|
1594 |
serializeException(e, out); |
|
1595 |
} catch (NotImplemented e) { |
|
1596 |
response.setStatus(500); |
|
1597 |
serializeException(e, out); |
|
1598 |
} catch (InvalidRequest e) { |
|
1599 |
response.setStatus(500); |
|
1600 |
serializeException(e, out); |
|
1601 |
} catch(NotFound e) { |
|
1602 |
response.setStatus(500); |
|
1603 |
serializeException(e, out); |
|
1604 |
} |
|
1579 | 1605 |
out.close(); |
1580 | 1606 |
} |
1581 | 1607 |
|
build.xml | ||
---|---|---|
176 | 176 |
value="RELEASE_EML_2_0_0_UPDATE_1" /> |
177 | 177 |
<property name="eml2_0_1-schema-tag" value="RELEASE_EML_2_0_1" /> |
178 | 178 |
<property name="eml2_1_0-schema-tag" value="RELEASE_EML_2_1_0" /> |
179 |
<property name="dataone-schema-tag" value="D1_SCHEMA_0_5" /> |
|
179 |
<property name="dataone-schema-tag" value="D1_SCHEMA_0_5_1" />
|
|
180 | 180 |
<property name="eml2-style-tag" value="RELEASE_EML_UTILS_0_9_0" /> |
181 | 181 |
<property name="eml2_0_0namespace" |
182 | 182 |
value="eml://ecoinformatics.org/eml-2.0.0" /> |
Also available in: Unified diff
changes for new d1 schemas