use of io.swagger.annotations.ApiImplicitParams in project indy by Commonjava.
the class DeprecatedStoreAdminHandler 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(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @Context final UriInfo uriInfo, @Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
String altPath = Paths.get(MavenPackageTypeDescriptor.MAVEN_ADMIN_REST_BASE_PATH, type).toString();
Consumer<Response.ResponseBuilder> modifier = (rb) -> responseHelper.markDeprecated(rb, altPath);
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 = responseHelper.formatResponse(e, message, modifier);
}
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, modifier);
}
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(getClass()).path(store.getName()).build(store.getKey().getType().singularEndpointName());
response = responseHelper.formatCreatedResponseWithJsonEntity(uri, store, modifier);
} else {
response = responseHelper.markDeprecated(status(CONFLICT).entity("{\"error\": \"Store already exists.\"}").type(application_json), altPath).build();
}
} catch (final IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = responseHelper.formatResponse(e, modifier);
}
return response;
}
use of io.swagger.annotations.ApiImplicitParams 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 = 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;
}
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 = responseHelper.formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiImplicitParams in project CzechIdMng by bcvsolutions.
the class IdmAuditController method findEntity.
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.AUDIT_READ + "')")
@RequestMapping(value = "/search/entity", method = RequestMethod.GET)
@ApiOperation(value = "Search audit logs related to entity", nickname = "searchEntity", tags = { IdmAuditController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.AUDIT_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.AUDIT_READ, description = "") }) })
@ApiImplicitParams({ @ApiImplicitParam(name = "entity", allowMultiple = false, dataType = "string", paramType = "query", value = "Entity class - find related audit log to this class"), @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<?> findEntity(@RequestParam(required = false) String entityClass, @RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
//
// Because backward compatibility there must be set entity class and other useless parameters
IdmAuditFilter filter = toFilter(parameters);
if (StringUtils.isEmpty(filter.getOwnerType())) {
throw new ResultCodeException(CoreResultCode.AUDIT_ENTITY_CLASS_IS_NOT_FILLED);
}
// Backward compatibility
if (StringUtils.isEmpty(filter.getOwnerCode()) && parameters.containsKey(IdmIdentity_.username.getName())) {
Object identityUsername = parameters.getFirst(IdmIdentity_.username.getName());
if (identityUsername != null) {
filter.setOwnerCode(identityUsername.toString());
}
}
//
Page<IdmAuditDto> dtos = auditService.find(filter, pageable);
Map<UUID, BaseDto> loadedDtos = new HashMap<>();
dtos.forEach(dto -> {
loadEmbeddedEntity(loadedDtos, dto);
});
return toResources(dtos, getDtoClass());
}
use of io.swagger.annotations.ApiImplicitParams in project CzechIdMng by bcvsolutions.
the class IdmRoleRequestController method getConcepts.
@ResponseBody
@RequestMapping(value = "/{backendId}/concepts", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_REQUEST_READ + "')")
@ApiOperation(value = "Role request concepts", nickname = "getRoleRequestConcepts", tags = { IdmRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }) })
@ApiImplicitParams({ @ApiImplicitParam(name = "parameters", allowMultiple = true, dataType = "string", paramType = "query", value = "Search criteria parameters. Parameters could be registered by module. Example id=25c5b9e8-b15d-4f95-b715-c7edf6f4aee6"), @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<?> getConcepts(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable String backendId, @RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
IdmRoleRequestDto entity = getDto(backendId);
if (entity == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
//
IdmConceptRoleRequestFilter filter = conceptRoleRequestController.toFilter(parameters);
filter.setRoleRequestId(entity.getId());
//
return toResources(conceptRoleRequestController.find(filter, pageable, IdmBasePermission.READ), IdmRoleRequestDto.class);
}
use of io.swagger.annotations.ApiImplicitParams in project CzechIdMng by bcvsolutions.
the class IdmRoleCatalogueController method findChildren.
@ResponseBody
@RequestMapping(value = "/search/children", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLECATALOGUE_AUTOCOMPLETE + "')")
@ApiOperation(value = "Search sub catalogues", nickname = "searchChildrenRoleCatalogues", tags = { IdmRoleCatalogueController.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) {
IdmRoleCatalogueFilter filter = toFilter(parameters);
filter.setRecursively(false);
//
return toResources(find(filter, pageable, IdmBasePermission.AUTOCOMPLETE), IdmTreeNode.class);
}
Aggregations