use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.MutationHelpers.getUser in project timbuctoo by HuygensING.
the class DeleteDataSetMutation method get.
@Override
public Object get(DataFetchingEnvironment environment) {
String combinedId = environment.getArgument("dataSetId");
Tuple<String, String> userAndDataSet = DataSetMetaData.splitCombinedId(combinedId);
User user = MutationHelpers.getUser(environment);
try {
dataSetRepository.removeDataSet(userAndDataSet.getLeft(), userAndDataSet.getRight(), user);
return new RemovedDataSet(combinedId);
} catch (IOException e) {
LOG.error("Data set deletion exception", e);
throw new RuntimeException("Data set could not be deleted");
} catch (NotEnoughPermissionsException e) {
throw new RuntimeException("You do not have enough permissions");
} catch (DataSetRepository.DataSetDoesNotExistException e) {
throw new RuntimeException(e.getMessage());
}
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.MutationHelpers.getUser in project timbuctoo by HuygensING.
the class MakePublicMutation method get.
@Override
public Object get(DataFetchingEnvironment env) {
User user = MutationHelpers.getUser(env);
DataSet dataSet = MutationHelpers.getDataSet(env, dataSetRepository::getDataSet);
try {
dataSetRepository.publishDataSet(user, dataSet.getMetadata().getOwnerId(), dataSet.getMetadata().getDataSetId());
} catch (DataSetPublishException e) {
LOG.error("Failed to publish data set", e);
throw new RuntimeException("Failed to publish data set");
}
return new DataSetWithDatabase(dataSet);
}
Aggregations