Search in sources :

Example 1 with Expiration

use of org.commonjava.indy.core.expire.Expiration in project indy by Commonjava.

the class SchedulerHandler method getStoreDisableTimeout.

@ApiOperation("Retrieve the expiration information related to re-enablement of a repository")
@ApiResponses({ @ApiResponse(code = 200, message = "Expiration information retrieved successfully.", response = Expiration.class), @ApiResponse(code = 400, message = "Store is manually disabled (doesn't automatically re-enable), or isn't disabled.") })
@Path("store/{packageType}/{type: (hosted|group|remote)}/{name}/disable-timeout")
@GET
public Expiration getStoreDisableTimeout(@ApiParam(value = "Package type (maven, generic-http, npm, etc)", required = true) @PathParam("packageType") String packageType, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") String storeType, @ApiParam(required = true) @PathParam("name") String storeName) {
    StoreKey storeKey = new StoreKey(packageType, StoreType.get(storeType), storeName);
    Expiration timeout = null;
    try {
        timeout = controller.getStoreDisableTimeout(storeKey);
    } catch (IndyWorkflowException e) {
        throwError(e);
    }
    if (timeout == null) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
    return timeout;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Expiration(org.commonjava.indy.core.expire.Expiration) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with Expiration

use of org.commonjava.indy.core.expire.Expiration in project indy by Commonjava.

the class SchedulerHandler method deprecatedGetStoreDisableTimeout.

@ApiOperation("[Deprecated] Retrieve the expiration information related to re-enablement of a repository")
@ApiResponses({ @ApiResponse(code = 200, message = "Expiration information retrieved successfully.", response = Expiration.class), @ApiResponse(code = 400, message = "Store is manually disabled (doesn't automatically re-enable), or isn't disabled.") })
@Path("store/{type: (hosted|group|remote)}/{name}/disable-timeout")
@GET
@Deprecated
public Response deprecatedGetStoreDisableTimeout(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") String storeType, @ApiParam(required = true) @PathParam("name") String storeName) {
    StoreType type = StoreType.get(storeType);
    String altPath = Paths.get("/api/admin/schedule", MAVEN_PKG_KEY, type.singularEndpointName(), storeName).toString();
    StoreKey storeKey = new StoreKey(type, storeName);
    Expiration timeout = null;
    try {
        timeout = controller.getStoreDisableTimeout(storeKey);
        if (timeout == null) {
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
        return formatOkResponseWithJsonEntity(timeout, objectMapper, rb -> markDeprecated(rb, altPath));
    } catch (IndyWorkflowException e) {
        throwError(e, rb -> markDeprecated(rb, altPath));
    }
    return null;
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ResponseUtils.throwError(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.throwError) ApiResponses(io.swagger.annotations.ApiResponses) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) ResponseUtils.formatOkResponseWithJsonEntity(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatOkResponseWithJsonEntity) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Api(io.swagger.annotations.Api) StoreKey(org.commonjava.indy.model.core.StoreKey) MAVEN_PKG_KEY(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY) ExpirationSet(org.commonjava.indy.core.expire.ExpirationSet) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Expiration(org.commonjava.indy.core.expire.Expiration) StoreType(org.commonjava.indy.model.core.StoreType) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) ResponseUtils.markDeprecated(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.markDeprecated) ApplicationContent(org.commonjava.indy.util.ApplicationContent) Response(javax.ws.rs.core.Response) SchedulerController(org.commonjava.indy.core.ctl.SchedulerController) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) ResponseUtils(org.commonjava.indy.bind.jaxrs.util.ResponseUtils) WebApplicationException(javax.ws.rs.WebApplicationException) WebApplicationException(javax.ws.rs.WebApplicationException) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Expiration(org.commonjava.indy.core.expire.Expiration) StoreKey(org.commonjava.indy.model.core.StoreKey) Path(javax.ws.rs.Path) ResponseUtils.markDeprecated(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.markDeprecated) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)2 Expiration (org.commonjava.indy.core.expire.Expiration)2 StoreKey (org.commonjava.indy.model.core.StoreKey)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Api (io.swagger.annotations.Api)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 Paths (java.nio.file.Paths)1 Inject (javax.inject.Inject)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 IndyResources (org.commonjava.indy.bind.jaxrs.IndyResources)1 ResponseUtils (org.commonjava.indy.bind.jaxrs.util.ResponseUtils)1 ResponseUtils.formatOkResponseWithJsonEntity (org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatOkResponseWithJsonEntity)1