140 |
140 |
protected static final String RESOURCE_META_CHANGED = "dirtySystemMetadata";
|
141 |
141 |
protected static final String RESOURCE_GENERATE_ID = "generate";
|
142 |
142 |
protected static final String RESOURCE_PACKAGE = "package";
|
|
143 |
protected static final String RESOURCE_VIEWS = "views";
|
143 |
144 |
|
|
145 |
|
144 |
146 |
|
145 |
147 |
// shared executor
|
146 |
148 |
private static ExecutorService executor = null;
|
... | ... | |
378 |
380 |
extra = parseTrailing(resource, RESOURCE_META);
|
379 |
381 |
getPackage(extra);
|
380 |
382 |
status = true;
|
381 |
|
}
|
382 |
|
|
|
383 |
}
|
|
384 |
} else if (resource.startsWith(RESOURCE_VIEWS)) {
|
|
385 |
logMetacat.debug("Using resource " + RESOURCE_VIEWS);
|
|
386 |
// after the command
|
|
387 |
extra = parseTrailing(resource, RESOURCE_VIEWS);
|
|
388 |
logMetacat.debug("view extra: " + extra);
|
|
389 |
|
|
390 |
String format = null;
|
|
391 |
String pid = null;
|
|
392 |
|
|
393 |
if (extra != null) {
|
|
394 |
// get the format
|
|
395 |
int formatIndex = extra.length();
|
|
396 |
if (extra.indexOf("/") > -1) {
|
|
397 |
formatIndex = extra.indexOf("/");
|
|
398 |
}
|
|
399 |
format = extra.substring(0, formatIndex);
|
|
400 |
logMetacat.debug("view format: " + format);
|
|
401 |
|
|
402 |
// get the pid if it is there
|
|
403 |
pid = extra.substring(formatIndex, extra.length());
|
|
404 |
if (pid != null && pid.length() == 0) {
|
|
405 |
pid = null;
|
|
406 |
} else {
|
|
407 |
if (pid.startsWith("/")) {
|
|
408 |
pid = pid.substring(1);
|
|
409 |
}
|
|
410 |
}
|
|
411 |
logMetacat.debug("pid: " + pid);
|
|
412 |
|
|
413 |
}
|
|
414 |
logMetacat.debug("verb:" + httpVerb);
|
|
415 |
if (httpVerb == GET) {
|
|
416 |
doViews(format, pid);
|
|
417 |
status = true;
|
|
418 |
}
|
383 |
419 |
}
|
384 |
420 |
|
385 |
421 |
if (!status) {
|
... | ... | |
479 |
515 |
}
|
480 |
516 |
}
|
481 |
517 |
|
|
518 |
private void doViews(String format, String pid) {
|
|
519 |
|
|
520 |
OutputStream out = null;
|
|
521 |
MNodeService mnode = MNodeService.getInstance(request);
|
|
522 |
|
|
523 |
try {
|
|
524 |
// get a list of views
|
|
525 |
if (pid != null) {
|
|
526 |
Identifier identifier = new Identifier();
|
|
527 |
identifier.setValue(pid);
|
|
528 |
InputStream stream = mnode.getView(session, identifier, format);
|
|
529 |
|
|
530 |
// set the content-type if we have it from the implementation
|
|
531 |
if (stream instanceof ContentTypeInputStream) {
|
|
532 |
response.setContentType(((ContentTypeInputStream) stream).getContentType());
|
|
533 |
}
|
|
534 |
response.setStatus(200);
|
|
535 |
out = response.getOutputStream();
|
|
536 |
// write the results to the output stream
|
|
537 |
IOUtils.copyLarge(stream, out);
|
|
538 |
return;
|
|
539 |
} else {
|
|
540 |
// TODO: list the registered views
|
|
541 |
BaseException ni = new NotImplemented("9999", "MN.listViews() is not implemented at this node");
|
|
542 |
throw ni;
|
|
543 |
}
|
|
544 |
|
|
545 |
|
|
546 |
} catch (BaseException be) {
|
|
547 |
// report Exceptions as clearly as possible
|
|
548 |
try {
|
|
549 |
out = response.getOutputStream();
|
|
550 |
} catch (IOException e) {
|
|
551 |
logMetacat.error("Could not get output stream from response", e);
|
|
552 |
}
|
|
553 |
serializeException(be, out);
|
|
554 |
} catch (Exception e) {
|
|
555 |
// report Exceptions as clearly and generically as possible
|
|
556 |
logMetacat.error(e.getClass() + ": " + e.getMessage(), e);
|
|
557 |
try {
|
|
558 |
out = response.getOutputStream();
|
|
559 |
} catch (IOException ioe) {
|
|
560 |
logMetacat.error("Could not get output stream from response", ioe);
|
|
561 |
}
|
|
562 |
ServiceFailure se = new ServiceFailure("0000", e.getMessage());
|
|
563 |
serializeException(se, out);
|
|
564 |
}
|
|
565 |
}
|
482 |
566 |
|
483 |
567 |
/**
|
484 |
568 |
* Handles notification of system metadata changes for the given identifier
|
implement the view service (uses existing skin-based dbtransform) - and include the REST endpoint. https://projects.ecoinformatics.org/ecoinfo/issues/6028