下面列出了javax.ws.rs.core.MediaType#APPLICATION_XML 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* CONFIG endpoint is a dump of the system configuration in XML form. TODO: Convert the output to
* JSON form.
*/
@GET
@Path("/config")
@Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_XML})
public Response config() {
final NameNodeLoader nnLoader = (NameNodeLoader) context.getAttribute(NNA_NN_LOADER);
try {
before();
String key = request.getParameter("key");
if (key != null && !key.isEmpty()) {
return Response.ok(nnLoader.getConfigValue(key), MediaType.TEXT_PLAIN).build();
} else {
nnLoader.dumpConfig(response);
return Response.ok().type(MediaType.APPLICATION_XML).build();
}
} catch (Exception ex) {
return handleException(ex);
} finally {
after();
}
}
/**
* Import a resource in the repository
*
* @response.representation.mediaType multipart/form-data
* @response.representation.doc The file, its name and the resourcename
* @response.representation.200.qname {http://www.example.com}repositoryEntryVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc Import the resource and return the repository entry
* @response.representation.200.example {@link org.olat.connectors.rest.support.vo.Examples#SAMPLE_REPOENTRYVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param filename
* The name of the imported file
* @param file
* The file input stream
* @param resourcename
* The name of the resource
* @param displayname
* The display name
* @param softkey
* The soft key (can be null)
* @param request
* The HTTP request
* @return
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.MULTIPART_FORM_DATA })
public Response putResource(@FormParam("filename") final String filename, @FormParam("file") final InputStream file,
@FormParam("resourcename") final String resourcename, @FormParam("displayname") final String displayname, @FormParam("softkey") final String softkey,
@Context final HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
File tmpFile = null;
long length = 0;
try {
final Identity identity = RestSecurityHelper.getUserRequest(request).getIdentity();
tmpFile = getTmpFile(filename);
FileUtils.save(file, tmpFile);
FileUtils.closeSafely(file);
length = tmpFile.length();
if (length > 0) {
final RepositoryEntry re = importFileResource(identity, tmpFile, resourcename, displayname, softkey);
final RepositoryEntryVO vo = ObjectFactory.get(re);
return Response.ok(vo).build();
}
return Response.serverError().status(Status.NO_CONTENT).build();
} catch (final Exception e) {
log.error("Error while importing a file", e);
} finally {
if (tmpFile != null && tmpFile.exists()) {
tmpFile.delete();
}
}
return Response.serverError().status(Status.INTERNAL_SERVER_ERROR).build();
}
@GET
@Path("/nodes/{nodeId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public NodeInfo getNode(@PathParam("nodeId") String nodeId) {
init();
if (nodeId == null || nodeId.isEmpty()) {
throw new NotFoundException("nodeId, " + nodeId + ", is empty or null");
}
ResourceScheduler sched = this.rm.getResourceScheduler();
if (sched == null) {
throw new NotFoundException("Null ResourceScheduler instance");
}
NodeId nid = ConverterUtils.toNodeId(nodeId);
RMNode ni = this.rm.getRMContext().getRMNodes().get(nid);
boolean isInactive = false;
if (ni == null) {
ni = this.rm.getRMContext().getInactiveRMNodes().get(nid.getHost());
if (ni == null) {
throw new NotFoundException("nodeId, " + nodeId + ", is not found");
}
isInactive = true;
}
NodeInfo nodeInfo = new NodeInfo(ni, sched);
if (isInactive) {
nodeInfo.setNodeHTTPAddress(EMPTY);
}
return nodeInfo;
}
@GET
@Path("/{id}/nextactions/{actionId}/payload")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get List Actions", response = ActionResultModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns list action can be executed", response = ActionResultModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response getActionPayload(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @BeanParam DossierActionSearchModel query,
@PathParam("id") String id, @PathParam("actionId") String actionId);
@PUT
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "update Deliverabletypes")
@ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns", response = DeliverableTypesModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateDeliverableType(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @BeanParam DeliverableTypeInputModel input,
@ApiParam(value = "id of dossier", required = true) @PathParam("id") long id);
/**
* verify if an artifact is available locally if not download from proxies will be try
*
* @since 1.4-M3
*/
@Path("artifactAvailable/{g}/{a}/{v}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@RedbackAuthorization(noPermission = true, noRestriction = true)
AvailabilityStatus artifactAvailable( @PathParam("g") String groupId, @PathParam("a") String artifactId,
@PathParam("v") String version, @QueryParam("repositoryId") String repositoryId )
throws ArchivaRestServiceException;
/**
* @return a sample user list
* */
@GET
@Path("/")
@Produces(MediaType.APPLICATION_XML)
RESTFullUserGroupList getList(@QueryParam("nameLike") String nameLike,
@QueryParam("page") Integer page,
@QueryParam("entries") Integer entries) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;
@POST
@Path("/{id}/forceresync")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Add a Dossier", response = DossierDetailModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns a Dossier was created", response = DossierDetailModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })
public Response forceResyncDossier(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") String id);
@PUT
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@ApiOperation(value = "Update a applicant", response = ApplicantModel.class)
@ApiResponses(value = {
@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the applicant was updated", response = ApplicantModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response updateApplicant(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @PathParam("id") long id,
@BeanParam ApplicantInputUpdateModel input);
@GET
@Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getLinks(@Context final UriInfo uriInfo) {
logger.debug("Get link for file controller on file: {}", file.getPath());
final ResourceSupport dto = new ResourceSupport();
dto.add(UriUtil.generateSelfLink(uriInfo));
return Response.ok(dto).build();
}
@Path ( "deleteProxyConnectorRule" )
@POST
@Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
ActionStatus deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule )
throws ArchivaRestServiceException;
@GET
@Path("/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts/{attemptid}/counters")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public JobTaskAttemptCounterInfo getJobTaskAttemptIdCounters(
@Context HttpServletRequest hsr, @PathParam("jobid") String jid,
@PathParam("taskid") String tid, @PathParam("attemptid") String attId) {
init();
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
checkAccess(job, hsr);
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
TaskAttempt ta = AMWebServices.getTaskAttemptFromTaskAttemptString(attId,
task);
return new JobTaskAttemptCounterInfo(ta);
}
/**
* Pulls the matching user, group, any object or linked account from the External Resource into Syncope.
*
* @param query query conditions
* @param pullTask pull specification
*/
@ApiResponses(
@ApiResponse(responseCode = "204", description = "Operation was successful"))
@POST
@Path("pull")
@Consumes({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
void pull(@BeanParam ReconQuery query, @NotNull PullTaskTO pullTask);
@Path( "setUiConfiguration" )
@POST
@Consumes( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML} )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
void setUiConfiguration( UiConfiguration uiConfiguration )
throws ArchivaRestServiceException;
/**
* Gets an specific enforcements given a agreementId If the enforcementJob
* it is not in the database, it returns 404 with empty payload
*
*
* <pre>
* GET /enforcements/{agreementId}
*
* Request:
* GET /enforcements HTTP/1.1
*
* Response:
*
* {@code
* <?xml version="1.0" encoding="UTF-8"?>
*
* <enforcement_job>
* <agreement_id>agreement04</agreement_id>
* <enabled>false</enabled>
* </enforcement_job>
*
* }
*
* </pre>
*
* Example: <li>curl
* http://localhost:8080/sla-service/enforcements/agreement04</li>
*
* @param agreementId
* of the enforcementJob
* @return XML information with the different details of the enforcementJob
*/
@GET
@Path("{agreementId}")
@Produces(MediaType.APPLICATION_XML)
public Response getEnforcementJobByAgreementId(@PathParam("agreementId") String agreementId){
logger.debug("StartOf getEnforcementJobByAgreementId - REQUEST for /enforcementJobs/" + agreementId);
try {
EnforcementJobHelper enforcementJobService = getHelper();
String serializedEnforcement = enforcementJobService.getEnforcementJobByUUID(agreementId);
if (serializedEnforcement!=null){
logger.debug("EndOf getEnforcementJobByAgreementId");
return buildResponse(200, serializedEnforcement);
}else{
logger.debug("EndOf getEnforcementJobByAgreementId");
return buildResponse(404, printError(404, "There is no enforcement with uuid " + agreementId
+ " in the SLA Repository Database"));
}
} catch (HelperException e) {
logger.info("getEnforcementJobByAgreementId exception:"+e.getMessage());
return buildResponse(e);
}
}
/**
* Deletes an agreement, passing the corresponding agreement_id as
* parameter.
*
*
* <pre>
* DELETE /agreements/{agreement_id}
*
* Request:
* DELETE /agreements HTTP/1.1
*
* Response:
* HTTP/1.1 200 Ok
* Content-type: application/xml
*
* {@code
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <message code="201" message= "The agreement has been deleted successfully in the SLA Repository Database"/>
* }
*
* </pre>
*
* Example:
* <li>curl -X DELETE
* localhost:8080/sla-service/agreements/agreement04</li>
*
* @throws Exception
*/
@DELETE
@Path("{agreementId}")
@Produces(MediaType.APPLICATION_XML)
public Response deleteAgreement(@PathParam("agreementId") String agreementId){
logger.debug("DELETE /agreements/" + agreementId);
AgreementHelper agreementRestService = getAgreementHelper();
boolean deleted = agreementRestService.deleteByAgreementId(agreementId);
if (deleted)
return buildResponse(
204,
printMessage(204, "The agreement with id:" + agreementId
+ " was deleted successfully"));
else
return buildResponse(
404,
printError(404, "There is no agreement with id "
+ agreementId + " in the SLA Repository Database"));
}
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.TEXT_PLAIN)
public String post(Bar bar) {
return bar.name + " " + bar.description;
}
/**
* @deprecated used for testing only
*/
@POST
@Path("/groups")
@Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML})
void setUserGroups(@Multipart("groups")RESTFullUserGroupList groups)
throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx;
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getOfficeSites(@Context HttpServletRequest request, @Context HttpHeaders header,
@Context Company company, @Context Locale locale, @Context User user,
@Context ServiceContext serviceContext, @BeanParam DataSearchModel query);
/**
* Returns connector object from the external resource, for the given type and key.
*
* @param key name of resource to read connector object from
* @param anyTypeKey any object type
* @param value if value looks like a UUID then it is interpreted as user, group or any object key, otherwise
* as key value on the resource
* @return connector object from the external resource, for the given type and key
*/
@GET
@Path("{key}/{anyTypeKey}/{value}")
@Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
ConnObjectTO readConnObject(
@NotNull @PathParam("key") String key,
@NotNull @PathParam("anyTypeKey") String anyTypeKey,
@NotNull @PathParam("value") String value);