示例#1
0
  @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();
  }
示例#2
0
 @Get
 @Path("/apps/{apps.id}/edit")
 @Permission(value = {Role.ADMIN, Role.MEMBER})
 public Apps edit(Apps apps) {
   checkPermission(apps);
   return repository.find(apps.getId());
 }
示例#3
0
 @Delete
 @Path("/apps/{apps.id}")
 @Permission(value = {Role.ADMIN, Role.MEMBER})
 public void destroy(Apps apps) {
   checkPermission(apps);
   repository.destroy(repository.find(apps.getId()));
   result.redirectTo(this).index();
 }
示例#4
0
  @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();
  }
示例#5
0
 @Get
 @Path("apps/list/{apps.id}")
 @Permission(value = {Role.ADMIN, Role.MEMBER})
 public List<Apps> list(Apps apps) {
   return repository.findById(apps.getId());
 }
示例#6
0
 private void checkPermission(Apps apps) {
   if (apps.getUser().getRole() != Role.ADMIN
       && apps.getUser().getId() != userSession.getUser().getId()) {
     result.redirectTo(IndexController.class).negado();
   }
 }
示例#7
0
 @Get
 @Path("/apps/{apps.id}")
 @Permission(value = {Role.ADMIN, Role.MEMBER})
 public Apps show(Apps apps) {
   return repository.find(apps.getId());
 }