Search in sources :

Example 1 with IdsType

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);
    }
}
Also used : IdsId(org.eclipse.dataspaceconnector.ids.spi.IdsId) DescriptionRequestMessage(de.fraunhofer.iais.eis.DescriptionRequestMessage) IdsType(org.eclipse.dataspaceconnector.ids.spi.IdsType)

Aggregations

DescriptionRequestMessage (de.fraunhofer.iais.eis.DescriptionRequestMessage)1 IdsId (org.eclipse.dataspaceconnector.ids.spi.IdsId)1 IdsType (org.eclipse.dataspaceconnector.ids.spi.IdsType)1