use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class MaintenanceHandler method deleteAll.
@ApiOperation("Delete the specified path globally (from any repository that contains it).")
@ApiResponse(code = 200, message = "Global deletion complete for path.")
@Path("/content/all{path: (/.+)?}")
@DELETE
public Response deleteAll(@ApiParam("The path to delete globally") @PathParam("path") final String path) {
Response response;
try {
contentController.deleteAll(path);
response = Response.ok().build();
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to delete: %s in: ALL. Reason: %s", e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class SetBackSettingsResource method delete.
@ApiOperation("DELETE the settings.xml simulation corresponding to the specified Indy group/repository")
@ApiResponses({ @ApiResponse(code = 400, message = "Requested repository is hosted on Indy and cannot be simulated via settings.xml"), @ApiResponse(code = 404, message = "No such repository or group, or the settings.xml has not been generated."), @ApiResponse(code = 204, message = "Deletion succeeded") })
@Path("/{type: (remote|group)}/{name}")
@DELETE
public Response delete(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String t, @PathParam("name") final String n) {
final StoreType type = StoreType.get(t);
if (StoreType.hosted == type) {
return Response.status(Status.BAD_REQUEST).build();
}
Response response;
final StoreKey key = new StoreKey(type, n);
try {
final boolean found = controller.deleteSetBackSettings(key);
if (found) {
response = Response.status(Status.NO_CONTENT).build();
} else {
response = Response.status(Status.NOT_FOUND).build();
}
} catch (final IndyWorkflowException e) {
response = ResponseUtils.formatResponse(e);
}
return response;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class ContentAccessHandler method handleMissingContentQuery.
private Response handleMissingContentQuery(final StoreKey sk, final String path, final Consumer<ResponseBuilder> builderModifier) {
Response response = null;
logger.trace("Transfer not found: {}/{}", sk, path);
if (StoreType.remote == sk.getType()) {
logger.trace("Transfer was from remote repo. Trying to get HTTP metadata for: {}/{}", sk, path);
try {
final HttpExchangeMetadata metadata = contentController.getHttpMetadata(sk, path);
if (metadata != null) {
logger.trace("Using HTTP metadata to formulate response status for: {}/{}", sk, path);
response = formatResponseFromMetadata(metadata, builderModifier);
} else {
logger.trace("No HTTP metadata found!");
}
} catch (final IndyWorkflowException e) {
logger.error(String.format("Error retrieving status metadata for: %s from: %s. Reason: %s", path, sk.getName(), e.getMessage()), e);
response = formatResponse(e, builderModifier);
}
}
if (response == null) {
response = formatResponse(ApplicationStatus.NOT_FOUND, null, "Path " + path + " is not available in store " + sk + ".", builderModifier);
}
return response;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class FoloAdminResource method getRecord.
@ApiOperation("Alias of /{id}/record, returns the tracking record for the specified key")
@ApiResponses({ @ApiResponse(code = 404, message = "No such tracking record exists."), @ApiResponse(code = 200, message = "Tracking record", response = TrackedContentDTO.class) })
@Path("/{id}/record")
@GET
public Response getRecord(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @Context final UriInfo uriInfo) {
Response response;
try {
final String baseUrl = uriInfo.getBaseUriBuilder().path("api").build().toString();
final TrackedContentDTO record = controller.getRecord(id, baseUrl);
if (record == null) {
response = Response.status(Status.NOT_FOUND).build();
} else {
response = formatOkResponseWithJsonEntity(record, objectMapper);
}
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to retrieve tracking report for: %s. Reason: %s", id, e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class ArchetypeCatalogGenerator method generateGroupFileContent.
@Override
public Transfer generateGroupFileContent(final Group group, final List<ArtifactStore> members, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
if (!canProcess(path)) {
return null;
}
final Transfer target = fileManager.getTransfer(group, path);
if (!target.exists()) {
String toMergePath = path;
if (!path.endsWith(ArchetypeCatalogMerger.CATALOG_NAME)) {
toMergePath = normalize(normalize(parentPath(toMergePath)), ArchetypeCatalogMerger.CATALOG_NAME);
}
final List<Transfer> sources = fileManager.retrieveAllRaw(members, toMergePath, new EventMetadata());
final byte[] merged = merger.merge(sources, group, toMergePath);
if (merged != null) {
OutputStream fos = null;
try {
fos = target.openOutputStream(TransferOperation.GENERATE, true, eventMetadata);
fos.write(merged);
} catch (final IOException e) {
throw new IndyWorkflowException("Failed to write merged archetype catalog to: {}.\nError: {}", e, target, e.getMessage());
} finally {
closeQuietly(fos);
}
// helper.writeChecksumsAndMergeInfo( merged, sources, group, toMergePath );
}
}
if (target.exists()) {
return target;
}
return null;
}
Aggregations