use of nl.knaw.huygens.timbuctoo.remote.rs.discover.Description in project timbuctoo by HuygensING.
the class ResultView method init.
private void init(Result<?> result, Interpreter interpreter) {
uri = result.getUri().toString();
ordinal = result.getOrdinal();
statusCode = result.getStatusCode();
contentType = result.getContent().map(o -> o.getClass().getSimpleName()).orElse("(no content)");
Object content = result.getContent().orElse(null);
if (content != null) {
if (content instanceof LinkList) {
LinkList linkList = (LinkList) content;
childCount = linkList.getValidUris().size();
} else if (content instanceof RsRoot) {
RsRoot<?, ?> rsRoot = (RsRoot) content;
childCount = rsRoot.getItemList().size();
Optional<Capability> optionalCapa = rsRoot.getCapability();
if (optionalCapa.isPresent()) {
capability = optionalCapa.get().xmlValue;
}
} else if (content instanceof Description) {
description = new DescriptionView((Result<Description>) result, interpreter);
}
}
if (result.getDescriptionResult().isPresent()) {
describedBy = new ResultView(result.getDescriptionResult().get(), interpreter);
}
errorList = result.getErrors().stream().map(throwable -> new ErrorView(throwable, interpreter)).collect(Collectors.toList());
invalidUris = result.getInvalidUris();
}
use of nl.knaw.huygens.timbuctoo.remote.rs.discover.Description in project timbuctoo by HuygensING.
the class DescriptionView method init.
private void init(Result<Description> descriptionResult, Interpreter interpreter) {
if (descriptionResult.getContent().isPresent()) {
Description description = descriptionResult.getContent().get();
String mimeType = description.getDescribedByLink().getType().orElse(null);
Optional<RDFFormat> maybeFormat = Rio.getParserFormatForMIMEType(mimeType);
if (!maybeFormat.isPresent()) {
String filename = descriptionResult.getUri().toString();
maybeFormat = Rio.getParserFormatForFileName(filename);
}
if (maybeFormat.isPresent()) {
createDescriptionNode(description, maybeFormat.get(), interpreter);
} else {
rawContent = description.getRawContent();
}
}
}
Aggregations