Search in sources :

Example 1 with DataSetPublishException

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);
    }
}
Also used : DataStorageSaveException(nl.knaw.huygens.timbuctoo.v5.datastorage.exceptions.DataStorageSaveException) DataSetPublishException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataSetPublishException) PermissionFetchingException(nl.knaw.huygens.timbuctoo.v5.security.exceptions.PermissionFetchingException) DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet) DataSetMetaData(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData) BasicDataSetMetaData(nl.knaw.huygens.timbuctoo.v5.dataset.dto.BasicDataSetMetaData)

Example 2 with DataSetPublishException

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);
}
Also used : DataSetPublishException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataSetPublishException) User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) DataSetWithDatabase(nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.DataSetWithDatabase) DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)

Aggregations

DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)2 DataSetPublishException (nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataSetPublishException)2 BasicDataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.BasicDataSetMetaData)1 DataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData)1 DataStorageSaveException (nl.knaw.huygens.timbuctoo.v5.datastorage.exceptions.DataStorageSaveException)1 DataSetWithDatabase (nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.DataSetWithDatabase)1 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)1 PermissionFetchingException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.PermissionFetchingException)1