javax.ws.rs.core.MediaType#APPLICATION_XML源码实例Demo

下面列出了javax.ws.rs.core.MediaType#APPLICATION_XML 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: NNAnalytics   文件: NamenodeAnalyticsMethods.java
/**
 * 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();
  }
}
 
源代码2 项目: olat   文件: RepositoryEntriesResource.java
/**
 * 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();
}
 
源代码3 项目: hadoop   文件: RMWebServices.java
@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;
}
 
源代码4 项目: opencps-v2   文件: DossierActionManagement.java
@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);
 
源代码5 项目: opencps-v2   文件: DeliverableTypesManagement.java
@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);
 
源代码6 项目: archiva   文件: BrowseService.java
/**
 * 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;
 
源代码7 项目: geofence   文件: RESTUserGroupService.java
/**
 * @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;
 
源代码8 项目: opencps-v2   文件: DossierManagement.java
@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);
 
源代码9 项目: opencps-v2   文件: ApplicantManagement.java
@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);
 
源代码10 项目: container   文件: FileController.java
@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();
}
 
源代码11 项目: archiva   文件: ProxyConnectorRuleService.java
@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;
 
源代码12 项目: big-c   文件: HsWebServices.java
@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);
}
 
源代码13 项目: syncope   文件: ReconciliationService.java
/**
 * 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);
 
源代码14 项目: archiva   文件: ArchivaAdministrationService.java
@Path( "setUiConfiguration" )
@POST
@Consumes( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML} )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
void setUiConfiguration( UiConfiguration uiConfiguration )
    throws ArchivaRestServiceException;
 
源代码15 项目: SeaCloudsPlatform   文件: EnforcementJobRest.java
/**
 * 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);
    }
}
 
源代码16 项目: SeaCloudsPlatform   文件: AgreementRest.java
/**
 * 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"));
    
}
 
源代码17 项目: quarkus   文件: ConsumesXMLTestCase.java
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.TEXT_PLAIN)
public String post(Bar bar) {
    return bar.name + " " + bar.description;
}
 
源代码18 项目: geofence   文件: RESTConfigService.java
/**
 * @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;
 
源代码19 项目: opencps-v2   文件: OfficeSiteManagement.java
@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);
 
源代码20 项目: syncope   文件: ResourceService.java
/**
 * 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);