Search in sources :

Example 1 with CreateStorageResponseImpl

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;
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) CreateStorageResponseImpl(ddf.catalog.content.operation.impl.CreateStorageResponseImpl) CreateStorageResponse(ddf.catalog.content.operation.CreateStorageResponse) StorageException(ddf.catalog.content.StorageException) ContentItem(ddf.catalog.content.data.ContentItem)

Aggregations

StorageException (ddf.catalog.content.StorageException)1 ContentItem (ddf.catalog.content.data.ContentItem)1 CreateStorageResponse (ddf.catalog.content.operation.CreateStorageResponse)1 CreateStorageResponseImpl (ddf.catalog.content.operation.impl.CreateStorageResponseImpl)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1