use of ddf.catalog.content.operation.impl.CreateStorageResponseImpl in project ddf by codice.
the class FileSystemStorageProvider method create.
@Override
public CreateStorageResponse create(CreateStorageRequest createRequest) throws StorageException {
LOGGER.trace("ENTERING: create");
List<ContentItem> contentItems = createRequest.getContentItems();
List<ContentItem> createdContentItems = new ArrayList<>(createRequest.getContentItems().size());
for (ContentItem contentItem : contentItems) {
try {
if (!ContentItemValidator.validate(contentItem)) {
LOGGER.warn("Item is not valid: {}", contentItem);
continue;
}
Path contentIdDir = getTempContentItemDir(createRequest.getId(), new URI(contentItem.getUri()));
Path contentDirectory = Files.createDirectories(contentIdDir);
createdContentItems.add(generateContentFile(contentItem, contentDirectory, (String) createRequest.getPropertyValue(Constants.STORE_REFERENCE_KEY)));
} catch (IOException | URISyntaxException | IllegalArgumentException e) {
throw new StorageException(e);
}
}
CreateStorageResponse response = new CreateStorageResponseImpl(createRequest, createdContentItems);
updateMap.put(createRequest.getId(), createdContentItems.stream().map(ContentItem::getUri).collect(Collectors.toSet()));
LOGGER.trace("EXITING: create");
return response;
}
Aggregations