Example usage for org.springframework.web.bind.annotation RequestMethod PUT

List of usage examples for org.springframework.web.bind.annotation RequestMethod PUT

Introduction

In this page you can find the example usage for org.springframework.web.bind.annotation RequestMethod PUT.

Prototype

RequestMethod PUT

To view the source code for org.springframework.web.bind.annotation RequestMethod PUT.

Click Source Link

Usage

From source file:com.netflix.spinnaker.halyard.controllers.v1.PersistentStorageController.java

@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setPersistentStorage(@PathVariable String deploymentName,
        @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate,
        @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity,
        @RequestBody Object rawPersistentStorage) {
    PersistentStorage persistentStorage = objectMapper.convertValue(rawPersistentStorage,
            PersistentStorage.class);

    UpdateRequestBuilder builder = new UpdateRequestBuilder();

    builder.setUpdate(() -> persistentStorageService.setPersistentStorage(deploymentName, persistentStorage));
    builder.setSeverity(severity);/*w  w  w  .jav  a 2 s .c o m*/

    Supplier<ProblemSet> doValidate = ProblemSet::new;

    if (validate) {
        doValidate = () -> persistentStorageService.validatePersistentStorage(deploymentName);
    }

    builder.setValidate(doValidate);
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());

    return DaemonTaskHandler.submitTask(builder::build, "Edit persistent storage settings");
}

From source file:com.snv.user.UsersController.java

/**
 * {@inheritDoc}//from  w ww . j  av  a2 s.c om
 */
@Override
@RequestMapping(method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public User put(@RequestBody User user) {
    return this.userService.put(user);
}

From source file:edu.uoc.json.controller.MeetingSessionController.java

@RequestMapping(method = RequestMethod.PUT)
public @ResponseBody JSONResponse lockSession(HttpSession session) {
    JSONResponse response = new JSONResponse();
    try {/*from w  ww. j ava 2s. c  o  m*/
        Room room = (Room) session.getAttribute(Constants.ROOM_SESSION);
        User user = (User) session.getAttribute(Constants.USER_SESSION);
        MeetingRoom meeting = (MeetingRoom) session.getAttribute(Constants.MEETING_SESSION);

        if (user != null && room != null && meeting != null) {
            room = roomDao.findByRoomCode(room.getId());
            boolean new_block = !room.isIs_blocked();
            meeting = meetingDao.findById(meeting.getId());
            if (meeting.getFinished() == (byte) 1) {
                new_block = false;
            }
            if (meeting.getFinished() == (byte) 1
                    || !Constants.REASON_BLOCK_RECORDING.equals(room.getReason_blocked())) {
                room.setIs_blocked(new_block);
                if (!new_block) {
                    room.setReason_blocked(null);
                } else {
                    room.setReason_blocked(Constants.REASON_BLOCK_BY_USER);
                }
            }
            roomDao.save(room);
            response.setOk(true);
        }
    } catch (Exception e) {
        logger.error("Lock session ", e);

    }
    return response;
}

From source file:org.springframework.samples.petclinic.rest.PetRestController.java

/**
 * Custom handler for save an pet.//from  w w  w . ja v  a 2s.c  o  m
 *
 * @param Pet
 * @return 
 * @return a ModelMap with the model attributes for the view
 */
@RequestMapping(value = "/save", method = RequestMethod.PUT)
public Pet savePet(@Valid @RequestBody Pet pet) {
    LOGGER.debug("pet: ", pet.toString());
    return this.clinicService.savePet(pet);
}

From source file:com.springsource.oauthservice.develop.AppController.java

@RequestMapping(value = "/apps/{slug}", method = RequestMethod.PUT)
public String update(@PathVariable String slug, @Valid AppForm form, BindingResult bindingResult,
        Principal user, Model model) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("slug", slug);
        return "develop/apps/edit";
    }/*from w w  w.  j a  v a2s. c o m*/
    return "redirect:/develop/apps/" + appRepository.updateApp(user.getName(), slug, form);
}

From source file:magoffin.matt.sobriquet.web.AliasController.java

/**
 * Store an alias./*from w  w  w .j  a  va 2  s  .  com*/
 * 
 * @param key
 *        The alias.
 * @param value
 *        The alias actual value.
 * @return The response.
 */
@RequestMapping(method = RequestMethod.PUT, path = "/alias/{key}", consumes = "text/plain")
@ResponseBody
public Response<Object> add(@PathVariable("key") String key, @RequestBody String value) {
    BasicAlias alias = new BasicAlias(key, value);
    aliasDao.store(alias);
    return Response.response(null);
}

From source file:com.oneops.cms.transmitter.web.PubController.java

@RequestMapping(value = "/publisher/stop", method = RequestMethod.PUT)
@ResponseBody
public PubStatus stop() {
    stopPublisher();
    PubStatus status = scheduler.getStatus();
    return status;
}

From source file:com.ar.hotwiredautorepairshop.controller.CustomerController.java

@RequestMapping(value = "/customers/update", method = RequestMethod.PUT)
public boolean updateCustomer(@RequestBody Customer customer) {
    Customer customerToBeUpdated = customerRepository.findOne(customer.getSocialSecurityNumber());
    customerToBeUpdated.setSocialSecurityNumber(customer.getSocialSecurityNumber());
    customerToBeUpdated.setFirstName(customer.getFirstName());
    customerToBeUpdated.setLastName(customer.getLastName());
    customerToBeUpdated.setStreetAddress(customer.getStreetAddress());
    customerToBeUpdated.setZipCode(customer.getZipCode());
    customerToBeUpdated.setCity(customer.getCity());
    customerToBeUpdated.setPhoneNumber(customer.getPhoneNumber());
    customerToBeUpdated.setEmail(customer.getEmail());

    String gender = customer.getGender();
    if (gender.equals("male") || gender.equals("female")) {
        customerToBeUpdated.setGender(gender);
    } else {// w w w. j  ava2 s. c  o m
        return false;
    }

    customerRepository.save(customerToBeUpdated);
    return true;
}

From source file:com.dhenton9000.birt.controllers.security.UsersController.java

@RequestMapping(method = RequestMethod.PUT, path = "/save", produces = "application/json")
@ApiOperation(value = "Save A User", notes = "Save changes to  a  User. It uses the id to change the login and username")
@ResponseStatus(HttpStatus.OK)//from ww  w.j av a 2 s .  c  o  m
@Transactional
public Users save(@RequestBody Users user) {

    Integer id = user.getUserid();
    Users foundUser = usersService.findOne(id);
    if (foundUser == null) {
        throw new ResourceNotFoundException("cannot find user [" + id + "]");
    }

    return usersService.save(user);
}

From source file:es.fdi.reservas.reserva.web.EspaciosRestController.java

@RequestMapping(value = "/gestor/administrar/espacio/editar/{idEspacio}", method = RequestMethod.PUT)
public String editarEspaciosGestor(@PathVariable("idEspacio") long idEspacio,
        @RequestBody EspacioDTO espacioActualizado) {

    Attachment attachment = new Attachment("");
    if (espacioActualizado.getImagen().equals("")) {
        attachment = espacio_service.getEspacio(espacioActualizado.getId()).getImagen();
    } else {/*w  w w  . ja  v a  2s . co m*/
        //         String img = "/img/users/" + user_service.getUser(idUser).getUsername();
        //         String nombreViejo = user_service.getUser(idUser).getUsername();
        //         String nombreNuevo = userActualizado.getUsername();
        //         
        //         if (!nombreViejo.equalsIgnoreCase(nombreNuevo)){
        //            //si el nombre de usuario ha cambiado, hay que renombrar el directorio y las referencias
        //            //File dirViejo = new File("../src/main/webapp/img/"  + nombreViejo);
        //            File dirNuevo = new File("../../img/"  + nombreNuevo);
        //            boolean correcto = dirNuevo.mkdir();
        //            
        //         }

        if (espacio_service.getAttachmentByName(espacioActualizado.getImagen()).isEmpty()) {

            //si no esta, lo aado

            attachment.setAttachmentUrl("/img/" + espacioActualizado.getImagen());
            attachment.setStorageKey(espacio_service.getEspacio(idEspacio).getNombreEspacio() + "/"
                    + espacioActualizado.getImagen());
            //reserva_service.addAttachment(attachment);
        } else {
            attachment = espacio_service.getAttachmentByName(espacioActualizado.getImagen()).get(0);
        }
    }
    espacio_service.editarEspacioGestor(espacioActualizado, attachment);
    //System.out.println(imagen + " Existe");
    //   }else{
    //      System.out.println(imagen + " No existe");
    //   }

    //espacio_service.editarEspacio(espacioActualizado);
    return "redirect:/gestor/administrar/espacios/1";
}