Search in sources :

Example 6 with StorageAdvice

use of org.commonjava.indy.dotmaven.data.StorageAdvice 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);
    }
}
Also used : StoreURIMatcher(org.commonjava.indy.dotmaven.util.StoreURIMatcher) StorageAdvice(org.commonjava.indy.dotmaven.data.StorageAdvice) WebdavException(net.sf.webdav.exceptions.WebdavException) Transfer(org.commonjava.maven.galley.model.Transfer) IOException(java.io.IOException)

Aggregations

WebdavException (net.sf.webdav.exceptions.WebdavException)6 StorageAdvice (org.commonjava.indy.dotmaven.data.StorageAdvice)6 IOException (java.io.IOException)4 StoreURIMatcher (org.commonjava.indy.dotmaven.util.StoreURIMatcher)4 Transfer (org.commonjava.maven.galley.model.Transfer)4 IndyDataException (org.commonjava.indy.data.IndyDataException)2 DotMavenException (org.commonjava.indy.dotmaven.DotMavenException)2 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)2 StoreKey (org.commonjava.indy.model.core.StoreKey)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 SettingsTemplate (org.commonjava.indy.dotmaven.util.SettingsTemplate)1