Package org.infoglue.cms.util

Examples of org.infoglue.cms.util.AccessConstraintExceptionBuffer


    }


    public String doInput() throws Exception
    {
      AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    Integer protectedSiteNodeVersionId = SiteNodeControllerProxy.getController().getProtectedSiteNodeVersionId(parentSiteNodeId);
    if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.CreateSiteNode", protectedSiteNodeVersionId.toString()))
      ceb.add(new AccessConstraintException("SiteNode.siteNodeId", "1002"));
   
    ceb.throwIfNotEmpty();
   
    return "input";
    }
View Full Code Here


    }


    public String doInputV3() throws Exception
    {     
      AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();

    Integer protectedSiteNodeVersionId = SiteNodeControllerProxy.getController().getProtectedSiteNodeVersionId(parentSiteNodeId);
    if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.CreateSiteNode", protectedSiteNodeVersionId.toString()))
      ceb.add(new AccessConstraintException("SiteNode.siteNodeId", "1002"));
   
    ceb.throwIfNotEmpty();

        userSessionKey = "" + System.currentTimeMillis();

    parentSiteNodeVO = SiteNodeControllerProxy.getController().getSiteNodeVOWithId(parentSiteNodeId);
View Full Code Here

          SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getACLatestActiveSiteNodeVersionVO(this.getInfoGluePrincipal(), siteNodeId);
          if(siteNodeVersionVO != null)
              this.siteNodeVersionId = siteNodeVersionVO.getId();
      }

      AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
      Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId);
      if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.SubmitToPublish", protectedSiteNodeVersionId.toString()))
        ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1005"));
     
      ceb.throwIfNotEmpty();

      //siteNodeVersionVOList = SiteNodeVersionController.getController().getSiteNodeVersionVOWithParentRecursive(siteNodeId, SiteNodeVersionVO.PUBLISHED_STATE);
      siteNodeVersionVOList = SiteNodeVersionController.getController().getPublishedSiteNodeVersionVOWithParentRecursive(siteNodeId);

    }
View Full Code Here

          SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getACLatestActiveSiteNodeVersionVO(this.getInfoGluePrincipal(), siteNodeId);
          if(siteNodeVersionVO != null)
              this.siteNodeVersionId = siteNodeVersionVO.getId();
      }

      AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
     
      Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId);
      if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.SubmitToPublish", protectedSiteNodeVersionId.toString()))
        ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1005"));
     
      ceb.throwIfNotEmpty();

      siteNodeVOList = SiteNodeController.getController().getSiteNodeVOWithParentRecursive(siteNodeId, processBean);
    }
    }
    finally
View Full Code Here

 
  public void intercept(InfoGluePrincipal infoGluePrincipal, InterceptionPointVO interceptionPointVO, Map extradata, boolean allowCreatorAccess) throws ConstraintException, SystemException, Exception
  {
    logger.info("interceptionPointVO:" + interceptionPointVO.getName());
   
    AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    try
    {
      Workflow workflowInit = new BasicWorkflow(infoGluePrincipal.getName());
     
      long id = workflowInit.initialize("MattiasWF", 1, new HashMap());
      logger.info("Workflow initialized....");
      logger.info("id:" + id);
      logger.info("name:" + workflowInit.getWorkflowName(id));
     
     
      Workflow workflow = workflowInit; //new BasicWorkflow(infoGluePrincipal.getName());
     
      int[] actions = workflow.getAvailableActions(id, null);
      logger.info("actions:" + actions.length);
      WorkflowDescriptor wd = workflow.getWorkflowDescriptor(workflow.getWorkflowName(id));

      for (int i = 0; i < actions.length; i++)
      {
        int availableActionId = actions[i];
        String name = wd.getAction(availableActionId).getName();
        logger.info("Action:" + availableActionId + ":" + name);
       
        //workflow.doAction(id, availableActionId, Collections.EMPTY_MAP);
      }
      Map map = new HashMap();
      map.put("userName", "Mattias");
      workflow.doAction(id, 1, map);

      actions = workflow.getAvailableActions(id, null);
      logger.info("actions:" + actions.length);
      wd = workflow.getWorkflowDescriptor(workflow.getWorkflowName(id));

      for (int i = 0; i < actions.length; i++)
      {
        int availableActionId = actions[i];
        String name = wd.getAction(availableActionId).getName();
        logger.info("Action:" + availableActionId + ":" + name);
       
        //workflow.doAction(id, availableActionId, Collections.EMPTY_MAP);
      }

      //workflow.doAction(id, 2, Collections.EMPTY_MAP);
      //workflow.doAction(id, 3, Collections.EMPTY_MAP);
      //workflow.doAction(id, 1, Collections.EMPTY_MAP); 
      //workflow.doAction(id, 2, Collections.EMPTY_MAP); 
   
      /*
      WorkflowQuery queryLeft = new WorkflowQuery(WorkflowQuery.OWNER, WorkflowQuery.CURRENT, WorkflowQuery.EQUALS, infoGluePrincipal.getName());
      WorkflowQuery queryRight = new WorkflowQuery(WorkflowQuery.STATUS, WorkflowQuery.CURRENT, WorkflowQuery.EQUALS, "Underway");
      WorkflowQuery query = new WorkflowQuery(queryLeft, WorkflowQuery.AND, queryRight);
      List workflows = workflow.query(query);
      for (Iterator iterator = workflows.iterator(); iterator.hasNext();) {
        Long wfId = (Long) iterator.next();
        logger.info(wfId);
        }
      */   
    }
    catch(Throwable t)
    {
      t.printStackTrace();
    }
       
    if(interceptionPointVO.getName().equalsIgnoreCase("Content.Read"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Write"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Create"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Delete"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Move"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.CreateVersion"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.SubmitToPublish"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.ChangeAccessRights"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("ContentVersion.Read"))
    {
      Integer contentVersionId = (Integer)extradata.get("contentVersionId");
      ContentVersionVO contentVersionVO = ContentVersionControllerProxy.getController().getContentVersionVOWithId(contentVersionId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("ContentVersion.Write"))
    {
      Integer contentVersionId = (Integer)extradata.get("contentVersionId");
      ContentVersionVO contentVersionVO = ContentVersionControllerProxy.getController().getContentVersionVOWithId(contentVersionId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("ContentVersion.Delete"))
    {
      Integer contentVersionId = (Integer)extradata.get("contentVersionId");
      ContentVersionVO contentVersionVO = ContentVersionControllerProxy.getController().getContentVersionVOWithId(contentVersionId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.Read"))
    {
      Integer siteNodeVersionId = (Integer)extradata.get("siteNodeVersionId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.Write"))
    {
      Integer siteNodeVersionId = (Integer)extradata.get("siteNodeVersionId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.CreateSiteNode"))
    {
      Integer parentSiteNodeId = (Integer)extradata.get("siteNodeId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestSiteNodeVersionVO(parentSiteNodeId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.DeleteSiteNode"))
    {
      Integer siteNodeId = (Integer)extradata.get("siteNodeId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestSiteNodeVersionVO(siteNodeId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.MoveSiteNode"))
    {
      Integer siteNodeId = (Integer)extradata.get("siteNodeId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestSiteNodeVersionVO(siteNodeId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.SubmitToPublish"))
    {
      Integer siteNodeVersionId = (Integer)extradata.get("siteNodeVersionId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);

    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.ChangeAccessRights"))
    {
      Integer siteNodeVersionId = (Integer)extradata.get("siteNodeVersionId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);

    }
   
    ceb.throwIfNotEmpty();
  }
View Full Code Here

 
  public void intercept(InfoGluePrincipal infoGluePrincipal, InterceptionPointVO interceptionPointVO, Map extradata, boolean allowCreatorAccess, Database db) throws ConstraintException, SystemException, Exception
  {
    logger.info("interceptionPointVO:" + interceptionPointVO.getName());
   
    AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    /*
    if(interceptionPointVO.getName().equalsIgnoreCase("Content.Read"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Read", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1000"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Write"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Write", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1001"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Create"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Create", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1002"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Delete"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Delete", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1003"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.Move"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Move", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1004"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.SubmitToPublish"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.SubmitToPublish", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1005"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.ChangeAccessRights"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.ChangeAccessRights", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1006"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("ContentVersion.Read"))
    {
      Integer contentVersionId = (Integer)extradata.get("contentVersionId");
      ContentVersionVO contentVersionVO = ContentVersionControllerProxy.getController().getContentVersionVOWithId(contentVersionId);
      if(!contentVersionVO.getVersionModifier().equalsIgnoreCase(infoGluePrincipal.getName()))
      { 
        if(ContentVersionControllerProxy.getController().getIsContentProtected(contentVersionVO.getContentId()) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "ContentVersion.Read", contentVersionId.toString()))
          ceb.add(new AccessConstraintException("ContentVersion.contentVersionId", "1000"));
      }
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("ContentVersion.Write"))
    {
      Integer contentVersionId = (Integer)extradata.get("contentVersionId");
      ContentVersionVO contentVersionVO = ContentVersionControllerProxy.getController().getContentVersionVOWithId(contentVersionId);
      if(!contentVersionVO.getVersionModifier().equalsIgnoreCase(infoGluePrincipal.getName()))
      { 
        if(ContentVersionControllerProxy.getController().getIsContentProtected(contentVersionVO.getContentId()) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "ContentVersion.Write", contentVersionId.toString()))
          ceb.add(new AccessConstraintException("ContentVersion.contentVersionId", "1001"));
      }
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("ContentVersion.Delete"))
    {
      Integer contentVersionId = (Integer)extradata.get("contentVersionId");
      ContentVersionVO contentVersionVO = ContentVersionControllerProxy.getController().getContentVersionVOWithId(contentVersionId);
      if(!contentVersionVO.getVersionModifier().equalsIgnoreCase(infoGluePrincipal.getName()))
      { 
        if(ContentVersionControllerProxy.getController().getIsContentProtected(contentVersionVO.getContentId()) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "ContentVersion.Delete", contentVersionId.toString()))
          ceb.add(new AccessConstraintException("ContentVersion.contentVersionId", "1003"));
      }
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("Content.CreateVersion"))
    {
      Integer contentId = (Integer)extradata.get("contentId");
      if(ContentVersionControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.CreateVersion", contentId.toString()))
        ceb.add(new AccessConstraintException("Content.contentId", "1002"));
    }
    else if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.Read"))
    {
      Integer siteNodeVersionId = (Integer)extradata.get("siteNodeVersionId");
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);
      if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(infoGluePrincipal.getName()))
      {
        if(SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getIsSiteNodeVersionProtected(siteNodeVersionId) && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "SiteNodeVersion.Read", siteNodeVersionId.toString()))
          ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeVersionId", "1000"));
      }
    }
    else*/ if(interceptionPointVO.getName().equalsIgnoreCase("SiteNodeVersion.Write"))
    {
      logger.info("******************************************************");
      logger.info("SiteNodeVersion.ChangeAccessRights");
      Integer siteNodeVersionId = (Integer)extradata.get("siteNodeVersionId");
      SiteNodeVersion siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionWithId(siteNodeVersionId, db);
      logger.info("VersionModifier:" + siteNodeVersion.getVersionModifier());
      logger.info("infoGluePrincipal:" + infoGluePrincipal.getName());
      if(!siteNodeVersion.getVersionModifier().equalsIgnoreCase(infoGluePrincipal.getName()))
      {
        Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId, db);
        if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(db, infoGluePrincipal, "SiteNodeVersion.Write", siteNodeVersionId.toString()))
          ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeVersionId", "1001"));
      }
    }

    ceb.throwIfNotEmpty();
  }
View Full Code Here

   
    public String doExecute() throws Exception
    {
      Timer t = new Timer();
     
      AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    if(interceptionPointCategory.equalsIgnoreCase("Content"))
    { 
      if(extraParameters == null || extraParameters.equals(""))
          throw new SystemException("The content category must have a content id sent in so don't set 'Use extra data for access control' to no for those interception points.");
         
        Integer contentId = new Integer(extraParameters);
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);
     
      if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
      {
        if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", contentId.toString()))
        {
          InterceptionPointVO changeInterceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("Content.ChangeAccessRights");
          InterceptionPointVO readInterceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("Content.Read");
          List changeAccessRightVOList = AccessRightController.getController().getAccessRightVOListOnly(changeInterceptionPointVO.getId(), "" + contentId);
          List readAccessRightVOList = AccessRightController.getController().getAccessRightVOListOnly(readInterceptionPointVO.getId(), "" + contentId);
          logger.info("changeAccessRightVOList:" + changeAccessRightVOList.size());
          logger.info("readAccessRightVOList:" + readAccessRightVOList.size());
          if(changeAccessRightVOList.size() > 0 && readAccessRightVOList.size() > 0)
            ceb.add(new AccessConstraintException("Content.contentId", "1006"));
        }
      }
    }
    else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion"))
    { 
      if(extraParameters == null || extraParameters.equals(""))
          throw new SystemException("The sitenode category must have a sitenode id sent in so don't set 'Use extra data for access control' to no for those interception points.");

      Integer siteNodeVersionId = new Integer(extraParameters);
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);
      SiteNodeVersionVO latestSiteNodeVersionVO = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(siteNodeVersionVO.getSiteNodeId());
      if(latestSiteNodeVersionVO.getId().intValue() > siteNodeVersionVO.getId().intValue() && (getRequest().getParameter("forceVersion") == null || getRequest().getParameter("forceVersion").equals("")))
      {
        siteNodeVersionId = latestSiteNodeVersionVO.getId();
        siteNodeVersionVO = latestSiteNodeVersionVO;
        extraParameters = siteNodeVersionId.toString();
      }
      if(siteNodeVersionVO != null)
        unrefreshedNodeId = "" + siteNodeVersionVO.getSiteNodeId();
     
      if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
      {
        boolean isSiteNodeVersionProtected = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getIsSiteNodeVersionProtected(siteNodeVersionVO.getId());
        Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId);
        if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString()))
        {
          InterceptionPointVO changeInterceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("SiteNodeVersion.ChangeAccessRights");
          InterceptionPointVO readInterceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName("SiteNodeVersion.Read");
          List changeAccessRightVOList = AccessRightController.getController().getAccessRightVOListOnly(changeInterceptionPointVO.getId(), "" + siteNodeVersionVO.getId());
          List readAccessRightVOList = AccessRightController.getController().getAccessRightVOListOnly(readInterceptionPointVO.getId(), "" + siteNodeVersionVO.getId());
          logger.info("changeAccessRightVOList:" + changeAccessRightVOList.size());
          logger.info("readAccessRightVOList:" + readAccessRightVOList.size());
          if(changeAccessRightVOList.size() > 0 && readAccessRightVOList.size() > 0)
            ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006"));
        }
      }
    }

    this.interceptionPointVOList = InterceptionPointController.getController().getInterceptionPointVOList(interceptionPointCategory);
    this.roleList = RoleControllerProxy.getController().getAllRoles();
    this.groupList = GroupControllerProxy.getController().getAllGroups();

    this.accessRightsUserRows = new ArrayList<AccessRightsUserRow>();
    Collection<AccessRightsUserRow> localAccessRightsUserRows = AccessRightController.getController().getAccessRightsUserRows(interceptionPointCategory, extraParameters);
    accessRightsUserRows.addAll(localAccessRightsUserRows);
    Collections.sort(this.accessRightsUserRows, new Comparator<AccessRightsUserRow>()
    {
      @Override
      public int compare(AccessRightsUserRow o1, AccessRightsUserRow o2)
      {
        return o1.getUserName().compareToIgnoreCase(o2.getUserName());
      }
    });

    Database db = CastorDatabaseService.getDatabase();
        beginTransaction(db);

        try
        {
        for(InterceptionPointVO interceptionPointVO : (List<InterceptionPointVO>)this.interceptionPointVOList)
        {
          this.extraAccessRightInfo += getExtraAccessRightText(interceptionPointVO, getExtraParameters(), db);

          Integer accessRightId = getAccessRightId(interceptionPointVO.getId(), getExtraParameters(), db);
          //Integer[] accessRightIds = getAccessRightIds(interceptionPointVO.getId(), getExtraParameters(), db);
         
          accessRightHasAccessMap.put("" + interceptionPointVO.getId() + "_" + getExtraParameters(), accessRightId);
         
          for(InfoGlueRole role : (List<InfoGlueRole>)this.roleList)
          {
              Boolean hasAccess = getHasAccessRight(interceptionPointVO.getId(), getExtraParameters(), role.getName(), db);
              accessRightHasAccessMap.put("" + interceptionPointVO.getId() + "_" + getExtraParameters() + "_" + role.getName(), hasAccess);
          }
         
          /*
          for(Integer currentAccessRightId : accessRightIds)
          {
            List<AccessRightGroupVO> currentAccessRightGroupVOList = AccessRightController.getController().getAccessRightGroupVOList(currentAccessRightId, db);
            if(currentAccessRightGroupVOList.size() > 0)
            {
              accessRightId = currentAccessRightId;
            }
          }
          */
         
          if(accessRightId != null && accessRightId > -1)
          {
            List<AccessRightGroupVO> accessRightGroupVOList = AccessRightController.getController().getAccessRightGroupVOList(accessRightId, db);
            logger.info("accessRightGroupVOList:" + accessRightGroupVOList.size() + " to " + accessRightId);
            accessRightGroupsMap.put(accessRightId, accessRightGroupVOList);
            accessRightGroupsMap.put(interceptionPointVO.getId(), accessRightGroupVOList);
          }
        }   
           
            commitTransaction(db);
        }
        catch(Exception e)
        {
            logger.error("An error occurred so we should not complete the transaction:" + e);
            rollbackTransaction(db);
            throw new SystemException(e.getMessage());
        }
        //t.printElapsedTime("Access 10");
   
    ceb.throwIfNotEmpty();

      return "success";
    }
View Full Code Here

 
  private ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
 
  public String doExecute() throws Exception
    {      
    AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    if(this.extraMultiParameter == null || this.extraMultiParameter.length == 0)
    {
      if(interceptionPointCategory.equalsIgnoreCase("Content"))
      { 
        Integer contentId = new Integer(parameters);
        ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);
        if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
        {
          Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId);
          if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString()))
            ceb.add(new AccessConstraintException("Content.contentId", "1006"));
        }
      }
      else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion"))
      { 
        Integer siteNodeVersionId = new Integer(parameters);
        SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);
       
        //If in published state we must first make it working state so it can later be published
        if(siteNodeVersionVO.getStateId().intValue() != SiteNodeVersionVO.WORKING_STATE)
        {
          this.oldParameters = "" + siteNodeVersionId;
          List events = new ArrayList();
          siteNodeVersionVO = SiteNodeStateController.getController().changeState(siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Access right changes", true, this.getInfoGluePrincipal(), siteNodeVersionVO.getSiteNodeId(), events);
          this.newParameters = "" + siteNodeVersionVO.getId();
          this.parameters = "" + siteNodeVersionVO.getId();
          siteNodeVersionId = siteNodeVersionVO.getId();
        }

        if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
        {
          Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId);
          if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", protectedSiteNodeVersionId.toString()))
            ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006"));
        }
      }
      ceb.throwIfNotEmpty();
    }
   
    //logger.info("this.extraMultiParameters[i]:" + this.extraMultiParameter);
    if(this.extraMultiParameter != null && this.extraMultiParameter.length > 0)
    {
View Full Code Here

      return "success";
  }
 
  public String doAddGroups() throws Exception
    {  
    AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    if(interceptionPointCategory.equalsIgnoreCase("Content"))
    { 
      Integer contentId = new Integer(parameters);
      ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);
      if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
      {
        Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId);
        if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString()))
          ceb.add(new AccessConstraintException("Content.contentId", "1006"));
      }
    }
    else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion"))
    { 
      Integer siteNodeVersionId = new Integer(parameters);
      SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);
     
      //If in published state we must first make it working state so it can later be published
      if(siteNodeVersionVO.getStateId().intValue() != SiteNodeVersionVO.WORKING_STATE.intValue())
      {
        this.oldParameters = "" + siteNodeVersionId;
        List events = new ArrayList();
        siteNodeVersionVO = SiteNodeStateController.getController().changeState(siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Access right changes", true, this.getInfoGluePrincipal(), siteNodeVersionVO.getSiteNodeId(), events);
        this.newParameters = "" + siteNodeVersionVO.getId();
        this.parameters = "" + siteNodeVersionVO.getId();
        siteNodeVersionId = siteNodeVersionVO.getId();
     
        AccessRightVO accessRightVO = AccessRightController.getController().getAccessRightVOWithId(this.accessRightId);
        List<AccessRightVO> accessRightsVOList = AccessRightController.getController().getAccessRightVOList(accessRightVO.getInterceptionPointName(), newParameters);
        for(AccessRightVO accessRightVOCandidate : accessRightsVOList)
        {
          if(accessRightVOCandidate.getInterceptionPointId().intValue() == interceptionPointId.intValue())
          {
            this.accessRightId = accessRightVOCandidate.getId();
          }
        }
      }

      if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
      {
        Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId);
        if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString()))
          ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006"));
      }
    }
   
    ceb.throwIfNotEmpty();
   
    String[] groupNames = this.getRequest().getParameterValues("groupName");
    AccessRightController.getController().updateGroups(this.accessRightId, this.parameters, groupNames);

    this.url = getResponse().encodeRedirectURL(this.returnAddress);
View Full Code Here

      return "success";
  }

  public String doAddUser() throws Exception
    {  
    AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
   
    if(this.extraMultiParameter == null || this.extraMultiParameter.length == 0)
    {
      if(interceptionPointCategory.equalsIgnoreCase("Content"))
      { 
        Integer contentId = new Integer(parameters);
        ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId);
        if(!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
        {
          Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId);
          if(ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString()))
            ceb.add(new AccessConstraintException("Content.contentId", "1006"));
        }
      }
      else if(interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion"))
      { 
        Integer siteNodeVersionId = new Integer(parameters);
        SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);
       
        //If in published state we must first make it working state so it can later be published
        if(siteNodeVersionVO.getStateId().intValue() != SiteNodeVersionVO.WORKING_STATE)
        {
          this.oldParameters = "" + siteNodeVersionId;
          //System.out.println("We better state change....");
          List events = new ArrayList();
          //System.out.println("OLd siteNodeVersionVO:" + siteNodeVersionVO.getId());
          siteNodeVersionVO = SiteNodeStateController.getController().changeState(siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Access right changes", true, this.getInfoGluePrincipal(), siteNodeVersionVO.getSiteNodeId(), events);
          //System.out.println("New siteNodeVersionVO:" + siteNodeVersionVO.getId());
          this.newParameters = "" + siteNodeVersionVO.getId();
          this.parameters = "" + siteNodeVersionVO.getId();
          siteNodeVersionId = siteNodeVersionVO.getId();
        }

        if(!siteNodeVersionVO.getVersionModifier().equalsIgnoreCase(this.getInfoGluePrincipal().getName()))
        {
          Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(siteNodeVersionId);
          if(protectedSiteNodeVersionId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString()))
            ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006"));
        }
      }
     
      ceb.throwIfNotEmpty();
    }

    String userName = this.getRequest().getParameter("userName");
    if(userName != null && !userName.equals(""))
    {
View Full Code Here

TOP

Related Classes of org.infoglue.cms.util.AccessConstraintExceptionBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.