Example #1
0
  @Override
  public int updateProject(Project outerProject) {
    Project project = getProject(outerProject.getId());
    project.setName(outerProject.getName());
    project.setIntroduction(outerProject.getIntroduction());
    project.setUpdateTime(new Date());

    if (outerProject.getMemberAccountList() != null) {
      // adding new ones
      for (String account : outerProject.getMemberAccountList()) {
        User user = accountDao.getUser(account);
        if (user != null) {
          boolean addSuccess = project.addMember(user);
          if (addSuccess) {
            Notification o = new Notification();
            o.setTypeId((short) 2);
            o.setTargetUser(outerProject.getUser());
            o.setUser(user);
            o.setParam1(new Integer(outerProject.getId()).toString());
            o.setParam2(outerProject.getName());
            accountMgr.addNotification(o);
          }
        }
      }

      if (project.getUserList() != null) {
        // remove old ones
        List<User> userListToBeRemoved = new ArrayList<User>();
        for (User user : project.getUserList()) {
          if (!outerProject.getMemberAccountList().contains(user.getAccount())) {
            userListToBeRemoved.add(user);
          }
        }

        for (User user : userListToBeRemoved) {
          project.removeMember(user);
        }
      }
    }

    return projectDao.updateProject(project);
  }
Example #2
0
 @Override
 public boolean canUserAccessPage(long userId, int pageId) {
   Page page = projectMgr.getPage(pageId);
   if (page != null) {
     Module module = page.getModule();
     if (module != null) {
       Project project = module.getProject();
       if (project != null) {
         return canUserAccessProject(userId, project.getId());
       }
     }
   }
   return false;
 }
Example #3
0
  public String __init__() {
    // prevent repeated intialization of servcie

    if (SystemConstant.serviceInitialized) {
      return SUCCESS;
    }

    SystemConstant.serviceInitialized = true;

    List<Project> list = projectMgr.getProjectList();
    for (Project p : list) {
      projectMgr.updateDoc(p.getId());
    }
    return SUCCESS;
  }
Example #4
0
 public String myWorkspace() {
   if (!isUserLogined()) {
     plsLogin();
     setRelativeReturnUrl("/workspace/myWorkspace.action?projectId=" + projectId);
     return LOGIN;
   }
   Project p = projectMgr.getProject(getProjectId());
   if (p == null || p.getId() <= 0) {
     setErrMsg("该项目不存在或已被删除,会不会是亲这个链接保存的太久了呢?0  .0");
     logger.error("Unexpected project id=%d", getProjectId());
     return ERROR;
   }
   Workspace workspace = new Workspace();
   workspace.setProject(p);
   setWorkspaceJsonString(workspace.toString());
   setWorkspace(workspace);
   // modified by liweiguang 2016-1-18
   setAccessable(getAccountMgr().canUserAccessProject(getCurUserId(), getProjectId()));
   setManageable(getAccountMgr().canUserManageProject(getCurUserId(), getProjectId()));
   // modified by liweiguang 2016-1-18 end
   return SUCCESS;
 }