Search in sources :

Example 11 with WebdavException

use of net.sf.webdav.exceptions.WebdavException in project indy by Commonjava.

the class ArtifactStoreSubStore method getStorageAdviceFor.

private StorageAdvice getStorageAdviceFor(final StoreURIMatcher matcher) throws WebdavException {
    final String uri = matcher.getURI();
    final StoreKey key = matcher.getStoreKey();
    ArtifactStore store;
    try {
        store = indy.getArtifactStore(key);
    } catch (final IndyDataException e) {
        logger.error(String.format("Failed to retrieve artifact store: %s for URI: %s\nReason: %s", key, uri, e.getMessage()), e);
        throw new WebdavException("Cannot create: " + uri);
    }
    if (store == null) {
        throw new WebdavException("Cannot retrieve ArtifactStore: " + key);
    }
    StorageAdvice advice;
    try {
        advice = advisor.getStorageAdvice(store);
    } catch (final DotMavenException e) {
        logger.error(String.format("Failed to retrieve storage advice for: %s (URI: %s)\nReason: %s", key, uri, e.getMessage()), e);
        throw new WebdavException("Cannot create: " + uri);
    }
    if (!advice.isDeployable()) {
        throw new WebdavException("Read-only area. Cannot create: " + uri);
    }
    return advice;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) StorageAdvice(org.commonjava.indy.dotmaven.data.StorageAdvice) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) WebdavException(net.sf.webdav.exceptions.WebdavException) StoreKey(org.commonjava.indy.model.core.StoreKey) DotMavenException(org.commonjava.indy.dotmaven.DotMavenException)

Aggregations

WebdavException (net.sf.webdav.exceptions.WebdavException)11 Transfer (org.commonjava.maven.galley.model.Transfer)7 IOException (java.io.IOException)6 StorageAdvice (org.commonjava.indy.dotmaven.data.StorageAdvice)6 StoreURIMatcher (org.commonjava.indy.dotmaven.util.StoreURIMatcher)6 IndyDataException (org.commonjava.indy.data.IndyDataException)5 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)5 StoreKey (org.commonjava.indy.model.core.StoreKey)5 StoreType (org.commonjava.indy.model.core.StoreType)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 DotMavenException (org.commonjava.indy.dotmaven.DotMavenException)2 OutputStreamWriter (java.io.OutputStreamWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Writer (java.io.Writer)1 HashMap (java.util.HashMap)1 SettingsTemplate (org.commonjava.indy.dotmaven.util.SettingsTemplate)1 SettingsURIMatcher (org.commonjava.indy.dotmaven.util.SettingsURIMatcher)1 IndyGroovyException (org.commonjava.indy.subsys.template.IndyGroovyException)1