Example usage for org.springframework.http HttpStatus CREATED

List of usage examples for org.springframework.http HttpStatus CREATED

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus CREATED.

Prototype

HttpStatus CREATED

To view the source code for org.springframework.http HttpStatus CREATED.

Click Source Link

Document

201 Created .

Usage

From source file:org.openbaton.nfvo.api.RestNetworkServiceDescriptor.java

/**
 * This operation allows submitting and validating a Network Service Descriptor (NSD), including
 * any related VNFFGD and VLD.//w ww  .  ja  v  a  2 s  .com
 *
 * @param networkServiceDescriptor : the Network Service Descriptor to be created
 * @return networkServiceDescriptor: the Network Service Descriptor filled with id and values from
 * core
 */
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public NetworkServiceDescriptor create(@RequestBody @Valid NetworkServiceDescriptor networkServiceDescriptor,
        @RequestHeader(value = "project-id") String projectId) throws NotFoundException, BadFormatException,
        NetworkServiceIntegrityException, CyclicDependenciesException {
    NetworkServiceDescriptor nsd;
    log.trace("Just Received: " + networkServiceDescriptor);
    nsd = networkServiceDescriptorManagement.onboard(networkServiceDescriptor, projectId);
    return nsd;
}

From source file:org.jasig.portlet.notice.controller.rest.JPANotificationRESTController.java

/**
 * Create a notification.// w  w w.  ja  va2 s.c om
 *
 * @param req the Http request
 * @param response the Http response
 * @param entry The Entry
 * @return The persisted entry
 */
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
public EntryDTO createNotification(HttpServletRequest req, HttpServletResponse response,
        @RequestBody EntryDTO entry) {
    EntryDTO persisted = restService.createNotification(entry);

    String url = getSingleNotificationRESTUrl(req, persisted.getId());
    response.addHeader("Location", url);

    return persisted;
}

From source file:org.kuali.mobility.emergencyinfo.controllers.EmergencyInfoController.java

@RequestMapping(value = "/collection", method = RequestMethod.POST, headers = "Accept=application/json")
public ResponseEntity<String> postAll(@RequestBody String json) {
    for (EmergencyInfo emergencyInfo : emergencyInfoService.fromJsonToCollection(json)) {
        emergencyInfoService.saveEmergencyInfo(emergencyInfo);
    }/*from w  w  w.j a  v a2s.  co  m*/
    return new ResponseEntity<String>(HttpStatus.CREATED);
}

From source file:ca.qhrtech.controllers.TableController.java

@RequestMapping(value = "/table", method = RequestMethod.POST)
public ResponseEntity<BGLTable> createTable(@RequestBody BGLTable table) {
    if (!tableService.doesTableExist(table)) {
        BGLTable newTable = tableService.saveTable(table);
        return new ResponseEntity<>(newTable, HttpStatus.CREATED);
    }// w  w  w  . j  av a2  s.co  m
    return new ResponseEntity<>(HttpStatus.CONFLICT);
}

From source file:org.osiam.addons.selfadministration.registration.RegistrationController.java

@RequestMapping(method = RequestMethod.POST)
public String register(@Valid @ModelAttribute final RegistrationUser registrationUser,
        final BindingResult bindingResult, final Model model, final HttpServletRequest request,
        final HttpServletResponse response) {

    userValidator.validate(registrationUser, bindingResult);
    if (bindingResult.hasErrors()) {
        model.addAttribute("allowedFields", registrationService.getAllAllowedFields());
        response.setStatus(HttpStatus.BAD_REQUEST.value());
        return "registration";
    }/*from   w  w  w. j a v a 2  s .co m*/

    User user = registrationService.saveRegistrationUser(registrationUser);
    registrationService.sendRegistrationEmail(user, request);

    model.addAttribute("user", user);

    response.setStatus(HttpStatus.CREATED.value());
    return "registrationSuccess";
}

From source file:net.maritimecloud.identityregistry.controllers.LogoController.java

/**
 * Creates or updates a logo for an organization
 * @param request request to get servletPath
 * @param orgMrn resource location for organization
 * @param logo the log encoded as a MultipartFile
 * @throws McBasicRestException/*from   www.j  a  v a  2 s.  c  om*/
 */
@RequestMapping(value = "/api/org/{orgMrn}/logo", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasRole('ORG_ADMIN') and @accessControlUtil.hasAccessToOrg(#orgMrn)")
public ResponseEntity<?> createLogoPost(HttpServletRequest request, @PathVariable String orgMrn,
        @RequestParam("logo") MultipartFile logo) throws McBasicRestException {
    Organization org = this.organizationService.getOrganizationByMrn(orgMrn);
    if (org != null) {
        try {
            this.updateLogo(org, logo.getInputStream());
            organizationService.save(org);
            return new ResponseEntity<>(HttpStatus.CREATED);
        } catch (IOException e) {
            log.error("Unable to create logo", e);
            throw new McBasicRestException(HttpStatus.BAD_REQUEST, MCIdRegConstants.INVALID_IMAGE,
                    request.getServletPath());
        }
    } else {
        throw new McBasicRestException(HttpStatus.NOT_FOUND, MCIdRegConstants.ORG_NOT_FOUND,
                request.getServletPath());
    }
}

From source file:nu.yona.server.batch.quartz.TriggerController.java

@RequestMapping(value = "/cron/{group}/", method = RequestMethod.POST)
@ResponseBody//w  w w  .  ja  va  2 s.c o m
@ResponseStatus(HttpStatus.CREATED)
public TriggerResource addTrigger(@PathVariable String group, @RequestBody CronTriggerDto trigger) {
    trigger.setGroup(group);
    return new TriggerResourceAssembler().toResource(triggerManagementService.addTrigger(group, trigger));
}

From source file:org.kuali.mobility.configparams.controllers.ConfigParamController.java

@RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
public ResponseEntity<String> post(@RequestBody String json) {
    ConfigParam cp = configParamService.fromJsonToEntity(json);
    if (cp.getName() != null && cp.getValue() != null && cp.getName().length() > 0
            && cp.getValue().length() > 0) {
        Long id = configParamService.saveConfigParam(cp);
        if (id == null) {
            return new ResponseEntity<String>(HttpStatus.NOT_MODIFIED);
        }//from   w  w w.  j  a  v a  2  s. co m
        return new ResponseEntity<String>(HttpStatus.CREATED);
    }
    return new ResponseEntity<String>(HttpStatus.NOT_MODIFIED);
}

From source file:org.trustedanalytics.examples.hbase.api.ApiController.java

@RequestMapping(method = RequestMethod.POST, value = "/tables/{name}/row", consumes = "application/json")
@ResponseStatus(HttpStatus.CREATED)
public void putRow(@PathVariable(value = "name") String name, @RequestBody RowValue rowValue)
        throws IOException, LoginException {
    LOG.info("put for {}, {}.", name, rowValue);
    hbaseService.putRow(name, rowValue);
}

From source file:org.ow2.proactive.workflow_catalog.rest.controller.WorkflowController.java

@ApiOperation(value = "Creates a new workflow")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Bucket not found"),
        @ApiResponse(code = 422, message = "Invalid XML workflow content supplied") })
@RequestMapping(value = "/buckets/{bucketId}/workflows", consumes = {
        MediaType.MULTIPART_FORM_DATA_VALUE }, method = POST)
@ResponseStatus(HttpStatus.CREATED)
public WorkflowMetadataList create(@PathVariable Long bucketId,
        @ApiParam(value = "Layout describing the tasks position in the Workflow") @RequestParam(required = false) Optional<String> layout,
        @ApiParam(value = "Import workflows from ZIP when set to 'zip'.") @RequestParam(required = false) Optional<String> alt,
        @RequestPart(value = "file") MultipartFile file) throws IOException {
    if (alt.isPresent() && ZIP_EXTENSION.equals(alt.get())) {
        return new WorkflowMetadataList(workflowService.createWorkflows(bucketId, layout, file.getBytes()));
    } else {/*from  w ww.  ja v a 2 s  .c  o  m*/
        return new WorkflowMetadataList(workflowService.createWorkflow(bucketId, layout, file.getBytes()));
    }
}