use of org.commonjava.indy.dotmaven.util.StoreURIMatcher in project indy by Commonjava.
the class ArtifactStoreSubStore method getResourceContent.
@Override
public InputStream getResourceContent(final ITransaction transaction, final String resourceUri) throws WebdavException {
final StoreURIMatcher matcher = new StoreURIMatcher(resourceUri);
final Transfer item = getTransfer(matcher);
if (item == null) {
throw new WebdavException("Cannot read content: " + resourceUri);
}
final String path = item.getPath();
final StoreKey key = LocationUtils.getKey(item);
try {
return item.openInputStream();
} catch (final IOException e) {
logger.error(String.format("Failed to open InputStream for: %s in store: %s. Reason: %s", path, key, e.getMessage()), e);
throw new WebdavException("Failed to get content for: " + resourceUri);
}
}
use of org.commonjava.indy.dotmaven.util.StoreURIMatcher in project indy by Commonjava.
the class ArtifactStoreSubStore method createResource.
@Override
public void createResource(final ITransaction transaction, final String resourceUri) throws WebdavException {
final StoreURIMatcher matcher = new StoreURIMatcher(resourceUri);
if (!matcher.hasStorePath()) {
throw new WebdavException("No store-level path specified: '" + resourceUri + "'. This URI references either a list of stores, a root store directory, or something else equally read-only.");
}
final StorageAdvice advice = getStorageAdviceFor(matcher);
final String path = matcher.getStorePath();
final Transfer item = fileManager.getStorageReference(advice.getHostedStore(), path);
try {
item.createFile();
} catch (final IOException e) {
logger.error("Failed to create file: {} in store: {}. Reason: {}", e, path, advice.getStore().getKey(), e.getMessage());
throw new WebdavException("Failed to create file: " + resourceUri);
}
}
Aggregations