use of nl.knaw.huygens.timbuctoo.remote.rs.download.exceptions.CantDetermineDataSetException in project timbuctoo by HuygensING.
the class ResourceSyncImportMutation method executeAction.
@Override
public Object executeAction(DataFetchingEnvironment env) {
User user = MutationHelpers.getUser(env);
String dataSetName = env.getArgument("dataSetName");
String capabilityListUri = env.getArgument("capabilityListUri");
String userSpecifiedDataSet = env.getArgument("userSpecifiedDataSet");
String authString = env.getArgument("authorization");
try {
ImportInfo importInfo = new ImportInfo(capabilityListUri, Date.from(Instant.now()));
DataSet dataSet = dataSetRepository.createDataSet(user, dataSetName, Lists.newArrayList(importInfo));
MutationHelpers.checkPermission(env, dataSet.getMetadata(), Permission.IMPORT_RESOURCESYNC);
ResourceSyncReport resourceSyncReport = new ResourceSyncReport();
ResourceSyncMutationFileHelper fileHelper = new ResourceSyncMutationFileHelper(dataSet, resourceSyncReport);
ResourceSyncImport resourceSyncImport = new ResourceSyncImport(resourceSyncFileLoader, false);
resourceSyncImport.filterAndImport(capabilityListUri, userSpecifiedDataSet, authString, null, fileHelper);
return resourceSyncReport;
} catch (DataStoreCreationException | IllegalDataSetNameException | IOException | CantRetrieveFileException | CantDetermineDataSetException | DataSetCreationException e) {
LOG.error("Failed to do a resource sync import. ", e);
throw new RuntimeException(e);
}
}
use of nl.knaw.huygens.timbuctoo.remote.rs.download.exceptions.CantDetermineDataSetException in project timbuctoo by HuygensING.
the class ResourceSyncUpdateMutation method executeAction.
@Override
public Object executeAction(DataFetchingEnvironment env) {
User user = MutationHelpers.getUser(env);
String combinedId = env.getArgument("dataSetId");
// the user-specified authorization token for remote server:
String authString = env.getArgument("authorization");
Tuple<String, String> userAndDataSet = DataSetMetaData.splitCombinedId(combinedId);
Optional<DataSet> dataSetOpt;
ResourceSyncReport resourceSyncReport = new ResourceSyncReport();
try {
dataSetOpt = dataSetRepository.getDataSet(user, userAndDataSet.getLeft(), userAndDataSet.getRight());
if (!dataSetOpt.isPresent()) {
LOG.error("DataSet does not exist.");
throw new RuntimeException("DataSet does not exist.");
}
DataSet dataSet = dataSetOpt.get();
MutationHelpers.checkPermission(env, dataSet.getMetadata(), Permission.UPDATE_RESOURCESYNC);
String capabilityListUri = dataSet.getMetadata().getImportInfo().get(0).getImportSource();
Date lastUpdate = dataSet.getMetadata().getImportInfo().get(0).getLastImportedOn();
dataSet.getMetadata().getImportInfo().get(0).setLastImportedOn(Date.from(Instant.now()));
ResourceSyncMutationFileHelper fileHelper = new ResourceSyncMutationFileHelper(dataSet, resourceSyncReport);
ResourceSyncImport resourceSyncImport = new ResourceSyncImport(resourceSyncFileLoader, false);
resourceSyncImport.filterAndImport(capabilityListUri, null, authString, lastUpdate, fileHelper);
} catch (IOException | CantRetrieveFileException | CantDetermineDataSetException e) {
LOG.error("Failed to do a resource sync import. ", e);
throw new RuntimeException(e);
}
return resourceSyncReport;
}
Aggregations