use of org.commonjava.indy.dotmaven.DotMavenException 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);
}
use of org.commonjava.indy.dotmaven.DotMavenException in project indy by Commonjava.
the class StorageAdvisor method getStorageAdvice.
public StorageAdvice getStorageAdvice(final ArtifactStore store) throws DotMavenException {
boolean deployable = false;
boolean releases = true;
boolean snapshots = false;
HostedRepository hostedStore = null;
final StoreType type = store.getKey().getType();
all: switch(type) {
case group:
{
List<ArtifactStore> constituents;
try {
constituents = dataManager.query().enabledState(true).getOrderedConcreteStoresInGroup(MAVEN_PKG_KEY, store.getName());
} catch (final IndyDataException e) {
throw new DotMavenException("Failed to retrieve constituent ArtifactStores for group: %s. Reason: %s", e, store.getName(), e.getMessage());
}
for (final ArtifactStore as : constituents) {
if (as.getKey().getType() == hosted) {
deployable = true;
hostedStore = (HostedRepository) as;
snapshots = hostedStore.isAllowSnapshots();
releases = hostedStore.isAllowReleases();
break all;
}
}
break;
}
case hosted:
{
deployable = true;
hostedStore = (HostedRepository) store;
snapshots = hostedStore.isAllowSnapshots();
releases = hostedStore.isAllowReleases();
break;
}
default:
}
return new StorageAdvice(store, hostedStore, deployable, releases, snapshots);
}
use of org.commonjava.indy.dotmaven.DotMavenException 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;
}
Aggregations