use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class MaintenanceHandler method deleteAllViaGet.
@ApiOperation("Delete the specified path globally (from any repository that contains it).")
@ApiResponse(code = 200, message = "Global deletion complete for path.")
@Path("/delete/all{path: (/.+)?}")
@GET
public Response deleteAllViaGet(@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 MaintenanceHandler method rescanAll.
@ApiOperation("Rescan all content in all repositories 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/all")
@GET
public Response rescanAll() {
Response response;
try {
contentController.rescanAll();
response = Response.ok().build();
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to rescan: ALL. Reason: %s", e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.IndyWorkflowException 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;
}
use of org.commonjava.indy.IndyWorkflowException 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;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class StoreAdminHandler method store.
/*
* (non-Javadoc)
* @see org.commonjava.indy.core.rest.admin.DeployPointAdminResource#store(java.lang.String)
*/
@ApiOperation("Update an existing store")
@ApiResponses({ @ApiResponse(code = 200, message = "The store was updated"), @ApiResponse(code = 400, message = "The store specified in the body JSON didn't match the URL parameters") })
@ApiImplicitParams({ @ApiImplicitParam(allowMultiple = false, paramType = "body", name = "body", required = true, dataType = "org.commonjava.indy.model.core.ArtifactStore", value = "The artifact store definition JSON") })
@Path("/{name}")
@PUT
@Consumes(ApplicationContent.application_json)
public Response store(@PathParam("packageType") final String packageType, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
final StoreType st = StoreType.get(type);
Response response = null;
String json = null;
try {
json = IOUtils.toString(request.getInputStream());
json = objectMapper.patchLegacyStoreJson(json);
} catch (final IOException e) {
final String message = "Failed to read " + st.getStoreClass().getSimpleName() + " from request body.";
logger.error(message, e);
response = formatResponse(e, message);
}
if (response != null) {
return response;
}
ArtifactStore store = null;
try {
store = objectMapper.readValue(json, st.getStoreClass());
} catch (final IOException e) {
final String message = "Failed to parse " + st.getStoreClass().getSimpleName() + " from request body.";
logger.error(message, e);
response = formatResponse(e, message);
}
if (response != null) {
return response;
}
if (!packageType.equals(store.getPackageType()) || st != store.getType() || !name.equals(store.getName())) {
response = Response.status(Status.BAD_REQUEST).entity(String.format("Store in URL path is: '%s' but in JSON it is: '%s'", new StoreKey(packageType, st, name), store.getKey())).build();
}
try {
String user = securityManager.getUser(securityContext, request);
logger.info("Storing: {}", store);
if (adminController.store(store, user, false)) {
response = ok().build();
} else {
logger.warn("{} NOT modified!", store);
response = notModified().build();
}
} catch (final IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = formatResponse(e);
}
return response;
}
Aggregations