157 |
157 |
resource = resource.trim();
|
158 |
158 |
}
|
159 |
159 |
|
160 |
|
System.out.println("handling verb " + httpVerb + " request with resource '" + resource + "'");
|
161 |
|
System.out.println("resource: '" + resource + "'");
|
|
160 |
logMetacat.debug("handling verb " + httpVerb + " request with resource '" + resource + "'");
|
|
161 |
logMetacat.debug("resource: '" + resource + "'");
|
162 |
162 |
boolean status = false;
|
163 |
163 |
|
164 |
164 |
if (resource != null) {
|
... | ... | |
173 |
173 |
// set the access rules
|
174 |
174 |
setaccess();
|
175 |
175 |
status = true;
|
176 |
|
System.out.println("done setting access");
|
|
176 |
logMetacat.debug("done setting access");
|
177 |
177 |
}
|
178 |
178 |
} else if (resource.equals(RESOURCE_IS_AUTHORIZED)) {
|
179 |
179 |
if (httpVerb == GET) {
|
... | ... | |
184 |
184 |
}
|
185 |
185 |
isAuthorized(objectId);
|
186 |
186 |
status = true;
|
187 |
|
System.out.println("done getting access");
|
|
187 |
logMetacat.debug("done getting access");
|
188 |
188 |
}
|
189 |
189 |
} else if (resource.equals(RESOURCE_META)) {
|
190 |
|
System.out.println("Using resource 'meta'");
|
|
190 |
logMetacat.debug("Using resource 'meta'");
|
191 |
191 |
String objectId = request.getPathInfo();
|
192 |
192 |
if (objectId != null && objectId.length() > 1) {
|
193 |
193 |
objectId = request.getPathInfo().substring(1);
|
... | ... | |
200 |
200 |
}
|
201 |
201 |
|
202 |
202 |
} else if (resource.equals(RESOURCE_OBJECTS)) {
|
203 |
|
System.out.println("Using resource 'object'");
|
|
203 |
logMetacat.debug("Using resource 'object'");
|
204 |
204 |
|
205 |
205 |
String objectId = request.getPathInfo();
|
206 |
206 |
if (objectId != null && objectId.length() > 1) {
|
... | ... | |
209 |
209 |
objectId = null;
|
210 |
210 |
}
|
211 |
211 |
|
212 |
|
System.out.println("objectId: " + objectId);
|
|
212 |
logMetacat.debug("objectId: " + objectId);
|
213 |
213 |
logMetacat.debug("verb:" + httpVerb);
|
214 |
214 |
|
215 |
215 |
if (httpVerb == GET) {
|
... | ... | |
230 |
230 |
}
|
231 |
231 |
|
232 |
232 |
} else if (resource.equals(RESOURCE_LOG)) {
|
233 |
|
System.out.println("Using resource 'log'");
|
|
233 |
logMetacat.debug("Using resource 'log'");
|
234 |
234 |
// handle log events
|
235 |
235 |
if (httpVerb == GET) {
|
236 |
236 |
getLog();
|
237 |
237 |
status = true;
|
238 |
238 |
}
|
239 |
239 |
} else if (resource.equals(RESOURCE_CHECKSUM)) {
|
240 |
|
System.out.println("Using resource 'checksum'");
|
|
240 |
logMetacat.debug("Using resource 'checksum'");
|
241 |
241 |
// handle checksum requests
|
242 |
242 |
if (httpVerb == GET) {
|
243 |
243 |
checksum();
|
... | ... | |
252 |
252 |
status = true;
|
253 |
253 |
} else if (resource.equals(RESOURCE_REPLICATE)) {
|
254 |
254 |
if (httpVerb == POST) {
|
255 |
|
System.out.println("processing replicate request");
|
|
255 |
logMetacat.debug("processing replicate request");
|
256 |
256 |
replicate();
|
257 |
257 |
status = true;
|
258 |
258 |
}
|
... | ... | |
283 |
283 |
serializeException(be, out);
|
284 |
284 |
} catch (Exception e) {
|
285 |
285 |
logMetacat.error(e.getClass() + ": " + e.getMessage());
|
286 |
|
System.out.println("Error handle(): " + e.getClass() + ": " + e.getMessage());
|
|
286 |
logMetacat.debug("Error handle(): " + e.getClass() + ": " + e.getMessage());
|
287 |
287 |
e.printStackTrace();
|
288 |
288 |
}
|
289 |
289 |
}
|
... | ... | |
314 |
314 |
}
|
315 |
315 |
|
316 |
316 |
private boolean monitor() throws NotFound, ParseException, NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, InsufficientResources, UnsupportedType, IOException, JiBXException {
|
317 |
|
System.out.println("processing monitor request");
|
|
317 |
logMetacat.debug("processing monitor request");
|
318 |
318 |
String pathInfo = request.getPathInfo();
|
319 |
319 |
|
320 |
|
System.out.println("verb is GET");
|
321 |
|
System.out.println("pathInfo is " + pathInfo);
|
|
320 |
logMetacat.debug("verb is GET");
|
|
321 |
logMetacat.debug("pathInfo is " + pathInfo);
|
322 |
322 |
pathInfo = pathInfo.substring(1);
|
323 |
323 |
|
324 |
324 |
if (pathInfo.toLowerCase().equals("ping")) {
|
325 |
|
System.out.println("processing ping request");
|
|
325 |
logMetacat.debug("processing ping request");
|
326 |
326 |
boolean result = MNodeService.getInstance().ping();
|
327 |
327 |
return result;
|
328 |
328 |
|
329 |
329 |
} else if (pathInfo.toLowerCase().equals("status")) {
|
330 |
|
System.out.println("processing status request");
|
|
330 |
logMetacat.debug("processing status request");
|
331 |
331 |
// TODO: implement in MNCore
|
332 |
332 |
//MNodeService.getInstance().getStatus();
|
333 |
333 |
return false;
|
334 |
334 |
|
335 |
335 |
} else if (pathInfo.toLowerCase().equals("object")) {
|
336 |
|
System.out.println("processing object request");
|
|
336 |
logMetacat.debug("processing object request");
|
337 |
337 |
Identifier pid = null;
|
338 |
338 |
ObjectFormat format = null;
|
339 |
339 |
if (params.containsKey("format")) {
|
... | ... | |
350 |
350 |
//ObjectStatistics objectStats = MNodeService.getInstance().getObjectStatistics(format, pid);
|
351 |
351 |
|
352 |
352 |
} else if (pathInfo.toLowerCase().equals("event")) {
|
353 |
|
System.out.println("processing event request");
|
|
353 |
logMetacat.debug("processing event request");
|
354 |
354 |
ObjectFormat format = null;
|
355 |
355 |
Integer period = null;
|
356 |
356 |
String requestor = null;
|
... | ... | |
403 |
403 |
//do nothing. default to MD5
|
404 |
404 |
logMetacat.warn("No algorithm specified, using default: " + checksumAlgorithm);
|
405 |
405 |
}
|
406 |
|
System.out.println("getting checksum for object " + guid + " with algorithm " + checksumAlgorithm);
|
|
406 |
logMetacat.debug("getting checksum for object " + guid + " with algorithm " + checksumAlgorithm);
|
407 |
407 |
try {
|
408 |
408 |
Checksum c = MNodeService.getInstance().getChecksum(session, guidid, checksumAlgorithm);
|
409 |
|
System.out.println("got checksum " + c.getValue());
|
|
409 |
logMetacat.debug("got checksum " + c.getValue());
|
410 |
410 |
response.setStatus(200);
|
411 |
|
System.out.println("serializing response");
|
|
411 |
logMetacat.debug("serializing response");
|
412 |
412 |
serializeServiceType(Checksum.class, c, response.getOutputStream());
|
413 |
|
System.out.println("done serializing response.");
|
|
413 |
logMetacat.debug("done serializing response.");
|
414 |
414 |
}
|
415 |
415 |
catch(NotAuthorized na)
|
416 |
416 |
{
|
... | ... | |
445 |
445 |
*/
|
446 |
446 |
private void replicate() throws Exception {
|
447 |
447 |
|
448 |
|
System.out.println("in POST replicate()");
|
|
448 |
logMetacat.debug("in POST replicate()");
|
449 |
449 |
|
450 |
450 |
File tmpDir = getTempDirectory();
|
451 |
|
System.out.println("temp dir: " + tmpDir.getAbsolutePath());
|
|
451 |
logMetacat.debug("temp dir: " + tmpDir.getAbsolutePath());
|
452 |
452 |
MultipartRequestResolver mrr = new MultipartRequestResolver(
|
453 |
453 |
tmpDir.getAbsolutePath(), 1000000000, 0);
|
454 |
454 |
MultipartRequest mr = mrr.resolveMultipart(request);
|
... | ... | |
456 |
456 |
Iterator keys = files.keySet().iterator();
|
457 |
457 |
while(keys.hasNext()) {
|
458 |
458 |
String key = (String)keys.next();
|
459 |
|
System.out.println("files key: " + key);
|
460 |
|
System.out.println("files value: " + files.get(key));
|
|
459 |
logMetacat.debug("files key: " + key);
|
|
460 |
logMetacat.debug("files value: " + files.get(key));
|
461 |
461 |
}
|
462 |
462 |
|
463 |
463 |
Map<String, List<String>> params = mr.getMultipartParameters();
|
464 |
464 |
keys = params.keySet().iterator();
|
465 |
465 |
while(keys.hasNext()) {
|
466 |
466 |
String key = (String)keys.next();
|
467 |
|
System.out.println("params key: " + key);
|
468 |
|
System.out.println("params value: " + params.get(key));
|
|
467 |
logMetacat.debug("params key: " + key);
|
|
468 |
logMetacat.debug("params value: " + params.get(key));
|
469 |
469 |
}
|
470 |
470 |
|
471 |
471 |
// File f = files.get("sysmeta");
|
472 |
472 |
// the files are not being keyed by the part name, but rather the filename
|
473 |
473 |
File f = files.get(files.keySet().iterator().next());
|
474 |
474 |
|
475 |
|
System.out.println("file: " + f.getAbsolutePath());
|
|
475 |
logMetacat.debug("file: " + f.getAbsolutePath());
|
476 |
476 |
FileInputStream fis = new FileInputStream(f);
|
477 |
477 |
|
478 |
478 |
String sn = params.get("sourceNode").get(0);
|
479 |
|
System.out.println("sourceNode: " + sn);
|
|
479 |
logMetacat.debug("sourceNode: " + sn);
|
480 |
480 |
NodeReference sourceNode = (NodeReference) deserializeServiceType(NodeReference.class, new ByteArrayInputStream(sn.getBytes("UTF-8")));
|
481 |
481 |
|
482 |
482 |
//parse the systemMetadata
|
... | ... | |
589 |
589 |
|
590 |
590 |
try {
|
591 |
591 |
String fromDateS = params.get("fromDate")[0];
|
592 |
|
System.out.println("param fromDateS: " + fromDateS);
|
|
592 |
logMetacat.debug("param fromDateS: " + fromDateS);
|
593 |
593 |
fromDate = parseDateAndConvertToGMT(fromDateS);
|
594 |
594 |
} catch (Exception e) {
|
595 |
595 |
logMetacat.warn("Could not parse fromDate: " + e.getMessage());
|
596 |
596 |
}
|
597 |
597 |
try {
|
598 |
598 |
String toDateS = params.get("toDate")[0];
|
599 |
|
System.out.println("param toDateS: " + toDateS);
|
|
599 |
logMetacat.debug("param toDateS: " + toDateS);
|
600 |
600 |
toDate = parseDateAndConvertToGMT(toDateS);
|
601 |
601 |
} catch (Exception e) {
|
602 |
602 |
logMetacat.warn("Could not parse toDate: " + e.getMessage());
|
... | ... | |
607 |
607 |
} catch (Exception e) {
|
608 |
608 |
logMetacat.warn("Could not parse event: " + e.getMessage());
|
609 |
609 |
}
|
610 |
|
System.out.println("fromDate: " + fromDate + " toDate: " + toDate);
|
|
610 |
logMetacat.debug("fromDate: " + fromDate + " toDate: " + toDate);
|
611 |
611 |
|
612 |
612 |
try {
|
613 |
613 |
start = Integer.parseInt(params.get("start")[0]);
|
... | ... | |
620 |
620 |
logMetacat.warn("Could not parse count: " + e.getMessage());
|
621 |
621 |
}
|
622 |
622 |
|
623 |
|
System.out.println("calling getLogRecords");
|
|
623 |
logMetacat.debug("calling getLogRecords");
|
624 |
624 |
Log log = MNodeService.getInstance().getLogRecords(session, fromDate, toDate, event, start, count);
|
625 |
625 |
|
626 |
626 |
out = response.getOutputStream();
|
... | ... | |
713 |
713 |
catch(Exception e)
|
714 |
714 |
{
|
715 |
715 |
response.setStatus(500);
|
716 |
|
System.out.println("Error with Crud.get(). " +
|
|
716 |
logMetacat.error("Error with Crud.get(). " +
|
717 |
717 |
"If this is an 'Exception producing data' error, " +
|
718 |
718 |
"go to CrudService.get() for better debugging. " +
|
719 |
719 |
"Here's the error: " + e.getClass() + ": " + e.getMessage());
|
... | ... | |
739 |
739 |
String[] value = (String[])request.getParameterValues(name);
|
740 |
740 |
/*for(int i=0; i<value.length; i++)
|
741 |
741 |
{
|
742 |
|
System.out.println("name: " + name + " value: " + value[i]);
|
|
742 |
logMetacat.debug("name: " + name + " value: " + value[i]);
|
743 |
743 |
}*/
|
744 |
744 |
if(name.equals("startTime") && value != null)
|
745 |
745 |
{
|
... | ... | |
750 |
750 |
}
|
751 |
751 |
catch(Exception e)
|
752 |
752 |
{ //if we can't parse it, just don't use the startTime param
|
753 |
|
System.out.println("Could not parse startTime: " + value[0]);
|
|
753 |
logMetacat.warn("Could not parse startTime: " + value[0]);
|
754 |
754 |
startTime = null;
|
755 |
755 |
}
|
756 |
756 |
}
|
... | ... | |
763 |
763 |
}
|
764 |
764 |
catch(Exception e)
|
765 |
765 |
{ //if we can't parse it, just don't use the endTime param
|
766 |
|
System.out.println("Could not parse endTime: " + value[0]);
|
|
766 |
logMetacat.warn("Could not parse endTime: " + value[0]);
|
767 |
767 |
endTime = null;
|
768 |
768 |
}
|
769 |
769 |
}
|
... | ... | |
790 |
790 |
}
|
791 |
791 |
}
|
792 |
792 |
//make the crud call
|
793 |
|
System.out.println("session: " + session + " startTime: " + startTime +
|
|
793 |
logMetacat.debug("session: " + session + " startTime: " + startTime +
|
794 |
794 |
" endtime: " + endTime + " objectFormat: " +
|
795 |
795 |
objectFormat + " replicaStatus: " + replicaStatus +
|
796 |
796 |
" start: " + start + " count: " + count);
|
... | ... | |
886 |
886 |
* @throws NotFound
|
887 |
887 |
*/
|
888 |
888 |
protected void putObject(String pid, String action) throws ServiceFailure, InvalidRequest, FileNotFoundException, JiBXException, InvalidToken, NotAuthorized, IdentifierNotUnique, UnsupportedType, InsufficientResources, InvalidSystemMetadata, NotImplemented, NotFound {
|
889 |
|
System.out.println("putObject with pid " + pid);
|
|
889 |
logMetacat.debug("putObject with pid " + pid);
|
890 |
890 |
logMetacat.debug("Entering putObject: " + pid + "/" + action);
|
891 |
891 |
OutputStream out = null;
|
892 |
892 |
try {
|
... | ... | |
914 |
914 |
|
915 |
915 |
Identifier id = new Identifier();
|
916 |
916 |
id.setValue(pid);
|
917 |
|
System.out.println("creating object with pid " + pid);
|
|
917 |
logMetacat.debug("creating object with pid " + pid);
|
918 |
918 |
Identifier rId = MNodeService.getInstance().create(session, id, object, smd);
|
919 |
919 |
serializeServiceType(Identifier.class, rId, out);
|
920 |
920 |
|
... | ... | |
962 |
962 |
Identifier id = new Identifier();
|
963 |
963 |
id.setValue(guid);
|
964 |
964 |
try {
|
965 |
|
System.out.println("Calling delete");
|
|
965 |
logMetacat.debug("Calling delete");
|
966 |
966 |
MNodeService.getInstance().delete(session, id);
|
967 |
967 |
serializeServiceType(Identifier.class, id, out);
|
968 |
968 |
}
|
use logging, not system.out