Пример #1
0
  @Override
  public void onRequestEntity(GwtConversation conversation, String entityId) {
    assertProjectSelected(conversation);

    try {
      AEntity entity = getDaoService().getById(entityId);
      if (!Auth.isVisible(entity, conversation.getSession().getUser()))
        throw new PermissionDeniedException();
      // TODO check if entity is from project
      conversation.sendToClient(entity);
      conversation.sendToClient(getAssociatedEntities(entity));
    } catch (EntityDoesNotExistException ex) {
      log.info("Requested entity not found:", entityId);
      // nop
    }
  }
Пример #2
0
  @Override
  public void onDeleteEntity(GwtConversation conversation, String entityId) {
    AEntity entity = getDaoService().getEntityById(entityId);
    User user = conversation.getSession().getUser();
    if (!Auth.isDeletable(entity, user)) throw new PermissionDeniedException();

    if (entity instanceof File) {
      File file = (File) entity;
      file.deleteFile();
    }

    if (entity instanceof Task) {
      // update sprint day snapshot before delete
      conversation
          .getProject()
          .getCurrentSprint()
          .getDaySnapshot(Date.today())
          .updateWithCurrentSprint();
    }

    ADao dao = getDaoService().getDao(entity);
    dao.deleteEntity(entity);

    if (entity instanceof Task) onTaskDeleted(conversation, (Task) entity);

    Project project = conversation.getProject();
    if (project != null) {
      for (GwtConversation c : webApplication.getConversationsByProject(project, conversation)) {
        c.getNextData().addDeletedEntity(entityId);
      }
    }

    if (user != null && project != null) {
      ProjectUserConfig config = project.getUserConfig(user);
      config.touch();
      sendToClients(conversation, config);
    }
  }
Пример #3
0
  @Override
  public void onChangeProperties(GwtConversation conversation, String entityId, Map properties) {
    AEntity entity = getDaoService().getEntityById(entityId);
    User currentUser = conversation.getSession().getUser();
    if (!Auth.isEditable(entity, currentUser)) throw new PermissionDeniedException();

    Sprint previousRequirementSprint =
        entity instanceof Requirement ? ((Requirement) entity).getSprint() : null;

    if (entity instanceof Requirement) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "label");
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "testDescription");
      postChangeIfChanged(conversation, entity, properties, currentUser, "sprintId");
      postChangeIfChanged(conversation, entity, properties, currentUser, "closed");
      postChangeIfChanged(conversation, entity, properties, currentUser, "issueId");
    }
    Project project = conversation.getProject();
    if (entity instanceof Task) {
      // update sprint day snapshot before change
      if (project.isCurrentSprintSet())
        project.getCurrentSprint().getDaySnapshot(Date.today()).updateWithCurrentSprint();
      postChangeIfChanged(conversation, entity, properties, currentUser, "label");
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
    }
    if (entity instanceof Wikipage) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "text");
    }
    if (entity instanceof Risk) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "probability");
      postChangeIfChanged(conversation, entity, properties, currentUser, "impact");
      postChangeIfChanged(conversation, entity, properties, currentUser, "probabilityMitigation");
      postChangeIfChanged(conversation, entity, properties, currentUser, "impactMitigation");
    }
    if (entity instanceof Impediment) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "solution");
      postChangeIfChanged(conversation, entity, properties, currentUser, "closed");
    }
    if (entity instanceof Issue) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "description");
      postChangeIfChanged(conversation, entity, properties, currentUser, "statement");
      postChangeIfChanged(conversation, entity, properties, currentUser, "closeDate");
      postChangeIfChanged(conversation, entity, properties, currentUser, "storyId");
    }
    if (entity instanceof BlogEntry) {
      postChangeIfChanged(conversation, entity, properties, currentUser, "text");
    }

    entity.updateProperties(properties);

    if (entity instanceof Task) onTaskChanged(conversation, (Task) entity, properties);
    if (entity instanceof Requirement)
      onRequirementChanged(
          conversation, (Requirement) entity, properties, previousRequirementSprint);
    if (entity instanceof Impediment)
      onImpedimentChanged(conversation, (Impediment) entity, properties);
    if (entity instanceof Issue) onIssueChanged(conversation, (Issue) entity, properties);
    if (entity instanceof BlogEntry)
      onBlogEntryChanged(conversation, (BlogEntry) entity, properties);
    if (entity instanceof Comment) onCommentChanged(conversation, (Comment) entity, properties);
    if (entity instanceof SystemConfig)
      onSystemConfigChanged(conversation, (SystemConfig) entity, properties);
    if (entity instanceof Wikipage) onWikipageChanged(conversation, (Wikipage) entity, properties);

    Project currentProject = project;
    if (currentUser != null && currentProject != null) {
      ProjectUserConfig config = currentProject.getUserConfig(currentUser);
      config.touch();
      sendToClients(conversation, config);
    }

    conversation.clearRemoteEntitiesByType(Change.class);
    sendToClients(conversation, entity);
  }
Пример #4
0
 @Override
 public boolean isVisibleFor(User user) {
   return Auth.isVisible(getParent(), user);
 }