Search in sources :

Example 1 with SettingsTemplate

use of org.commonjava.indy.dotmaven.util.SettingsTemplate in project indy by Commonjava.

the class SettingsSubStore method getSettingsTemplate.

private synchronized SettingsTemplate getSettingsTemplate(final URIMatcher matcher) throws WebdavException {
    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. Reason: %s", key, e.getMessage()), e);
        throw new WebdavException("Failed to retrieve length for: " + matcher.getURI());
    }
    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. Reason: %s", key, e.getMessage()), e);
        throw new WebdavException("Failed to retrieve length for: " + matcher.getURI());
    }
    return new SettingsTemplate(key, advice, requestInfo, templatingEngine);
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) StorageAdvice(org.commonjava.indy.dotmaven.data.StorageAdvice) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) SettingsTemplate(org.commonjava.indy.dotmaven.util.SettingsTemplate) WebdavException(net.sf.webdav.exceptions.WebdavException) StoreKey(org.commonjava.indy.model.core.StoreKey) DotMavenException(org.commonjava.indy.dotmaven.DotMavenException)

Example 2 with SettingsTemplate

use of org.commonjava.indy.dotmaven.util.SettingsTemplate in project indy by Commonjava.

the class SettingsSubStore method getStoredObject.

@Override
public StoredObject getStoredObject(final ITransaction transaction, final String uri) throws WebdavException {
    final StoredObject so = new StoredObject();
    final Date d = new Date();
    so.setCreationDate(d);
    so.setLastModified(d);
    final SettingsURIMatcher matcher = new SettingsURIMatcher(uri);
    if (matcher.isSettingsFileResource()) {
        so.setFolder(false);
        final SettingsTemplate st = getSettingsTemplate(matcher);
        so.setResourceLength(st.getLength());
    } else {
        so.setFolder(true);
    }
    return so;
}
Also used : SettingsURIMatcher(org.commonjava.indy.dotmaven.util.SettingsURIMatcher) StoredObject(net.sf.webdav.StoredObject) SettingsTemplate(org.commonjava.indy.dotmaven.util.SettingsTemplate) Date(java.util.Date)

Aggregations

SettingsTemplate (org.commonjava.indy.dotmaven.util.SettingsTemplate)2 Date (java.util.Date)1 StoredObject (net.sf.webdav.StoredObject)1 WebdavException (net.sf.webdav.exceptions.WebdavException)1 IndyDataException (org.commonjava.indy.data.IndyDataException)1 DotMavenException (org.commonjava.indy.dotmaven.DotMavenException)1 StorageAdvice (org.commonjava.indy.dotmaven.data.StorageAdvice)1 SettingsURIMatcher (org.commonjava.indy.dotmaven.util.SettingsURIMatcher)1 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1