@Post @Path("/apps") @Permission(value = {Role.ADMIN, Role.MEMBER}) public void create(Apps apps, UploadedFile war) { try { PropertiesUtil props = new PropertiesUtil("src/main/resources/path.properties"); String pathDeploy = props.getValor("tomcat.webapps"); if (war != null) apps.setNameWar(war.getFileName().substring(0, war.getFileName().indexOf("."))); validator.validate(apps); uploadValidate(war); validator.onErrorUsePageOf(this).newApps(); File warFile = new File(pathDeploy + war.getFileName()); IOUtils.copyLarge(war.getFile(), new FileOutputStream(warFile)); apps.setUser(this.userSession.getUser()); this.result.include("message", "Upload concluído com sucesso."); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } repository.create(apps); result.redirectTo(this).index(); }
@Put @Path("/apps") @Permission(value = {Role.ADMIN, Role.MEMBER}) public void update(Apps apps) { checkPermission(apps); apps.setUser(this.userSession.getUser()); validator.validate(apps); validator.onErrorUsePageOf(this).edit(apps); repository.update(apps); result.redirectTo(this).index(); }