use of javax.ws.rs.PathParam in project indy by Commonjava.
the class DeprecatedContentAccessResource method doCreate.
@ApiOperation("Store file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 201, message = "Content was stored successfully"), @ApiResponse(code = 400, message = "No appropriate storage location was found in the specified store (this store, or a member if a group is specified).") })
@PUT
@Path("/{path: (.+)?}")
public Response doCreate(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @PathParam("path") final String path, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
String packageType = MavenPackageTypeDescriptor.MAVEN_PKG_KEY;
final Supplier<URI> uriSupplier = () -> uriInfo.getBaseUriBuilder().path(getClass()).path(path).build(packageType, type, name);
final Consumer<Response.ResponseBuilder> deprecated = builder -> {
String alt = Paths.get("/api/maven", type, name, path).toString();
responseHelper.markDeprecated(builder, alt);
};
final EventMetadata metadata = new EventMetadata().set(STORE_HTTP_HEADERS, RequestUtils.extractRequestHeadersToMap(request));
return handler.doCreate(packageType, type, name, path, request, metadata, uriSupplier, deprecated);
}
use of javax.ws.rs.PathParam in project wildfly by wildfly.
the class DeploymentRestResourcesDefintion method addMethodParameters.
private void addMethodParameters(JaxrsResourceMethodDescription jaxrsRes, Method method) {
for (Parameter param : method.getParameters()) {
ParamInfo paramInfo = new ParamInfo();
paramInfo.cls = param.getType();
paramInfo.defaultValue = null;
paramInfo.name = null;
paramInfo.type = null;
Annotation annotation;
if ((annotation = param.getAnnotation(PathParam.class)) != null) {
PathParam pathParam = (PathParam) annotation;
paramInfo.name = pathParam.value();
paramInfo.type = "@" + PathParam.class.getSimpleName();
} else if ((annotation = param.getAnnotation(QueryParam.class)) != null) {
QueryParam queryParam = (QueryParam) annotation;
paramInfo.name = queryParam.value();
paramInfo.type = "@" + QueryParam.class.getSimpleName();
} else if ((annotation = param.getAnnotation(HeaderParam.class)) != null) {
HeaderParam headerParam = (HeaderParam) annotation;
paramInfo.name = headerParam.value();
paramInfo.type = "@" + HeaderParam.class.getSimpleName();
} else if ((annotation = param.getAnnotation(CookieParam.class)) != null) {
CookieParam cookieParam = (CookieParam) annotation;
paramInfo.name = cookieParam.value();
paramInfo.type = "@" + CookieParam.class.getSimpleName();
} else if ((annotation = param.getAnnotation(MatrixParam.class)) != null) {
MatrixParam matrixParam = (MatrixParam) annotation;
paramInfo.name = matrixParam.value();
paramInfo.type = "@" + MatrixParam.class.getSimpleName();
} else if ((annotation = param.getAnnotation(FormParam.class)) != null) {
FormParam formParam = (FormParam) annotation;
paramInfo.name = formParam.value();
paramInfo.type = "@" + FormParam.class.getSimpleName();
}
if (paramInfo.name == null) {
paramInfo.name = param.getName();
}
if ((annotation = param.getAnnotation(DefaultValue.class)) != null) {
DefaultValue defaultValue = (DefaultValue) annotation;
paramInfo.defaultValue = defaultValue.value();
}
jaxrsRes.parameters.add(paramInfo);
}
}
use of javax.ws.rs.PathParam in project japid42 by branaway.
the class RouterMethod method extractArguments.
public Object[] extractArguments(play.mvc.Http.RequestHeader r) {
String path = r.path();
if (path.endsWith(withExtension))
path = path.substring(0, path.lastIndexOf(withExtension));
List<RegMatch> rootParamValueMatches = RegMatch.findAllMatchesIn(valueExtractionPattern, path);
List<String> rootParamValues = new ArrayList<String>();
for (RegMatch rm : rootParamValueMatches) {
rootParamValues.addAll(rm.subgroups);
}
if (rootParamValues.size() != paramSpecList.size()) {
throw new RuntimeException("param spec number does not match that from URI capturing. Spec contains: " + paramSpecList.size() + " while the URI contains: " + rootParamValues.size() + ". The route entry is: " + this.toString());
}
Map<String, Object> args = new java.util.HashMap<String, Object>();
int c = 0;
for (ParamSpec paramSpec : paramSpecList) {
String name = paramSpec.name;
String value = rootParamValues.get(c++);
if (!paramSpec.formatPattern.matcher(value).matches()) {
throw new IllegalArgumentException("format mismatch for : (" + name + ")" + value + ". The route entry is: " + this.toString());
}
Class<?> type = paramSpec.type;
Object val = convertArgType(c, name, value, type);
args.put(name, val);
}
//
Object[] argValues = new Object[0];
List<Object> argVals = new ArrayList<Object>();
Annotation[][] annos = meth.getParameterAnnotations();
c = 0;
int pos = 0;
for (Annotation[] ans : annos) {
PathParam pathParam = null;
QueryParam queryParam = null;
for (Annotation an : ans) {
if (an instanceof PathParam)
pathParam = (PathParam) an;
else if (an instanceof QueryParam)
queryParam = (QueryParam) an;
}
if (pathParam != null) {
Object v = args.get(pathParam.value());
if (v != null)
argVals.add(v);
else
throw new IllegalArgumentException("can not find annotation value for argument " + pathParam.value() + "in " + meth.getDeclaringClass() + "#" + meth);
} else if (queryParam != null) {
String name = queryParam.value();
// XXX should this
String queryString = r.getQueryString(name);
// be of
// String[]?
argVals.add(convertArgType(c, name, queryString, meth.getParameterTypes()[c]));
} else if (autoRouting) {
Object v = args.get("_" + pos++);
if (v != null)
argVals.add(v);
else
throw new IllegalArgumentException("can not find value for param No. " + c + " in " + meth.getDeclaringClass() + "#" + meth);
} else
throw new IllegalArgumentException("can not find how to map the value for an argument for method:" + meth.getDeclaringClass() + "#" + meth + ". The parameter position is(0-based): " + c);
c++;
}
argValues = argVals.toArray(argValues);
return argValues;
}
use of javax.ws.rs.PathParam in project graylog2-server by Graylog2.
the class AuthzRolesResource method getUsersForRole.
@GET
@ApiOperation(value = "Get a paginated list of users for a role")
@Path("/{roleId}/assignees")
@Produces(MediaType.APPLICATION_JSON)
@RequiresPermissions(RestPermissions.USERS_LIST)
public PaginatedResponse<UserOverviewDTO> getUsersForRole(@ApiParam(name = "roleId") @PathParam("roleId") @NotEmpty String roleId, @ApiParam(name = "page") @QueryParam("page") @DefaultValue("1") int page, @ApiParam(name = "per_page") @QueryParam("per_page") @DefaultValue("50") int perPage, @ApiParam(name = "query") @QueryParam("query") @DefaultValue("") String query, @ApiParam(name = "sort", value = "The field to sort the result on", required = true, allowableValues = "username,full_name,email") @DefaultValue(AuthzRoleDTO.FIELD_NAME) @QueryParam("sort") String sort, @ApiParam(name = "order", value = "The sort direction", allowableValues = "asc, desc") @DefaultValue("asc") @QueryParam("order") String order) {
SearchQuery searchQuery;
try {
searchQuery = userSearchQueryParser.parse(query);
} catch (IllegalArgumentException e) {
throw new BadRequestException("Invalid argument in search query: " + e.getMessage());
}
final PaginatedList<UserOverviewDTO> result = paginatedUserService.findPaginatedByRole(searchQuery, page, perPage, sort, order, ImmutableSet.of(roleId));
final Set<String> roleIds = result.stream().flatMap(u -> u.roles().stream()).collect(Collectors.toSet());
final Map<String, String> rolesMap = authzRolesService.findPaginatedByIds(new SearchQuery(""), 0, 0, AuthzRoleDTO.FIELD_NAME, "asc", roleIds).stream().collect(Collectors.toMap(AuthzRoleDTO::id, AuthzRoleDTO::name));
final List<UserOverviewDTO> users = result.stream().map(u -> {
final Set<String> roleNames = u.roles().stream().map(rolesMap::get).collect(Collectors.toSet());
return u.toBuilder().roles(roleNames).build();
}).collect(Collectors.toList());
final PaginatedList<UserOverviewDTO> enrichedResult = new PaginatedList<>(users, result.pagination().total(), result.pagination().page(), result.pagination().perPage());
return PaginatedResponse.create("users", enrichedResult, query);
}
use of javax.ws.rs.PathParam in project graylog2-server by Graylog2.
the class IndicesResource method indexSetClosed.
@GET
@Timed
@Path("/{indexSetId}/closed")
@ApiOperation(value = "Get a list of closed indices that can be reopened.")
@Produces(MediaType.APPLICATION_JSON)
public ClosedIndices indexSetClosed(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<String> closedIndices = indices.getClosedIndices(indexSet).stream().filter(index -> isPermitted(RestPermissions.INDICES_READ, index)).collect(Collectors.toSet());
return ClosedIndices.create(closedIndices, closedIndices.size());
}
Aggregations