Search in sources :

Example 1 with RootFolderNotFoundException

use of org.craftercms.core.exception.RootFolderNotFoundException in project engine by craftercms.

the class S3ContentStoreAdapter method createContext.

/**
 * {@inheritDoc}
 */
@Override
public Context createContext(final String id, final String rootFolderPath, final boolean mergingOn, final boolean cacheOn, final int maxAllowedItemsInCache, final boolean ignoreHiddenFiles) throws RootFolderNotFoundException, StoreException, AuthenticationException {
    AmazonS3URI uri = new AmazonS3URI(StringUtils.removeEnd(rootFolderPath, DELIMITER));
    ListObjectsV2Request request = new ListObjectsV2Request().withBucketName(uri.getBucket()).withPrefix(uri.getKey()).withDelimiter(DELIMITER);
    ListObjectsV2Result result = client.listObjectsV2(request);
    if (isResultEmpty(result)) {
        throw new RootFolderNotFoundException("Root folder " + rootFolderPath + " not found");
    }
    return new S3Context(id, this, rootFolderPath, mergingOn, cacheOn, maxAllowedItemsInCache, ignoreHiddenFiles, uri);
}
Also used : RootFolderNotFoundException(org.craftercms.core.exception.RootFolderNotFoundException) AmazonS3URI(com.amazonaws.services.s3.AmazonS3URI)

Example 2 with RootFolderNotFoundException

use of org.craftercms.core.exception.RootFolderNotFoundException in project core by craftercms.

the class FileSystemContentStoreAdapter method createContext.

@Override
public Context createContext(String id, String storeServerUrl, String username, String password, String rootFolderPath, boolean mergingOn, boolean cacheOn, int maxAllowedItemsInCache, boolean ignoreHiddenFiles) throws RootFolderNotFoundException, StoreException, AuthenticationException {
    Resource rootFolderResource = resourceLoader.getResource(rootFolderPath);
    if (!rootFolderResource.exists()) {
        throw new RootFolderNotFoundException("Root folder " + rootFolderPath + " not found (make sure that it has a valid URL " + "prefix (e.g. file:))");
    }
    FileSystemFile rootFolder;
    try {
        rootFolder = new FileSystemFile(rootFolderResource.getFile());
    } catch (IOException e) {
        throw new StoreException("Unable to retrieve file handle for root folder " + rootFolderPath, e);
    }
    return new FileSystemContext(id, this, null, rootFolderPath, rootFolder, mergingOn, cacheOn, maxAllowedItemsInCache, ignoreHiddenFiles);
}
Also used : Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) RootFolderNotFoundException(org.craftercms.core.exception.RootFolderNotFoundException) StoreException(org.craftercms.core.exception.StoreException)

Aggregations

RootFolderNotFoundException (org.craftercms.core.exception.RootFolderNotFoundException)2 AmazonS3URI (com.amazonaws.services.s3.AmazonS3URI)1 IOException (java.io.IOException)1 StoreException (org.craftercms.core.exception.StoreException)1 Resource (org.springframework.core.io.Resource)1