use of io.swagger.annotations.ApiImplicitParams in project indy by Commonjava.
the class ReplicationHandler method replicate.
@ApiOperation("Replicate the stores of a remote Indy")
@ApiImplicitParams({ @ApiImplicitParam(paramType = "body", name = "body", dataType = "org.commonjava.indy.model.core.dto.ReplicationDTO", required = true, value = "The configuration determining how replication should be handled, and what remote site to replicate.") })
@POST
@Produces(ApplicationContent.application_json)
public Response replicate(@Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
Response response;
try {
String user = securityManager.getUser(securityContext, request);
ReplicationDTO dto = serializer.readValue(request.getInputStream(), ReplicationDTO.class);
final Set<StoreKey> replicated = controller.replicate(dto, user);
final Map<String, Object> params = new LinkedHashMap<String, Object>();
params.put("replicationCount", replicated.size());
params.put("items", replicated);
response = responseHelper.formatOkResponseWithJsonEntity(params);
} catch (final IndyWorkflowException | IOException e) {
logger.error(String.format("Replication failed: %s", e.getMessage()), e);
response = responseHelper.formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiImplicitParams 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());
// logger.warn("=> JSON: " + json);
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 = responseHelper.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 = responseHelper.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 = responseHelper.formatCreatedResponseWithJsonEntity(uri, store);
} else {
response = status(CONFLICT).entity("{\"error\": \"Store already exists.\"}").type(application_json).build();
}
} catch (final IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = responseHelper.formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiImplicitParams in project CzechIdMng by bcvsolutions.
the class IdmRoleCatalogueController method findRoots.
@ResponseBody
@RequestMapping(value = "/search/roots", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLECATALOGUE_AUTOCOMPLETE + "')")
@ApiOperation(value = "Search root catalogues", nickname = "searchRootRoleCatalogues", tags = { IdmRoleCatalogueController.TAG })
@ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "string", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "string", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") })
public Resources<?> findRoots(@RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
IdmRoleCatalogueFilter filter = toFilter(parameters);
filter.setRoots(Boolean.TRUE);
//
return toResources(find(filter, pageable, IdmBasePermission.AUTOCOMPLETE), IdmTreeNode.class);
}
use of io.swagger.annotations.ApiImplicitParams in project CzechIdMng by bcvsolutions.
the class IdmTreeNodeController method findChildren.
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.TREENODE_AUTOCOMPLETE + "')")
@RequestMapping(value = "/search/children", method = RequestMethod.GET)
@ApiOperation(value = "Search sub tree nodes", nickname = "searchChildrenTreeNodes", tags = { IdmTreeNodeController.TAG }, notes = "Finds direct chilren by given parent node uuid identifier. Set 'parent' parameter.")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "string", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "string", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") })
public Resources<?> findChildren(@RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
IdmTreeNodeFilter filter = toFilter(parameters);
filter.setRecursively(false);
//
return toResources(find(filter, pageable, IdmBasePermission.AUTOCOMPLETE), IdmTreeNode.class);
}
use of io.swagger.annotations.ApiImplicitParams in project swagger-core by swagger-api.
the class ParameterProcessorTest method implicitParameterLongTypeProcessorTest.
@Test(description = "test for issue #1873 fixing.")
public void implicitParameterLongTypeProcessorTest() throws NoSuchMethodException {
final ApiImplicitParams params = getClass().getDeclaredMethod("implicitParametrizedMethodLongType").getAnnotation(ApiImplicitParams.class);
final PathParameter param0 = (PathParameter) ParameterProcessor.applyAnnotations(null, new PathParameter(), String.class, Collections.<Annotation>singletonList(params.value()[0]));
assertEquals(param0.getName(), "id");
assertEquals(param0.getIn(), "path");
assertEquals(param0.getRequired(), true);
assertEquals(param0.getType(), "integer");
assertEquals(param0.getFormat(), "int64");
}
Aggregations