List of usage examples for org.springframework.http MediaType APPLICATION_XML_VALUE
String APPLICATION_XML_VALUE
To view the source code for org.springframework.http MediaType APPLICATION_XML_VALUE.
Click Source Link
From source file:com.orange.ngsi.server.NgsiRestBaseController.java
@RequestMapping(method = RequestMethod.PUT, value = { "/contextEntities/{entityID}", "/contextEntities/{entityID}/attributes" }, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) final public ResponseEntity<UpdateContextElementResponse> updateContextEntity(@PathVariable String entityID, @RequestBody UpdateContextElement updateContextElement, HttpServletRequest httpServletRequest) throws Exception { ngsiValidation.checkUpdateContextElement(updateContextElement); registerIntoDispatcher(httpServletRequest); return new ResponseEntity<>(updateContextElement(entityID, updateContextElement), HttpStatus.OK); }
From source file:com.orange.ngsi.server.NgsiBaseController.java
@RequestMapping(value = "/registerContext", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) final public ResponseEntity<RegisterContextResponse> registerContextRequest( @RequestBody final RegisterContext registerContext, HttpServletRequest httpServletRequest) throws Exception { ngsiValidation.checkRegisterContext(registerContext); registerIntoDispatcher(httpServletRequest); return new ResponseEntity<>(registerContext(registerContext), HttpStatus.OK); }
From source file:za.org.opengov.ussd.controller.cm.CMUssdController.java
/** * This would be called via a USSD gateway, as an HTTP message, with a GET * method, and various headers with values. * //from ww w .j a v a 2 s . com * The address to call this service would be: * * [host-address]:8080/opengov/ussd/cm/{service name} * * For example * * http://localhost:8080/opengov/ussd/cm/stockout * * Be sure to include necessary headers. * * @param ussdRequest * @return Response body, which includes requestID and display text. */ @RequestMapping(value = "{ussdServiceTag}", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE) public @ResponseBody CMUssdResponse callService(@RequestHeader(value = "msisdn") String msisdn, @RequestHeader(value = "provider") String provider, @RequestHeader(value = "ussdSessionId") String ussdSessionID, @RequestHeader(value = "request") String request, @RequestHeader(value = "requestid") String requestID, @PathVariable String ussdServiceTag) { // just for testing logger.info("USSD service called: " + "\n Invoking USSD service: " + ussdServiceTag + "\n Received cell number: " + msisdn + "\n Provider: " + provider + "\n USSD Session ID: " + ussdSessionID + "\n Request String: " + request + "\n Request ID: " + requestID); // construct request object from HTTP headers CMUssdRequest ussdRequest = new CMUssdRequest(msisdn, provider, ussdSessionID, request, requestID); // delegates to service tier CMUssdResponse response = delegateToServices(ussdServiceTag, ussdRequest); return response; }
From source file:example.users.UserController.java
/** * Returns the payload of {@link #getXml()} wrapped into another XML element to simulate a change in the * representation structure./*from w ww . j a va 2s . c o m*/ * * @return */ @GetMapping(path = "/changed", produces = MediaType.APPLICATION_XML_VALUE) String getChangedXml() { return "<user><username>".concat(XML_PAYLOAD).concat("</username></user>"); }
From source file:ca.qhrtech.services.implementations.BGGServiceImpl.java
private HttpEntity<?> buildXmlHttpHeader() { HttpHeaders headers = new HttpHeaders(); headers.add("Accept", MediaType.APPLICATION_XML_VALUE); return new HttpEntity<>(headers); }
From source file:se.skltp.cooperation.web.rest.v1.controller.ServiceDomainController.java
/** * GET /serviceDomains -> get all the serviceDomains as xml *//*from ww w . ja v a 2 s .c o m*/ @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE) public ServiceDomainListDTO getAllAsXml(@RequestParam(required = false) String namespace) { log.debug("REST request to get all ServiceDomains as xml"); return new ServiceDomainListDTO(getAll(namespace)); }
From source file:org.oncoblocks.centromere.web.controller.ReadOnlyApiController.java
/** * {@code PUT /{id}}/* w w w .j av a2 s .c o m*/ * Attempts to update an existing entity record, replacing it with the submitted entity. Throws * an exception if the target entity does not exist. * * @return updated representation of the submitted entity. */ @RequestMapping(value = "/{id}", method = RequestMethod.PUT, produces = { MediaType.APPLICATION_JSON_VALUE, ApiMediaTypes.APPLICATION_HAL_JSON_VALUE, ApiMediaTypes.APPLICATION_HAL_XML_VALUE, MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_PLAIN_VALUE }) public HttpEntity<?> update(@RequestBody T entity, @PathVariable ID id, HttpServletRequest request) { throw new MethodNotAllowedException(); }
From source file:org.messic.server.facade.controllers.rest.SettingsController.java
@ApiMethod(path = "/services/settings", verb = ApiVerb.GET, description = "Get the user settings", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) @ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error"), @ApiError(code = NotAuthorizedMessicRESTException.VALUE, description = "Not authorized to obtain this info") }) @RequestMapping(value = "", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)/*from w w w.j a v a 2s. c o m*/ @ResponseBody protected User getUser() throws NotAuthorizedMessicRESTException, UnknownMessicRESTException { try { User user = SecurityUtil.getCurrentUser(); User result = userAPI.getUserByLogin(user.getLogin()); return result; } catch (NotAuthorizedMessicRESTException e) { throw new NotAuthorizedMessicRESTException(e); } catch (Exception e) { throw new UnknownMessicRESTException(e); } }
From source file:se.skltp.cooperation.web.rest.v1.controller.InstalledContractController.java
/** * GET /serviceContracts -> get all the serviceContracts. Content type: XML *///from w ww . ja v a 2 s. com @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE) public InstalledContractListDTO getAllAsXml(@RequestParam(required = false) Long connectionPointId, @RequestParam(required = false) Long serviceContractId, @RequestParam(required = false) Long serviceDomainId) { log.debug("REST request to get all ServiceContracts as xml"); InstalledContractListDTO result = new InstalledContractListDTO(); result.setInstalledContracts(getAll(connectionPointId, serviceContractId, serviceDomainId)); return result; }
From source file:org.messic.server.facade.controllers.pages.CaptchaController.java
@ApiMethod(path = "/captcha", verb = ApiVerb.GET, description = "Get a captcha", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) @ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error") }) @RequestMapping(value = "", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)//from www .jav a2 s. com @ResponseBody @ApiResponseObject public Captcha getCaptcha() throws UnknownMessicRESTException { try { UUID idOne = UUID.randomUUID(); // create the image with the text BufferedImage bi = service.getImageChallengeForID(idOne.toString()); BufferedImage bi2 = Util.ImagedeepCopy(bi); Graphics2D g2d = (Graphics2D) bi.getGraphics(); float alpha = 0.25f; int type = AlphaComposite.SRC_OVER; AlphaComposite composite = AlphaComposite.getInstance(type, alpha); g2d.setComposite(composite); final int Min = 5; final int Max = 30; int random1 = Min + (int) (Math.random() * ((Max - Min) + 1)); int random2 = Min + (int) (Math.random() * ((Max - Min) + 1)); g2d.drawImage(bi2, random1, random2, null); alpha = 0.80f; type = AlphaComposite.SRC_OVER; composite = AlphaComposite.getInstance(type, alpha); g2d.setComposite(composite); int MinX = 0; int MaxX = bi.getWidth(); int MinY = 0; int MaxY = bi.getHeight(); g2d.setColor(Color.black); for (int i = 0; i < random2; i++) { int random3 = MinX + (int) (Math.random() * ((MaxX - MinX) + 1)); int random4 = MinX + (int) (Math.random() * ((MaxX - MinX) + 1)); int random5 = MinY + (int) (Math.random() * ((MaxY - MinY) + 1)); int random6 = MinY + (int) (Math.random() * ((MaxY - MinY) + 1)); g2d.drawLine(random3, random5, random4, random6); } Captcha result = new Captcha(); result.id = idOne.toString(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(bi, "jpg", baos); byte[] resultb64 = Base64.encode(baos.toByteArray()); result.captchaImage = new String(resultb64); return result; } catch (Exception e) { throw new UnknownMessicRESTException(e); } }