Example usage for org.springframework.http HttpStatus NO_CONTENT

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

Introduction

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

Prototype

HttpStatus NO_CONTENT

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

Click Source Link

Document

204 No Content .

Usage

From source file:io.github.howiefh.jeews.modules.sys.controller.OrganizationController.java

@RequiresPermissions("organization:delete")
@RequestMapping(value = "", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteBatch(@RequestBody List<Long> ids) {
    organizationService.deleteBatch(ids);
}

From source file:io.github.howiefh.jeews.modules.oauth2.controller.ClientController.java

@RequiresPermissions("clients:delete")
@RequestMapping(value = "", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteBatch(@RequestBody List<Long> ids) {
    clientService.deleteBatch(ids);/*from  w w w .java  2s.co  m*/
}

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

/**
 * This operation is used to remove a disabled Network Service Descriptor
 *
 * @param id of Network Service Descriptor
 *///from  ww  w .  j a  v  a2  s  .c o  m
@RequestMapping(value = "{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void delete(@PathVariable("id") String id, @RequestHeader(value = "project-id") String projectId)
        throws WrongStatusException {
    networkServiceDescriptorManagement.delete(id, projectId);
}

From source file:com.wujiabo.opensource.feather.rest.controller.RbacRestController.java

@RequestMapping(value = "/group/{id}", method = RequestMethod.PUT, consumes = MediaTypes.JSON)
// Restful204??, . ?200??.
@ResponseStatus(HttpStatus.NO_CONTENT)
public void update(@RequestBody TGroup task) {
    // JSR303 Bean Validator, RestExceptionHandler?.
    RestValidation.validateWithException(validator, task);

    // ?//from ww w .  java2  s.c o m
    // taskService.saveTask(task);
}

From source file:com.ge.predix.acceptance.test.zone.admin.DefaultZoneAuthorizationIT.java

/**
 * 1. Create a token from zone issuer with scopes for accessing: a. zone specific resources, AND b.
 * acs.zones.admin//from ww w.  ja v  a  2 s.  c  o m
 *
 * 2. Try to access a zone specific resource . This should work 3. Try to access /v1/zone - THIS SHOULD FAIL
 *
 * @throws Exception
 */
public void testAccessGlobalResourceWithZoneIssuer() throws Exception {
    OAuth2RestTemplate zone2AcsTemplate = this.acsRestTemplateFactory.getACSZone2RogueTemplate();

    HttpHeaders zoneTwoHeaders = new HttpHeaders();
    zoneTwoHeaders.set(PolicyHelper.PREDIX_ZONE_ID, this.zoneHelper.getZone2Name());

    // Write a resource to zone2. This should work
    ResponseEntity<Object> responseEntity = this.privilegeHelper.postResources(zone2AcsTemplate,
            zoneHelper.getAcsBaseURL(), zoneTwoHeaders, new BaseResource("/sites/sanramon"));
    Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.NO_CONTENT);

    // Try to get global resource from global/baseUrl. This should FAIL
    try {
        zone2AcsTemplate.exchange(this.zoneHelper.getAcsBaseURL() + "/v1/zone/" + this.zone2Name,
                HttpMethod.GET, null, Zone.class);
        Assert.fail("Able to access non-zone specific resource with a zone specific issuer token!");
    } catch (OAuth2AccessDeniedException e) {
        // expected
    }

    // Try to get global resource from zone2Url. This should FAIL
    try {
        zone2AcsTemplate.exchange(this.zoneHelper.getAcsBaseURL() + "/v1/zone/" + this.zone2Name,
                HttpMethod.GET, new HttpEntity<>(zoneTwoHeaders), Zone.class);
        Assert.fail("Able to access non-zone specific resource from a zone specific URL, "
                + "with a zone specific issuer token!");
    } catch (InvalidRequestException e) {
        // expected
    }

}

From source file:uk.org.rbc1b.roms.controller.volunteer.update.VolunteerUpdateController.java

/**
 * Accepts and checks requests for updating contact when the volunteer puts
 * in his RBC ID and date of birth to trigger an email. There is no security
 * checks around this as this is initial request by the volunteer.
 *
 * @param form the user form//  w  w  w  .j  a v a2 s.  c  o  m
 * @throws TemplateException on failure to render the email
 * @throws IOException  on failure to render the email
 */
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptRequest(@Valid VolunteerUpdateRequestForm form) throws IOException, TemplateException {
    Volunteer volunteer = volunteerDao.findVolunteer(form.getPersonId(), null);
    if (volunteer == null) {
        throw new ResourceNotFoundException("No volunteer #" + form.getPersonId());
    }

    assertVolunteerInformationIsValid(volunteer);

    Date birthDate = DataConverterUtil.toSqlDate(form.getBirthDate());

    if (volunteer.getPerson().getBirthDate().compareTo(birthDate) != 0) {
        throw new ForbiddenRequestException("Birth date does not match");
    }

    Email email = volunteerUpdateEmailGenerator.generateVolunteerUpdateRequestEmail(volunteer);
    emailDao.save(email);
}

From source file:com.consol.citrus.samples.javaee.employee.EmployeeResourceTest.java

@Test
@InSequence(3)/*w ww  .  j  a  va2  s.c o  m*/
@CitrusTest
public void testPut(@CitrusResource TestDesigner citrus) {
    citrus.http().client(serviceUri).send().put().fork(true).contentType(MediaType.APPLICATION_FORM_URLENCODED)
            .payload("name=Howard&age=21&email=howard@example.com");

    citrus.http().client(serviceUri).receive().response(HttpStatus.NO_CONTENT);

    citrus.http().client(serviceUri).send().get().accept(MediaType.APPLICATION_XML);

    citrus.http().client(serviceUri).receive().response(HttpStatus.OK)
            .payload("<employees>" + "<employee>" + "<age>20</age>" + "<name>Penny</name>" + "</employee>"
                    + "<employee>" + "<age>21</age>" + "<name>Leonard</name>" + "</employee>" + "<employee>"
                    + "<age>22</age>" + "<name>Sheldon</name>" + "</employee>" + "<employee>" + "<age>21</age>"
                    + "<name>Howard</name>" + "<email>howard@example.com</email>" + "</employee>"
                    + "</employees>");

    citrusFramework.run(citrus.getTestCase());
}

From source file:curly.artifactory.ArtifactResourceControllerTests.java

@Test
public void testDeleteResource() throws Exception {
    String id = artifact.getId();
    mockMvc.perform(asyncDispatch(mockMvc.perform(delete("/arts/{id}", id).principal(octoUser()))
            .andExpect(request().asyncStarted())
            .andExpect(request().asyncResult(new ResponseEntity<>(HttpStatus.NO_CONTENT))).andReturn()));
}

From source file:com.tsg.addressbookmvc.RESTController.java

@RequestMapping(value = "/address/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteAddress(@PathVariable("id") int id) {
    // remove the Address associated with the given id from the data layer
    dao.removeAddress(id);/*from  w  w w  .  j  a  va2  s . c  om*/

}

From source file:github.priyatam.springrest.resource.PolicyResource.java

@RequestMapping(method = RequestMethod.HEAD, value = "/policy/{policyNum}")
@ResponseBody/*w w  w .  j av  a 2s . c  om*/
public ResponseEntity<Policy> head(HttpServletRequest request, @PathVariable String policyNum) {
    logger.debug("Requested head for: " + policyNum);
    // / String url = ServletUriComponentsBuilder.fromRequest(request).build().toString();
    try {
        String tag = eTagHelper.get(vhost + URLS.POLICY.expand(policyNum));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Etag", tag);
        return new ResponseEntity<Policy>(null, headers, HttpStatus.NO_CONTENT);
    } catch (InvalidTagException e) {
        return new ResponseEntity<Policy>(HttpStatus.NOT_FOUND);
    }
}