/** * @param resourceDTO * @param siteId * @param id * @param response * @param comment * @return * @throws com.sfr.tiilta.client.exception.ValidationException * @throws java.io.IOException */ @PreAuthorize( "@tiiltaAuthorization.hasBenderPermission('TemplatingDjango', 'Site' , #siteId, @userService.getConnected(), #id)") @RequestMapping( value = "/bender/{siteId:.+}/resource/{id}", method = RequestMethod.PUT, headers = {"content-type=application/json"}) public ResponseEntity<BenderResource> updateResource( @RequestBody @Valid BenderResource resourceDTO, @PathVariable("siteId") String siteId, @PathVariable("id") String id, HttpServletResponse response, @RequestParam(value = "comment", required = false) String comment) throws ValidationException, IOException { ResponseEntity<BenderResource> result = new ResponseEntity<>(null, new HttpHeaders(), HttpStatus.BAD_REQUEST); boolean isSaved = false; Site site = siteService.getSite(siteId); if (site == null) { throw new ValidationException("le site est inconnu"); } if (resourceDTO != null) { User user = userService.getConnected(); BenderResource originResource = benderService.getResourceById(id, null); if (originResource == null) { throw new ValidationException("Le fichier n'existe pas"); } resourceDTO.setModifiedBy(user.getName()); resourceDTO.setUpdateDate(new Date()); resourceDTO.setSite(siteId); // Admin only fields if (!tiiltaAuthorization.hasPermission( Permission.Admin, Subject.Site, siteId, userService.getConnected())) { resourceDTO.setSensitive(originResource.isSensitive()); resourceDTO.setExecutable(originResource.isExecutable()); resourceDTO.setExecutorType(originResource.getExecutorType()); } benderService.persist(resourceDTO); // récupération de la resource sauvegardée avec la dernière version dans SVN result = new ResponseEntity<>( this.getResourceById(id, null, siteId), new HttpHeaders(), HttpStatus.OK); } return result; }
public void addUser(User user) { if (dataSource != null) { if (enableActionDelete) { DeleteActionButton deleteActionButton = new DeleteActionButton(user.getId()); deleteActionButton.setRow(dataSource.getSize()); deleteActionButton.addClickHandler(deleteClickHandler); Object[] row = {user.getId(), user.getName(), deleteActionButton}; dataSource.addRow(row); } else { Object[] row = {user.getId(), user.getName()}; dataSource.addRow(row); } } }
public void updateUser(User user) { if (dataSource != null && dataSource.getSize() > 0) { for (int i = 0; i < dataSource.getSize(); i++) { if (dataSource.getRowData(i)[0].equals(user.getId())) { if (enableActionDelete) { DeleteActionButton deleteActionButton = new DeleteActionButton(user.getId()); deleteActionButton.setRow(dataSource.getSize()); deleteActionButton.addClickHandler(deleteClickHandler); Object[] row = {user.getId(), user.getName(), deleteActionButton}; dataSource.updateRow(i, row); } else { Object[] row = {user.getId(), user.getName()}; dataSource.updateRow(i, row); } break; } } } }