use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class StoreAdminHandler method create.
@ApiOperation("Create a new store")
@ApiResponses({ @ApiResponse(code = 201, response = ArtifactStore.class, message = "The store was created"), @ApiResponse(code = 409, message = "A store with the specified type and name already exists") })
@ApiImplicitParams({ @ApiImplicitParam(allowMultiple = false, paramType = "body", name = "body", required = true, dataType = "org.commonjava.indy.model.core.ArtifactStore", value = "The artifact store definition JSON") })
@POST
@Consumes(ApplicationContent.application_json)
@Produces(ApplicationContent.application_json)
public Response create(@PathParam("packageType") final String packageType, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @Context final UriInfo uriInfo, @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;
}
logger.info("\n\nGot artifact store: {}\n\n", store);
try {
String user = securityManager.getUser(securityContext, request);
if (adminController.store(store, user, false)) {
final URI uri = uriInfo.getBaseUriBuilder().path("/api/admin/stores").path(store.getPackageType()).path(store.getType().singularEndpointName()).build(store.getName());
response = formatCreatedResponseWithJsonEntity(uri, store, objectMapper);
} else {
response = status(CONFLICT).entity("{\"error\": \"Store already exists.\"}").type(application_json).build();
}
} catch (final IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class StatsHandler method getAllEndpoints.
@ApiOperation("Retrieve a listing of the artifact stores available on the system. This is especially useful for setting up a network of Indy instances that reference one another")
@ApiResponse(code = 200, response = EndpointViewListing.class, message = "The artifact store listing")
@Path("/all-endpoints")
@GET
@Produces(ApplicationContent.application_json)
public Response getAllEndpoints(@Context final UriInfo uriInfo) {
Response response;
try {
final String baseUri = uriInfo.getBaseUriBuilder().path(IndyDeployment.API_PREFIX).build().toString();
final EndpointViewListing listing = statsController.getEndpointsListing(baseUri, uriFormatter);
response = formatOkResponseWithJsonEntity(listing, objectMapper);
logger.info("\n\n\n\n\n\n{} Sent all-endpoints:\n\n{}\n\n\n\n\n\n\n", new Date(), listing);
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to retrieve endpoint listing: %s", formatEntity(e)), e);
response = formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class RevisionsAdminResource method doGet.
@ApiOperation("Retrieve the changelog for the Indy data directory content with the specified path, start-index, and number of results")
@ApiResponse(code = 200, message = "JSON containing changelog entries", response = ChangeSummaryDTO.class)
@Path("/data/changelog{path: /.*}")
@GET
@Produces(ApplicationContent.application_json)
public Response doGet(@PathParam("path") final String path, @QueryParam("start") final int start, @QueryParam("count") final int count) {
Response response;
try {
final List<ChangeSummary> listing = revisionsManager.getDataChangeLog(path, start, count);
response = formatOkResponseWithJsonEntity(new ChangeSummaryDTO(listing), objectMapper);
} catch (final GitSubsystemException e) {
logger.error("Failed to read git changelog from data dir: " + e.getMessage(), e);
response = formatResponse(e, "Failed to read git changelog from data dir.");
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class RevisionsAdminResource method pushDataGitUpdates.
@ApiOperation("Push Indy data directory content to the configured remote Git repository (if configured in the [revisions] section)")
@ApiResponse(code = 200, message = "Push complete, or not configured")
@Path("/data/push")
@GET
public Response pushDataGitUpdates() {
Response response;
try {
revisionsManager.pushDataUpdates();
// FIXME: Return some status
response = Response.ok().build();
} catch (final GitSubsystemException e) {
logger.error("Failed to push git updates for data dir: " + e.getMessage(), e);
response = ResponseUtils.formatResponse(e, "Failed to push git updates for data dir: " + e.getMessage());
}
return response;
}
use of io.swagger.annotations.ApiResponse 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;
}
Aggregations