use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.NotEnoughPermissionsException in project timbuctoo by HuygensING.
the class DataSetRepository method removeDataSet.
public void removeDataSet(String ownerId, String dataSetName, User user) throws IOException, NotEnoughPermissionsException, DataSetDoesNotExistException {
try {
DataSet dataSet = dataSetMap.get(ownerId).get(dataSetName);
if (dataSet == null) {
LOG.warn("DataSet '{}' of user with id '{}' does not exist (anymore).", dataSetName, ownerId);
throw new DataSetDoesNotExistException(dataSetName, ownerId);
}
String combinedId = dataSet.getMetadata().getCombinedId();
if (!permissionFetcher.getPermissions(user, dataSet.getMetadata()).contains(Permission.ADMIN)) {
throw new NotEnoughPermissionsException(String.format("User '%s' is not allowed to remove dataset '%s'", user.getDisplayName(), combinedId));
}
dataSet.stop();
dataSetMap.get(ownerId).remove(dataSetName);
permissionFetcher.removeAuthorizations(combinedId);
} catch (PermissionFetchingException e) {
throw new IOException(e);
}
// remove folder
dataStorage.getDataSetStorage(ownerId, dataSetName).clear();
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.NotEnoughPermissionsException 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());
}
}
Aggregations