use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataSetPublishException in project timbuctoo by HuygensING.
the class DataSetRepository method publishDataSet.
public void publishDataSet(User user, String ownerId, String dataSetName) throws DataSetPublishException {
Optional<DataSet> dataSet = getDataSet(user, ownerId, dataSetName);
try {
if (dataSet.isPresent() && permissionFetcher.getPermissions(user, dataSet.get().getMetadata()).contains(Permission.ADMIN)) {
DataSetMetaData dataSetMetaData = dataSet.get().getMetadata();
dataSetMetaData.publish();
try {
dataStorage.getDataSetStorage(ownerId, dataSetName).saveMetaData(dataSetMetaData);
} catch (DataStorageSaveException e) {
throw new DataSetPublishException(e);
}
}
} catch (PermissionFetchingException e) {
throw new DataSetPublishException(e);
}
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataSetPublishException 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