use of javax.ws.rs.PathParam in project graylog2-server by Graylog2.
the class IndicesResource method indexSetReopened.
@GET
@Timed
@Path("/{indexSetId}/reopened")
@ApiOperation(value = "Get a list of reopened indices, which will not be cleaned by retention cleaning")
@Produces(MediaType.APPLICATION_JSON)
public ClosedIndices indexSetReopened(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
final Set<String> reopenedIndices = indices.getReopenedIndices(indexSet).stream().filter(index -> isPermitted(RestPermissions.INDICES_READ, index)).collect(Collectors.toSet());
return ClosedIndices.create(reopenedIndices, reopenedIndices.size());
}
use of javax.ws.rs.PathParam in project graylog2-server by Graylog2.
the class IndexSetsResource method get.
@GET
@Path("{id}")
@Timed
@ApiOperation(value = "Get index set")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Unauthorized"), @ApiResponse(code = 404, message = "Index set not found") })
public IndexSetSummary get(@ApiParam(name = "id", required = true) @PathParam("id") String id) {
checkPermission(RestPermissions.INDEXSETS_READ, id);
final IndexSetConfig defaultIndexSet = indexSetService.getDefault();
return indexSetService.get(id).map(config -> IndexSetSummary.fromIndexSetConfig(config, config.equals(defaultIndexSet))).orElseThrow(() -> new NotFoundException("Couldn't load index set with ID <" + id + ">"));
}
use of javax.ws.rs.PathParam in project graylog2-server by Graylog2.
the class Generator method determineParameters.
private List<Parameter> determineParameters(Method method) {
final List<Parameter> params = Lists.newArrayList();
int i = 0;
for (Annotation[] annotations : method.getParameterAnnotations()) {
final Parameter param = new Parameter();
Parameter.Kind paramKind = Parameter.Kind.BODY;
for (Annotation annotation : annotations) {
if (annotation instanceof ApiParam) {
final ApiParam apiParam = (ApiParam) annotation;
final String name = Strings.isNullOrEmpty(apiParam.name()) ? Strings.isNullOrEmpty(apiParam.value()) ? "arg" + i : apiParam.value() : apiParam.name();
param.setName(name);
param.setDescription(apiParam.value());
param.setIsRequired(apiParam.required());
final TypeSchema parameterSchema = typeSchema(method.getGenericParameterTypes()[i]);
param.setTypeSchema(parameterSchema);
if (!isNullOrEmpty(apiParam.defaultValue())) {
param.setDefaultValue(apiParam.defaultValue());
}
}
if (annotation instanceof DefaultValue) {
final DefaultValue defaultValueAnnotation = (DefaultValue) annotation;
// Only set if empty to make sure ApiParam's defaultValue has precedence!
if (isNullOrEmpty(param.getDefaultValue()) && !isNullOrEmpty(defaultValueAnnotation.value())) {
param.setDefaultValue(defaultValueAnnotation.value());
}
}
if (annotation instanceof QueryParam) {
paramKind = Parameter.Kind.QUERY;
} else if (annotation instanceof PathParam) {
paramKind = Parameter.Kind.PATH;
} else if (annotation instanceof HeaderParam) {
paramKind = Parameter.Kind.HEADER;
} else if (annotation instanceof FormParam) {
paramKind = Parameter.Kind.FORM;
}
}
param.setKind(paramKind);
if (param.getTypeSchema() != null) {
params.add(param);
}
i++;
}
return params;
}
use of javax.ws.rs.PathParam in project swagger-core by swagger-api.
the class DefaultParameterExtension method extractParameters.
@Override
public ResolvedParameter extractParameters(List<Annotation> annotations, Type type, Set<Type> typesToSkip, Components components, javax.ws.rs.Consumes classConsumes, javax.ws.rs.Consumes methodConsumes, boolean includeRequestBody, JsonView jsonViewAnnotation, Iterator<OpenAPIExtension> chain) {
if (shouldIgnoreType(type, typesToSkip)) {
return new ResolvedParameter();
}
Parameter parameter = null;
for (Annotation annotation : annotations) {
if (annotation instanceof QueryParam) {
QueryParam param = (QueryParam) annotation;
Parameter qp = new Parameter();
qp.setIn(QUERY_PARAM);
qp.setName(param.value());
parameter = qp;
} else if (annotation instanceof PathParam) {
PathParam param = (PathParam) annotation;
Parameter pp = new Parameter();
pp.setIn(PATH_PARAM);
pp.setName(param.value());
parameter = pp;
} else if (annotation instanceof MatrixParam) {
MatrixParam param = (MatrixParam) annotation;
Parameter pp = new Parameter();
pp.setIn(PATH_PARAM);
pp.setStyle(Parameter.StyleEnum.MATRIX);
pp.setName(param.value());
parameter = pp;
} else if (annotation instanceof HeaderParam) {
HeaderParam param = (HeaderParam) annotation;
Parameter pp = new Parameter();
pp.setIn(HEADER_PARAM);
pp.setName(param.value());
parameter = pp;
} else if (annotation instanceof CookieParam) {
CookieParam param = (CookieParam) annotation;
Parameter pp = new Parameter();
pp.setIn(COOKIE_PARAM);
pp.setName(param.value());
parameter = pp;
} else if (annotation instanceof io.swagger.v3.oas.annotations.Parameter) {
if (((io.swagger.v3.oas.annotations.Parameter) annotation).hidden()) {
return new ResolvedParameter();
}
if (parameter == null) {
parameter = new Parameter();
}
if (StringUtils.isNotBlank(((io.swagger.v3.oas.annotations.Parameter) annotation).ref())) {
parameter.$ref(((io.swagger.v3.oas.annotations.Parameter) annotation).ref());
}
} else {
List<Parameter> formParameters = new ArrayList<>();
List<Parameter> parameters = new ArrayList<>();
if (handleAdditionalAnnotation(parameters, formParameters, annotation, type, typesToSkip, classConsumes, methodConsumes, components, includeRequestBody, jsonViewAnnotation)) {
ResolvedParameter extractParametersResult = new ResolvedParameter();
extractParametersResult.parameters.addAll(parameters);
extractParametersResult.formParameters.addAll(formParameters);
return extractParametersResult;
}
}
}
List<Parameter> parameters = new ArrayList<>();
ResolvedParameter extractParametersResult = new ResolvedParameter();
if (parameter != null && (StringUtils.isNotBlank(parameter.getIn()) || StringUtils.isNotBlank(parameter.get$ref()))) {
parameters.add(parameter);
} else if (includeRequestBody) {
Parameter unknownParameter = ParameterProcessor.applyAnnotations(null, type, annotations, components, classConsumes == null ? new String[0] : classConsumes.value(), methodConsumes == null ? new String[0] : methodConsumes.value(), jsonViewAnnotation);
if (unknownParameter != null) {
if (StringUtils.isNotBlank(unknownParameter.getIn()) && !"form".equals(unknownParameter.getIn())) {
extractParametersResult.parameters.add(unknownParameter);
} else if ("form".equals(unknownParameter.getIn())) {
unknownParameter.setIn(null);
extractParametersResult.formParameters.add(unknownParameter);
} else {
// return as request body
extractParametersResult.requestBody = unknownParameter;
}
}
}
for (Parameter p : parameters) {
Parameter processedParameter = ParameterProcessor.applyAnnotations(p, type, annotations, components, classConsumes == null ? new String[0] : classConsumes.value(), methodConsumes == null ? new String[0] : methodConsumes.value(), jsonViewAnnotation);
if (processedParameter != null) {
extractParametersResult.parameters.add(processedParameter);
}
}
return extractParametersResult;
}
use of javax.ws.rs.PathParam in project mycore by MyCoRe-Org.
the class MCRClassificationEditorResource method filter.
@GET
@Path("filter/{text}")
@Produces(MediaType.APPLICATION_JSON)
public Response filter(@PathParam("text") String text) {
SolrClient solrClient = MCRSolrClassificationUtil.getCore().getClient();
ModifiableSolrParams p = new ModifiableSolrParams();
p.set("q", "*" + text + "*");
p.set("fl", "id,ancestors");
JsonArray docList = new JsonArray();
MCRSolrSearchUtils.stream(solrClient, p).flatMap(document -> {
List<String> ids = new ArrayList<>();
ids.add(document.getFirstValue("id").toString());
Collection<Object> fieldValues = document.getFieldValues("ancestors");
if (fieldValues != null) {
for (Object anc : fieldValues) {
ids.add(anc.toString());
}
}
return ids.stream();
}).distinct().map(JsonPrimitive::new).forEach(docList::add);
return Response.ok().entity(docList.toString()).build();
}
Aggregations