use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class SettingsTemplate method formatSettings.
private void formatSettings() throws WebdavException {
if (content != null) {
return;
}
final String name = key.getName();
final StoreType type = key.getType();
final StringBuilder url = new StringBuilder();
url.append(requestInfo.getBaseUrl());
logger.debug("settings base-url is: '{}'", url);
if (url.charAt(url.length() - 1) != '/') {
url.append('/');
}
url.append("api/");
url.append(type.singularEndpointName()).append('/').append(name);
try {
final Map<String, Object> params = new HashMap<String, Object>();
params.put(TYPE_KEY, type.singularEndpointName());
params.put(NAME_KEY, name);
params.put(URL_KEY, url);
params.put(RELEASES_KEY, advice.isReleasesAllowed());
params.put(SNAPSHOTS_KEY, advice.isSnapshotsAllowed());
params.put(DEPLOY_ENABLED_KEY, advice.isDeployable());
final String rendered = templateEngine.render(TEMPLATE, params);
content = rendered.getBytes("UTF-8");
} catch (final UnsupportedEncodingException e) {
throw new IllegalStateException("Cannot find encoding for UTF-8!", e);
} catch (final IndyGroovyException e) {
throw new WebdavException(String.format("Failed to render settings.xml template for: '%s'. Reason: %s", key, e.getMessage()), e);
}
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class SettingsURIMatcher method getStoreType.
/* (non-Javadoc)
* @see org.commonjava.indy.dotmaven.util.URIMatcher#getStoreType()
*/
@Override
public StoreType getStoreType() {
if (!matches()) {
return null;
}
final String typePart = matcher.group(TYPE_GRP);
if (typePart == null) {
return null;
}
final StoreType type = StoreType.get(typePart);
return type;
}
use of org.commonjava.indy.model.core.StoreType 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().packageType(MAVEN_PKG_KEY).enabledState(true).getOrderedConcreteStoresInGroup(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.model.core.StoreType in project indy by Commonjava.
the class NfcResource method getStore.
@Path("/{packageType}/{type: (hosted|group|remote)}/{name}")
@ApiOperation("Retrieve all not-found cache entries currently tracked for a given store")
@ApiResponses({ @ApiResponse(code = 200, response = NotFoundCacheDTO.class, message = "The not-found cache for the specified artifact store") })
@GET
@Produces(ApplicationContent.application_json)
public Response getStore(@ApiParam(name = "packageType", required = true, value = "The type of package (eg. maven, npm, generic-http)") @PathParam("packageType") final String packageType, @ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "The type of store") @PathParam("type") final String t, @ApiParam(name = "name", value = "The name of the store") @PathParam("name") final String name) {
Response response;
final StoreType type = StoreType.get(t);
final StoreKey key = new StoreKey(packageType, type, name);
try {
final NotFoundCacheDTO dto = controller.getMissing(key);
response = formatOkResponseWithJsonEntity(dto, serializer);
} catch (final IndyWorkflowException e) {
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class NfcResource method deprecatedClearStore.
@Path("/{type: (hosted|group|remote)}/{name}{path: (/.+)?}")
@ApiOperation("[Deprecated] Clear all not-found cache entries for a particular store (or optionally, a subpath within a store)")
@DELETE
@Deprecated
public Response deprecatedClearStore(@ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "The type of store") @PathParam("type") final String t, @ApiParam(name = "name", required = true, value = "The name of the store") @PathParam("name") final String name, @ApiParam(name = "path", required = false, value = "The sub-path to clear") @PathParam("path") final String p) {
Response response;
final StoreType type = StoreType.get(t);
String altPath = Paths.get("/api/nfc", MAVEN_PKG_KEY, type.singularEndpointName(), name).toString();
final StoreKey key = new StoreKey(type, name);
try {
if (isNotEmpty(p)) {
controller.clear(key);
} else {
controller.clear(key, p);
}
response = markDeprecated(Response.ok(), altPath).build();
} catch (final IndyWorkflowException e) {
response = formatResponse(e, (rb) -> markDeprecated(rb, altPath));
}
return response;
}
Aggregations