Search in sources :

Example 36 with IndyWorkflowException

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;
}
Also used : ResponseUtils.formatResponse(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponse(io.swagger.annotations.ApiResponse)

Example 37 with IndyWorkflowException

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;
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 38 with IndyWorkflowException

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;
}
Also used : ResponseUtils.formatResponse(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse) Response(javax.ws.rs.core.Response) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) HttpExchangeMetadata(org.commonjava.maven.galley.transport.htcli.model.HttpExchangeMetadata)

Example 39 with IndyWorkflowException

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;
}
Also used : ResponseUtils.formatResponse(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 40 with IndyWorkflowException

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;
}
Also used : OutputStream(java.io.OutputStream) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Transfer(org.commonjava.maven.galley.model.Transfer) IOException(java.io.IOException) EventMetadata(org.commonjava.maven.galley.event.EventMetadata)

Aggregations

IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)109 Response (javax.ws.rs.core.Response)40 Transfer (org.commonjava.maven.galley.model.Transfer)39 IOException (java.io.IOException)36 ResponseUtils.formatResponse (org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse)36 StoreKey (org.commonjava.indy.model.core.StoreKey)36 ApiOperation (io.swagger.annotations.ApiOperation)35 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)34 ApiResponse (io.swagger.annotations.ApiResponse)33 Path (javax.ws.rs.Path)32 StoreType (org.commonjava.indy.model.core.StoreType)26 IndyDataException (org.commonjava.indy.data.IndyDataException)25 GET (javax.ws.rs.GET)24 Logger (org.slf4j.Logger)22 ApiResponses (io.swagger.annotations.ApiResponses)21 ArrayList (java.util.ArrayList)19 Produces (javax.ws.rs.Produces)18 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)18 InputStream (java.io.InputStream)15 List (java.util.List)13