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);
}
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);
}
Aggregations