List of usage examples for org.springframework.http MediaType TEXT_PLAIN_VALUE
String TEXT_PLAIN_VALUE
To view the source code for org.springframework.http MediaType TEXT_PLAIN_VALUE.
Click Source Link
From source file:com.seajas.search.bridge.contender.metadata.SeajasEntry.java
/** * Set the textual description.//from ww w. ja v a2 s . co m * * @param value */ public void setDescriptionText(final String value) { SyndContent description = new SyndContentImpl(); description.setValue(value); description.setType(MediaType.TEXT_PLAIN_VALUE); super.setDescription(description); }
From source file:org.oncoblocks.centromere.web.controller.CrudApiController.java
/** * {@code POST /}/*from w ww .j a va 2 s . com*/ * Attempts to create a new record using the submitted entity. Throws an exception if the * entity already exists. * * @param entity entity representation to be persisted * @return updated representation of the submitted entity */ @RequestMapping(value = "", method = RequestMethod.POST, 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<?> create(@RequestBody T entity, HttpServletRequest request) { T created = getRepository().insert(entity); if (created == null) throw new RequestFailureException(40003, "There was a problem creating the record.", "", ""); if (ApiMediaTypes.isHalMediaType(request.getHeader("Accept"))) { FilterableResource resource = getAssembler().toResource(created); return new ResponseEntity<>(resource, HttpStatus.CREATED); } else { return new ResponseEntity<>(created, HttpStatus.CREATED); } }
From source file:com.boyuanitsm.fort.web.rest.AccountResource.java
/** * POST /register : register the user.//from www .ja v a2 s . co m * * @param managedUserDTO the managed user DTO * @param request the HTTP request * @return the ResponseEntity with status 201 (Created) if the user is registred or 400 (Bad Request) if the login or e-mail is already in use */ @RequestMapping(value = "/register", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @Timed public ResponseEntity<?> registerAccount(@Valid @RequestBody ManagedUserDTO managedUserDTO, HttpServletRequest request) { HttpHeaders textPlainHeaders = new HttpHeaders(); textPlainHeaders.setContentType(MediaType.TEXT_PLAIN); return userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase()) .map(user -> new ResponseEntity<>("login already in use", textPlainHeaders, HttpStatus.BAD_REQUEST)) .orElseGet(() -> userRepository.findOneByEmail(managedUserDTO.getEmail()) .map(user -> new ResponseEntity<>("e-mail address already in use", textPlainHeaders, HttpStatus.BAD_REQUEST)) .orElseGet(() -> { User user = userService.createUserInformation(managedUserDTO.getLogin(), managedUserDTO.getPassword(), managedUserDTO.getFirstName(), managedUserDTO.getLastName(), managedUserDTO.getEmail().toLowerCase(), managedUserDTO.getLangKey()); String baseUrl = request.getScheme() + // "http" "://" + // "://" request.getServerName() + // "myhost" ":" + // ":" request.getServerPort() + // "80" request.getContextPath(); // "/myContextPath" or "" if deployed in root context mailService.sendActivationEmail(user, baseUrl); return new ResponseEntity<>(HttpStatus.CREATED); })); }
From source file:su90.mybatisdemo.web.endpoints.EmployeesEndpoints.java
@RequestMapping(value = "/set/", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE }, produces = { MediaType.TEXT_PLAIN_VALUE }) @ApiOperation(value = "create one employee if possible") public ResponseEntity<Void> createEmployee(@RequestBody EmployeeIn employeeIn) { if (employeeIn.email == null) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); }//w ww . j a v a 2 s .com if (employeesService.hasEntityWithEmail(employeeIn.email)) { return new ResponseEntity<>(HttpStatus.CONFLICT); } if (employeeIn.job_id != null && jobsService.getEntryById(employeeIn.job_id) == null) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } if (employeeIn.manager_id != null && employeesService.getEntryById(employeeIn.manager_id) == null) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } if (employeeIn.department_id != null && departmentsService.getEntryById(employeeIn.department_id) == null) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } Long thekey = employeesService.saveEntry(employeeIn.getDomain()); if (thekey != null) { HttpHeaders headers = new HttpHeaders(); headers.setLocation( UriUtils.generateUri(MvcUriComponentsBuilder.on(EmployeesEndpoints.class).getOne(thekey))); return new ResponseEntity<>(headers, HttpStatus.CREATED); } else { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } }
From source file:org.calrissian.restdoclet.example.spring.ExampleController.java
/** * Retrieves the stored color for a particular user. * * @param userId user id of the user.//from ww w. j a va 2 s. c o m * @param normalize Determines whether the result will be standardized * @pathVar name Name of the user to retrieve the color for * @queryParam normalize If set to "true" the name of the color will be normalized before being returned. */ @RequestMapping(value = "/user/{name}/color", produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody public String getColor(@PathVariable("name") String userId, @RequestParam(required = false) boolean normalize) { if (!userColors.containsKey(userId)) return ""; return (normalize ? userColors.get(userId).toLowerCase() : userColors.get(userId)); }
From source file:org.awesomeagile.integrations.hackpad.HackpadClientTest.java
@Test public void testCreateHackpad() { mockServer.expect(requestTo("http://test/api/1.0/pad/create")).andExpect(method(HttpMethod.POST)) .andExpect(header(HTTP.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE)) .andExpect(content().string("The Title")) .andRespond(withSuccess("{\"padId\":\"C0E68BD495E9\"}", MediaType.APPLICATION_JSON)); PadIdentity id = client.createHackpad("The Title"); assertEquals("C0E68BD495E9", id.getPadId()); }
From source file:de.codecentric.boot.admin.actuate.LogfileMvcEndpoint.java
@RequestMapping(method = RequestMethod.GET) public void invoke(HttpServletResponse response) throws IOException { if (!isAvailable()) { response.setStatus(HttpStatus.NOT_FOUND.value()); return;//w w w .ja va2s . c o m } Resource file = new FileSystemResource(logfile); response.setContentType(MediaType.TEXT_PLAIN_VALUE); response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getFilename() + "\""); FileCopyUtils.copy(file.getInputStream(), response.getOutputStream()); }
From source file:org.zalando.logbook.servlet.example.ExampleController.java
@RequestMapping(value = "/stream", produces = MediaType.TEXT_PLAIN_VALUE) public void stream(final HttpServletRequest request, final HttpServletResponse response) throws IOException { ByteStreams.copy(request.getInputStream(), response.getOutputStream()); }
From source file:org.bonitasoft.web.designer.controller.AssetResource.java
@RequestMapping(value = "/{artifactId}/assets/{type}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) public ResponseEntity<Asset> saveOrUpdate(@RequestParam("file") MultipartFile file, @PathVariable("artifactId") String id, @PathVariable("type") String type) { checkArtifactId(id);//from ww w .ja va 2s. c o m Asset asset = assetService.upload(file, repository.get(id), type); return new ResponseEntity<>(asset, HttpStatus.CREATED); }
From source file:org.bonitasoft.web.designer.controller.ImportController.java
@RequestMapping(value = "/import/{artifactType}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseStatus(HttpStatus.CREATED)/*from w w w . j av a 2 s . c o m*/ @ResponseBody public ImportReport importArtifact(@RequestParam("file") MultipartFile file, @RequestParam(value = "force", defaultValue = "false", required = false) boolean force, @PathVariable(value = "artifactType") String artifactType) { checkFilePartIsPresent(file); checkFileIsZip(file); Path extractDir = unzip(file); ArtifactImporter importer = getArtifactImporter(artifactType, extractDir); if (force) { return pathImporter.forceImportFromPath(extractDir, importer); } return pathImporter.importFromPath(extractDir, importer); }