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:org.bozzo.ipplan.web.SubnetController.java

@RequestMapping(value = "/{subnetId}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteSubnet(@PathVariable Integer infraId, @PathVariable Long subnetId,
        @RequestParam(required = false) DeleteMode mode) {
    logger.info("delete subnet with id: {} (infra id: {})", subnetId, infraId);
    this.service.deleteByInfraIdAndId(mode, infraId, subnetId);
}

From source file:net.eusashead.hateoas.response.argumentresolver.AsyncEntityControllerITCase.java

@Test
public void testPut() throws Exception {

    // Expected result
    HttpHeaders headers = new HttpHeaders();
    headers.setETag("W/\"b0c689597eb9dd62c0a1fb90a7c5c5a5\"");
    ResponseEntity<Entity> expectedResult = new ResponseEntity<Entity>(headers, HttpStatus.NO_CONTENT);

    // Execute asynchronously
    MvcResult mvcResult = this.mockMvc
            .perform(put("http://localhost/async/foo").content(mapper.writeValueAsBytes(new Entity("foo")))
                    .contentType(MediaType.APPLICATION_JSON)
                    .characterEncoding(Charset.forName("UTF-8").toString()).accept(MediaType.APPLICATION_JSON))
            .andExpect(request().asyncStarted()).andExpect(request().asyncResult(expectedResult)).andReturn();

    // Perform asynchronous dispatch
    this.mockMvc.perform(asyncDispatch(mvcResult)).andDo(print()).andExpect(status().isNoContent());

}

From source file:org.bozzo.ipplan.web.AddressController.java

@RequestMapping(value = "/{addressId}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteAddress(@PathVariable Integer infraId, @PathVariable Long subnetId,
        @PathVariable Long addressId) {
    logger.info("delete address with id: {} (infra id: {}, subnet id: {})", addressId, infraId, subnetId);
    this.repository.deleteBySubnetIdAndIp(subnetId, addressId);
}

From source file:com.expedia.seiso.web.controller.v2.ItemControllerV2.java

/**
 * Assigns an item to a given property./*from   www  .  j  av  a 2s  .c o  m*/
 * 
 * @param repoKey
 *            Repository key
 * @param itemKey
 *            Item key
 * @param propKey
 *            Property key
 * @param propItemKey
 *            Key for the item to assign to the property
 */
@RequestMapping(value = "/{repoKey}/{itemKey}/{propKey}", method = RequestMethod.PUT, consumes = MediaTypes.TEXT_URI_LIST_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void putProperty(@PathVariable String repoKey, @PathVariable String itemKey,
        @PathVariable String propKey, @RequestBody(required = false) ItemKey propItemKey) {

    delegate.putProperty(repoKey, itemKey, propKey, propItemKey);
}

From source file:za.ac.cput.project.universalhardwarestorev2.api.LoginApi.java

@RequestMapping(value = "/login/delete/{id}", method = RequestMethod.DELETE)
public ResponseEntity<Login> deleteLogin(@PathVariable("id") long id) {
    System.out.println("Fetching & Deleting Login with id " + id);

    Login login = service.findById(id);// w  ww. ja v a  2 s  . c  om
    if (login == null) {
        System.out.println("Unable to delete. Login with id " + id + " not found");
        return new ResponseEntity<Login>(HttpStatus.NOT_FOUND);
    }

    service.delete(login);
    return new ResponseEntity<Login>(HttpStatus.NO_CONTENT);
}

From source file:com.boundlessgeo.geoserver.api.controllers.WorkspaceController.java

@RequestMapping(value = "/{wsName:.+}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void delete(@PathVariable String wsName, HttpServletResponse response) {
    Catalog cat = geoServer.getCatalog();

    WorkspaceInfo ws = findWorkspace(wsName, cat);
    new CascadeDeleteVisitor(cat).visit(ws);

    recent.remove(WorkspaceInfo.class, ws);
}

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

/**
 * Handles update requests. There is no security checks around this because
 * it is done be the unauthenticated user. Security is added by hashed urls.
 *
 * @param volunteerId the person Id/*from www.  j a  v a  2 s .c o m*/
 * @param datetime the date and time of the original request
 * @param hash the hash
 * @param form the updated contact form
 * @throws TemplateException on failure to render the confirmation email
 * @throws IOException  on failure to render the confirmation email
 */
@RequestMapping(value = "/{volunteerId}/{datetime}/{hash}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptUpdate(@PathVariable Integer volunteerId, @PathVariable String datetime,
        @PathVariable String hash, @Valid VolunteerUpdateForm form) throws IOException, TemplateException {
    Volunteer volunteer = volunteerDao.findVolunteer(volunteerId, null);
    if (volunteer == null) {
        throw new ResourceNotFoundException("No volunteer #" + volunteerId);
    }

    if (!checkHash(volunteer, datetime, hash)) {
        throw new ForbiddenRequestException("Mismatched request hash");
    }
    if (!checkWithinTime(datetime)) {
        throw new ForbiddenRequestException("Expired request hash");
    }

    volunteer.getPerson().setEmail(form.getEmail());
    volunteer.getPerson().setTelephone(form.getTelephone());
    volunteer.getPerson().setMobile(form.getMobile());
    volunteer.getPerson().setWorkPhone(form.getWorkPhone());
    volunteer.getPerson().getAddress().setStreet(form.getStreet());
    volunteer.getPerson().getAddress().setTown(form.getTown());
    volunteer.getPerson().getAddress().setCounty(form.getCounty());
    volunteer.getPerson().getAddress().setPostcode(form.getPostcode());

    // update the volunteer's contact details last confirmed time-stamp
    final DateTime dt = new DateTime();
    volunteer.setContactDetailsLastConfirmed(DataConverterUtil.toSqlDate(dt));

    UserDetails system = userDetailsService.loadUserByUsername("System");
    Authentication authentication = new UsernamePasswordAuthenticationToken(system, system.getUsername(),
            system.getAuthorities());
    SecurityContextHolder.getContext().setAuthentication(authentication);
    volunteerDao.updateVolunteer(volunteer);

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

From source file:net.eusashead.hateoas.hal.response.impl.HalResponseBuilderImplTest.java

@Test
public void testHead() {
    // Create a HalGetResponseBuilder
    HalResponseBuilderImpl builder = new HalResponseBuilderImpl(representationFactory,
            new MockHttpServletRequest("HEAD", "/path/to/resource"));

    // Create a response with a Representation
    ResponseEntity<Representation> response = builder.withProperty("string", "String value")
            .etag(new Date(123456789l)).lastModified(new Date(123456789l)).expireIn(1000000).build();

    // Check we get a 204
    Assert.assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());

    // Check headers
    assertHeaders(response);/* www.j  a v  a 2s  . c  o  m*/

    // Check body is null
    Assert.assertNull(response.getBody());

}