下面列出了怎么用javax.ws.rs.PathParam的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* {@value GET_BUILD_CONFIGS_DESC}
*
* @param id {@value PV_ID}
* @param pageParams
* @return
*/
@Operation(
summary = GET_BUILD_CONFIGS_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = BuildConfigPage.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@GET
@Path("/{id}/build-configs")
Page<BuildConfiguration> getBuildConfigs(
@Parameter(description = PV_ID) @PathParam("id") String id,
@Valid @BeanParam PageParameters pageParams);
@ApiOperation(
value = "List enum values",
response = String.class,
responseContainer = "Array",
httpMethod = "GET"
)
@GET
@Path("/enum/{className}")
public Response listEnum(@PathParam("className") String className) {
if (!className.startsWith("org.taktik.icure.services.external.rest.v1.dto")) {
throw new IllegalArgumentException("Invalid package");
}
if (!className.matches("[a-zA-Z0-9.]+")) {
throw new IllegalArgumentException("Invalid class name");
}
try {
return Response.ok().entity(Arrays.asList((Enum[]) Class.forName(className).getMethod("values").invoke(null))
.stream().map(Enum::name).collect(Collectors.toList())).build();
} catch (IllegalAccessException | InvocationTargetException | ClassNotFoundException | NoSuchMethodException e) {
throw new IllegalArgumentException("Invalid class name");
}
}
@JaxrsMethodDescribe(value = "更新指定Work的Data数据.", action = ActionUpdateWithWorkPath0.class)
@PUT
@Path("work/{id}/{path0}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void updateWithWorkPath0(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("工作标识") @PathParam("id") String id, @JaxrsParameterDescribe("0级路径") @PathParam("path0") String path0,
JsonElement jsonElement) {
ActionResult<ActionUpdateWithWorkPath0.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionUpdateWithWorkPath0().execute(effectivePerson, id, path0, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@GET
@Path("/source/{source}/vuln/{vuln}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Returns a specific vulnerability",
response = Vulnerability.class
)
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 404, message = "The vulnerability could not be found")
})
@PermissionRequired(Permissions.Constants.VIEW_PORTFOLIO)
public Response getVulnerabilityByVulnId(@PathParam("source") String source,
@PathParam("vuln") String vuln) {
try (QueryManager qm = new QueryManager()) {
final Vulnerability vulnerability = qm.getVulnerabilityByVulnId(source, vuln);
if (vulnerability != null) {
return Response.ok(vulnerability).build();
} else {
return Response.status(Response.Status.NOT_FOUND).entity("The vulnerability could not be found.").build();
}
}
}
/**
* Removes the service network.
*
* @param id network identifier
* @return 204 NO_CONTENT, 400 BAD_REQUEST if the network does not exist
*/
@DELETE
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteNetwork(@PathParam("id") String id) {
log.trace(String.format(MESSAGE, "DELETE " + id));
if (!haService.isActive()
&& !DEFAULT_ACTIVE_IP_ADDRESS.equals(haService.getActiveIp())) {
return syncDelete(haService, NETWORKS, id);
}
adminService.removeNetwork(id);
return noContent().build();
}
@JaxrsMethodDescribe(value = "获取指定人员共享给我编辑的文件.", action = ActionListWithEditor.class)
@GET
@Path("list/editor/{owner}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithEditor(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("文件所有人") @PathParam("owner") String owner) {
ActionResult<List<ActionListWithEditor.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
result = new ActionListWithEditor().execute(effectivePerson, owner);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@POST
@Path("{id}/tag")
public ResponseFrame tagImage(@PathParam("id") String id,
@QueryParam("repo") String repo,
@QueryParam("tag") String tag) {
WebTarget target = resource().path(IMAGES)
.path(id).path("tag")
.queryParam("tag", tag).queryParam("repo", repo);
Response response = postResponse(target);
String entity = response.readEntity(String.class);
response.close();
ResponseFrame frame = new ResponseFrame();
frame.setId(id);
if (entity.isEmpty())
frame.setMessage("tagged as " + tag);
else {
JsonReader reader = Json.createReader(new StringReader(entity));
JsonObject o = reader.readObject();
frame.setMessage(o.getJsonString("message").getString());
}
return frame;
}
@ApiOperation(
value = "Get a user by his Email/Login",
response = UserDto.class,
httpMethod = "GET",
notes = "General information about the user"
)
@GET
@Path("/byEmail/{email}")
public Response getUserByEmail(@PathParam("email") String email) {
if (email == null) {
return Response.status(400).type("text/plain").entity("A required query parameter was not specified for this request.").build();
}
User user = userLogic.getUserByEmail(email);
boolean succeed = (user != null);
if (succeed) {
return Response.ok().entity(mapper.map(user, UserDto.class)).build();
} else {
return Response.status(404).type("text/plain").entity("Getting User failed. Possible reasons: no such user exists, or server error. Please try again or read the server log.").build();
}
}
/**
* Fetch complete definition of an entity given its GUID.
* @param guid GUID for the entity
* @return AtlasEntity
* @throws AtlasBaseException
*/
@GET
@Path("/guid/{guid}")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasEntityWithExtInfo getById(@PathParam("guid") String guid) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getById(" + guid + ")");
}
return entitiesStore.getById(guid);
} finally {
AtlasPerfTracer.log(perf);
}
}
@JaxrsMethodDescribe(value = "删除待办.", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionDelete().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
/**
* {@value GET_RELEASES}
*
* @param id {@value PV_ID}
* @param pageParameters
* @return
*/
@Operation(
summary = GET_RELEASES,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ProductReleasePage.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@GET
@Path("/{id}/releases")
Page<ProductRelease> getReleases(
@Parameter(description = PV_ID) @PathParam("id") String id,
@Valid @BeanParam PageParameters pageParameters);
@DELETE
@Path("/mapping/{uuid}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Deletes a mapping",
code = 204
)
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 404, message = "The UUID of the mapping could not be found"),
})
@PermissionRequired(Permissions.Constants.ACCESS_MANAGEMENT)
public Response deleteMappingByUuid(@ApiParam(value = "The UUID of the mapping to delete", required = true)
@PathParam("uuid") final String uuid) {
try (QueryManager qm = new QueryManager()) {
final MappedOidcGroup mapping = qm.getObjectByUuid(MappedOidcGroup.class, uuid);
if (mapping != null) {
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "Mapping for group " + mapping.getGroup().getName() + " and team " + mapping.getTeam().getName() + " deleted");
qm.delete(mapping);
return Response.status(Response.Status.NO_CONTENT).build();
} else {
return Response.status(Response.Status.NOT_FOUND).entity("The UUID of the mapping could not be found.").build();
}
}
}
@PUT
@Path(TagRESTConstants.RESOURCE_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerServiceResource updateServiceResource(@PathParam("id") Long id, RangerServiceResource resource) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.updateServiceResource(" + id + ")");
}
RangerServiceResource ret;
try {
validator.preUpdateServiceResource(id, resource);
ret = tagStore.updateServiceResource(resource);
} catch(Exception excp) {
LOG.error("updateServiceResource(" + resource + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== TagREST.updateServiceResource(" + id + "): " + ret);
}
return ret;
}
@JaxrsMethodDescribe(value = "根据ID删除已经上传成功的文件以及文件信息", action = ActionDelete.class)
@DELETE
@Path("{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("导入文件信息ID") @PathParam("id") String id) {
ActionResult<ActionDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
Boolean check = true;
if (check) {
try {
result = new ActionDelete().execute(request, effectivePerson, id);
} catch (Exception e) {
result = new ActionResult<>();
Exception exception = new ExceptionAttendanceImportFileProcess(e, "根据ID删除已经上传成功的文件以及文件信息时发生异常!");
result.error(exception);
logger.error(e, effectivePerson, request, null);
}
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@ApiOperation(
value = "Delete contacts.",
response = String.class,
responseContainer = "Array",
httpMethod = "DELETE",
notes = "Response is a set containing the ID's of deleted contacts."
)
@DELETE
@Path("/{contactIds}")
public Response deleteContacts(@PathParam("contactIds") String ids) {
if (ids == null || ids.length() == 0) {
return Response.status(400).type("text/plain").entity("A required query parameter was not specified for this request.").build();
}
// TODO versioning?
Set<String> deletedIds = contactLogic.deleteContacts(new HashSet<>(Arrays.asList(ids.split(","))));
boolean succeed = (deletedIds != null);
if (succeed) {
return Response.ok().entity(deletedIds).build();
} else {
return Response.status(500).type("text/plain").entity("Contacts deletion failed.").build();
}
}
@DELETE
@Path("/{id}/entries/{cartEntryId}")
@ApiOperation(value = "Removes a cart entry from the cart.")
@ApiResponses(value = {
@ApiResponse(code = HTTP_OK, message = HTTP_OK_MESSAGE, response = Cart.class),
@ApiResponse(code = HTTP_BAD_REQUEST, message = HTTP_BAD_REQUEST_MESSAGE, response = ErrorResponse.class),
@ApiResponse(code = HTTP_FORBIDDEN, message = HTTP_FORBIDDEN_MESSAGE, response = ErrorResponse.class),
@ApiResponse(code = HTTP_NOT_FOUND, message = HTTP_NOT_FOUND_MESSAGE, response = ErrorResponse.class)
})
Cart deleteCartEntry(
@ApiParam(value = "The ID of the cart.", required = true)
@PathParam("id") String id,
@ApiParam(value = "The cart entry id to be removed.", required = true)
@PathParam("cartEntryId") String cartEntryId,
@ApiParam(value = ACCEPT_LANGUAGE_DESC)
@HeaderParam(ACCEPT_LANGUAGE) String acceptLanguage);
@POST
@Consumes("application/json")
@Produces("application/json")
public MetaModelParview addVisualDependeciesForBusinessModelDriver(@PathParam("id") Integer id, MetaModelParview parameterViewObject) {
logger.debug("IN");
IMetaModelParviewDAO parameterViewDAO;
Integer newId = null;
Assert.assertNotNull(parameterViewObject, "Visual Dependencies can not be null");
try {
parameterViewDAO = DAOFactory.getMetaModelParviewDao();
newId = parameterViewDAO.insertMetaModelParview(parameterViewObject);
parameterViewObject.setId(newId);
} catch (HibernateException e) {
logger.error("Visual Dependencies can not be created", e);
throw new SpagoBIRestServiceException(e.getCause().getLocalizedMessage() + "in Visual Dependencsies", buildLocaleFromSession(), e);
}
logger.debug("OUT");
return parameterViewObject;
}
@JaxrsMethodDescribe(value = "列示当前用户的草稿对象,上一页.", action = ActionListPrev.class)
@GET
@Path("list/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("草稿标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPrev().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@GET
@Path("/schemas/{name}/branches")
@ApiOperation(value = "Get list of registered schema branches",
response = SchemaBranch.class, responseContainer = "List",
tags = OPERATION_GROUP_OTHER)
@Timed
@UnitOfWork
public Response getAllBranches(@ApiParam(value = "Details about schema name",required = true) @PathParam("name") String schemaName,
@Context UriInfo uriInfo,
@Context SecurityContext securityContext) {
try {
Collection<SchemaBranch> schemaBranches = authorizationAgent.authorizeGetAllBranches(AuthorizationUtils.getUserAndGroups(securityContext),
schemaRegistry, schemaName, schemaRegistry.getSchemaBranches(schemaName));
return WSUtils.respondEntities(schemaBranches, Response.Status.OK);
} catch(SchemaNotFoundException e) {
return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaName);
} catch (Exception ex) {
LOG.error("Encountered error while listing schema branches", ex);
return WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage());
}
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public int addNewMachine(@Context HttpServletRequest request, @PathParam("execution") int executionId,
MachineNode machine) {
log.debug("POST (" + request.getRemoteAddr() + ") - Add new machine to execution " + executionId);
if (null == machine) {
throw new WebApplicationException("Machine can't be null");
}
final Execution execution = executionRepository.findById(executionId);
StopWatch stopWatch = newStopWatch(log).start("Adding machine to execution");
execution.addMachine(machine);
stopWatch.stopAndLog();
stopWatch = newStopWatch(log).start("Publishing machine create event");
publisher.publishEvent(new MachineCreatedEvent(executionId, machine));
stopWatch.stopAndLog();
return execution.getMachines().indexOf(machine);
}
@GET
@POST
@Path("/id/{id}/map")
@Interceptors({RequiredInterceptor.class, ResponseInterceptor.class})
public QueryGeometryResponse map(@PathParam("id") @Required("id") String id) {
// Find out who/what called this method
DatawavePrincipal dp = null;
Principal p = ctx.getCallerPrincipal();
String user = p.getName();
if (p instanceof DatawavePrincipal) {
dp = (DatawavePrincipal) p;
user = dp.getShortName();
}
return queryGeometryHandler.getQueryGeometryResponse(id, queryHandler.query(user, id, dp).getResult());
}
@GET
@Path("/{code}/dictgroups")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getDictgroups(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user, @Context ServiceContext serviceContext,
@PathParam("code") String code, @BeanParam DataSearchModel query);
@GET
@Path("{id}")
@Produces("application/xml")
public Response getOrder(@PathParam("id") int id, @Context UriInfo uriInfo)
{
Order order = orderDB.get(id);
if (order == null)
{
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
Response.ResponseBuilder builder = Response.ok(order);
if (!order.isCancelled()) addCancelHeader(uriInfo, builder);
return builder.build();
}
@GET
@Path("{id}")
public Response get(@PathParam("id") Long id) {
final Optional<Issue> issueFound = service.get(id);
if (issueFound.isPresent()) {
return Response.ok(issueFound.get()).build();
}
return Response.status(Response.Status.NOT_FOUND).build();
}
@GET
@Produces("application/json")
@Consumes("application/json")
@Path(value = "/{code}/feeds")
public List<DataFeedInfo> findbyCollectionCode(@PathParam("code") String code,
@QueryParam("offset") Integer offset,
@QueryParam("limit") Integer limit){
offset = (offset != null) ? offset : Constants.DEFAULT_OFFSET;
limit = (limit != null) ? limit : Constants.DEFAULT_RECORD_LIMIT;
ApplicationContext appContext = new ClassPathXmlApplicationContext("spring/spring-servlet.xml");
DataFeedService dataFeedService = (DataFeedService) appContext.getBean("dataFeedService");
return dataFeedService.findbyCollectionCode(code, offset, limit);
}
@POST
@Path("/topologies/{topologyId}/testcases")
public Response addTestRunCase(@PathParam("topologyId") Long topologyId,
TopologyTestRunCase testRunCase,
@Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER,
Topology.NAMESPACE, topologyId, WRITE);
testRunCase.setTopologyId(topologyId);
Long currentVersionId = catalogService.getCurrentVersionId(topologyId);
testRunCase.setVersionId(currentVersionId);
TopologyTestRunCase addedCase = catalogService.addTopologyTestRunCase(testRunCase);
return WSUtils.respondEntity(addedCase, CREATED);
}
@PUT
@Path("{id}")
public Response update(@PathParam(value = "id") Long id, @Valid @BeanParam TaskForm form) {
log.log(Level.INFO, "updating existed [email protected]:{0}, form data:{1}", new Object[]{id, form});
if (validationResult.isFailed()) {
AlertMessage alert = AlertMessage.danger("Validation voilations!");
validationResult.getAllErrors()
.stream()
.forEach((ParamError t) -> {
alert.addError(t.getParamName(), "", t.getMessage());
});
models.put("errors", alert);
return Response.status(BAD_REQUEST).entity("edit.jsp").build();
}
Task task = taskRepository.findById(id);
task.setName(form.getName());
task.setDescription(form.getDescription());
taskRepository.update(task);
flashMessage.notify(Type.info, "Task was updated successfully!");
return Response.ok("redirect:tasks").build();
}
@Path("{firstParamConcrete}/properties")
@Override
public Response testParamInheritance(
@PathParam("firstParamConcrete") String firstParam,
String secondParam,
String thirdParam) {
return Response.ok().build();
}
/**
*
* @param confFileName
* confFileName is the file name of configuration like
* alertActionConfiguration.json, emailConfiguration.json
* @return json
*/
@GET
@Path("/defaultclusterconfiguration/{confFileName}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDefaultConfiguration(@PathParam("confFileName") final String confFileName) {
try {
String path = JumbuneInfo.getHome()
+ ConfigurationConstants.DEFAULT_CONFIGURATION_DIR + confFileName;
return Response.ok(FileUtil.readFileIntoString(path)).build();
} catch (Exception e) {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e).build();
}
}
@GET
@Path("/{tenant}/{namespace}/subscriptionDispatchRate")
@ApiOperation(value = "Get Subscription dispatch-rate configured for the namespace, -1 represents not configured yet")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Namespace does not exist") })
public DispatchRate getSubscriptionDispatchRate(@PathParam("tenant") String tenant,
@PathParam("namespace") String namespace) {
validateNamespaceName(tenant, namespace);
return internalGetSubscriptionDispatchRate();
}