use of org.eclipse.dataspaceconnector.ids.spi.IdsType in project DataSpaceConnector by eclipse-dataspaceconnector.
the class DescriptionHandler method handleRequestInternal.
public MultipartResponse handleRequestInternal(@NotNull MultipartRequest multipartRequest, @NotNull Result<ClaimToken> verificationResult) {
Objects.requireNonNull(multipartRequest);
Objects.requireNonNull(verificationResult);
var descriptionRequestMessage = (DescriptionRequestMessage) multipartRequest.getHeader();
var payload = multipartRequest.getPayload();
var requestedElement = descriptionRequestMessage.getRequestedElement();
IdsId idsId = null;
if (requestedElement != null) {
var result = transformerRegistry.transform(requestedElement, IdsId.class);
if (result.failed() || (idsId = result.getContent()) == null) {
monitor.warning(String.format("Could not transform URI to IdsId: [%s]", String.join(", ", result.getFailureMessages())));
return createBadParametersErrorMultipartResponse(descriptionRequestMessage);
}
}
IdsType type;
if (idsId == null || (type = idsId.getType()) == IdsType.CONNECTOR) {
return connectorDescriptionRequestHandler.handle(descriptionRequestMessage, verificationResult, payload);
}
switch(type) {
case ARTIFACT:
return artifactDescriptionRequestHandler.handle(descriptionRequestMessage, verificationResult, payload);
case CATALOG:
return dataCatalogDescriptionRequestHandler.handle(descriptionRequestMessage, verificationResult, payload);
case REPRESENTATION:
return representationDescriptionRequestHandler.handle(descriptionRequestMessage, verificationResult, payload);
case RESOURCE:
return resourceDescriptionRequestHandler.handle(descriptionRequestMessage, verificationResult, payload);
default:
return createErrorMultipartResponse(descriptionRequestMessage);
}
}
Aggregations