Search in sources :

Example 1 with RmlRdfCreator

use of nl.knaw.huygens.timbuctoo.v5.rml.RmlRdfCreator in project timbuctoo by HuygensING.

the class Rml method upload.

@POST
public Response upload(final String rdfData, @PathParam("userId") final String ownerId, @PathParam("dataSetId") final String dataSetId, @HeaderParam("authorization") String authHeader) throws DataStoreCreationException, LogStorageFailedException, ExecutionException, InterruptedException {
    Optional<User> user;
    try {
        user = userValidator.getUserFromAccessToken(authHeader);
    } catch (UserValidationException e) {
        LOG.error("Exception validating user", e);
        return Response.status(Response.Status.UNAUTHORIZED).build();
    }
    if (!user.isPresent()) {
        return Response.status(Response.Status.UNAUTHORIZED).build();
    }
    final Optional<DataSet> dataSet = dataSetRepository.getDataSet(user.get(), ownerId, dataSetId);
    if (dataSet.isPresent()) {
        ImportManager importManager = dataSet.get().getImportManager();
        final String baseUri = dataSet.get().getMetadata().getBaseUri();
        Future<ImportStatus> promise = importManager.generateLog(baseUri, baseUri, new RmlRdfCreator(baseUri, rdfData));
        return handleImportManagerResult(promise);
    } else {
        return errorResponseHelper.dataSetNotFound(ownerId, dataSetId);
    }
}
Also used : UserValidationException(nl.knaw.huygens.timbuctoo.v5.security.exceptions.UserValidationException) ImportManager(nl.knaw.huygens.timbuctoo.v5.dataset.ImportManager) User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet) ImportStatus(nl.knaw.huygens.timbuctoo.v5.dataset.ImportStatus) RmlRdfCreator(nl.knaw.huygens.timbuctoo.v5.rml.RmlRdfCreator) POST(javax.ws.rs.POST)

Aggregations

POST (javax.ws.rs.POST)1 ImportManager (nl.knaw.huygens.timbuctoo.v5.dataset.ImportManager)1 ImportStatus (nl.knaw.huygens.timbuctoo.v5.dataset.ImportStatus)1 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)1 RmlRdfCreator (nl.knaw.huygens.timbuctoo.v5.rml.RmlRdfCreator)1 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)1 UserValidationException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.UserValidationException)1