use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class MaintenanceHandler method rescan.
@ApiOperation("Rescan all content in the specified repository to re-initialize metadata, capture missing index keys, etc.")
@ApiResponse(code = 200, message = "Rescan was started successfully. (NOTE: There currently is no way to determine when rescanning is complete.)")
@Path("/rescan/{packageType}/{type: (hosted|group|remote)}/{name}")
@GET
public Response rescan(@ApiParam(value = "The package type (eg. maven, npm, generic-http)", required = true) @PathParam("packageType") final String packageType, @ApiParam(value = "The type of store / repository", allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam("The name of the store / repository") @PathParam("name") final String name) {
final StoreKey key = new StoreKey(packageType, StoreType.get(type), name);
Response response;
try {
contentController.rescan(key);
response = Response.ok().build();
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to rescan: %s. Reason: %s", key, e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class ReplicationHandler method replicate.
@ApiOperation("Replicate the stores of a remote Indy")
@ApiImplicitParams({ @ApiImplicitParam(paramType = "body", name = "body", dataType = "org.commonjava.indy.model.core.dto.ReplicationDTO", required = true, value = "The configuration determining how replication should be handled, and what remote site to replicate.") })
@POST
@Produces(ApplicationContent.application_json)
public Response replicate(@Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
Response response;
try {
String user = securityManager.getUser(securityContext, request);
final ReplicationDTO dto = serializer.readValue(request.getInputStream(), ReplicationDTO.class);
final Set<StoreKey> replicated = controller.replicate(dto, user);
final Map<String, Object> params = new LinkedHashMap<String, Object>();
params.put("replicationCount", replicated.size());
params.put("items", replicated);
response = formatOkResponseWithJsonEntity(params, serializer);
} catch (final IndyWorkflowException | IOException e) {
logger.error(String.format("Replication failed: %s", e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class NfcResource method clearStore.
@Path("/{packageType}/{type: (hosted|group|remote)}/{name}{path: (/.+)?}")
@ApiOperation("Clear all not-found cache entries for a particular store (or optionally, a subpath within a store)")
@DELETE
public Response clearStore(@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", 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);
try {
final StoreKey key = new StoreKey(packageType, type, name);
if (isNotEmpty(p)) {
controller.clear(key);
} else {
controller.clear(key, p);
}
response = Response.ok().build();
} catch (final IndyWorkflowException e) {
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class NfcResource method deprecatedGetStore.
@Path("/{type: (hosted|group|remote)}/{name}")
@ApiOperation("[Deprecated] 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 deprecatedGetStore(@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);
String altPath = Paths.get("/api/nfc", MAVEN_PKG_KEY, type.singularEndpointName(), name).toString();
final StoreKey key = new StoreKey(type, name);
try {
final NotFoundCacheDTO dto = controller.getMissing(key);
response = formatOkResponseWithJsonEntity(dto, serializer, rb -> markDeprecated(rb, altPath));
} catch (final IndyWorkflowException e) {
response = formatResponse(e, (rb) -> markDeprecated(rb, altPath));
}
return response;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class SetBackSettingsManager method deleteStoreSettings.
public boolean deleteStoreSettings(final ArtifactStore store) throws SetBackDataException {
if (!config.isEnabled()) {
throw new SetBackDataException("SetBack is disabled!");
}
final StoreKey key = store.getKey();
if (StoreType.hosted == key.getType()) {
return false;
}
final DataFile settingsXml = getSettingsXml(key);
if (settingsXml.exists()) {
try {
settingsXml.delete(new ChangeSummary(ChangeSummary.SYSTEM_USER, "SETBACK: Deleting generated SetBack settings.xml for: " + store));
} catch (final IOException e) {
throw new SetBackDataException("Failed to delete SetBack settings.xml for: %s.\n at: %s\n Reason: %s", e, store, settingsXml, e.getMessage());
}
return true;
}
return false;
}
Aggregations