⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aggregatedlayoutmanager.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      restrictions = node.getRestrictionsByPath("children");      boolean isFolder = (node.getNodeType() == IUserLayoutNodeDescription.FOLDER );      if ( isFolder ) {       for ( int i = 0; i < restrictions.size(); i++ ) {         IUserLayoutRestriction restriction = (IUserLayoutRestriction)restrictions.get(i);          for ( String nextId = ((ALFolder)node).getFirstChildNodeId(); nextId != null; ) {           ALNode nextNode = getLayoutNode(nextId);           String tmpNodeId = nextNode.getNextNodeId();           if ( (restriction.getRestrictionType() & RestrictionTypes.DEPTH_RESTRICTION) == 0 &&                !restriction.checkRestriction(nextNode) ) {              moveNodeToLostFolder(nextId);           }            nextId = tmpNodeId;          }       }      }      // Checking parent related restrictions on the parent if it exists      String parentNodeId = node.getParentNodeId();      if ( parentNodeId != null ) {       restrictions = node.getRestrictionsByPath("parent");       ALNode parentNode = getLayoutNode(parentNodeId);       for ( int i = 0; i < restrictions.size(); i++ ) {          IUserLayoutRestriction restriction = (IUserLayoutRestriction)restrictions.get(i);          if ( (restriction.getRestrictionType() & RestrictionTypes.DEPTH_RESTRICTION) == 0 &&                !restriction.checkRestriction(parentNode) ) {              moveNodeToLostFolder(nodeId);              break;          }       }      }        if ( isFolder ) {            ++depth;            ALFolder folder = (ALFolder) node;            String firstChildId = folder.getFirstChildNodeId();            if ( firstChildId != null ) {             String id = getLastSiblingNode(firstChildId).getId();             while ( id != null && !changeSiblingNodesOrder(folder.getFirstChildNodeId()) ) {			   String lastNodeId = getLastSiblingNode(id).getId();			   id = getLayoutNode(lastNodeId).getPreviousNodeId();			   moveNodeToLostFolder(lastNodeId);             }               for ( String nextId = folder.getFirstChildNodeId(); nextId != null;                    nextId = getLayoutNode(nextId).getNextNodeId() )               moveWrongNodesToLostFolder(nextId,depth);            }         }  }  // Gets the content of the lost folder  public String getLostFolderXML() throws PortalException {    Document document = DocumentFactory.getNewDocument();    layout.writeTo(ALFolderDescription.LOST_FOLDER_ID,document);    return org.jasig.portal.utils.XML.serializeNode(document);  }  /**     * Checks the local restriction specified by the parameters below     * @param node a <code>ALNode</code> node to be checked     * @param restrictionType a restriction type     * @param propertyValue a <code>String</code> property value to be checked     * @return a boolean value     * @exception PortalException if an error occurs     */  protected boolean checkRestriction(ALNode node, int restrictionType, String propertyValue ) throws PortalException {    return checkRestriction(node, restrictionType, UserLayoutRestriction.LOCAL_RESTRICTION, propertyValue);  }  /**     * Checks the necessary restrictions while adding a new node     * @param nodeDesc a <code>IALNodeDescription</code> node description of a new node to be added     * @param parentId a <code>String</code> parent node ID     * @param nextSiblingId a <code>String</code> next sibling node ID     * @return a boolean value     * @exception PortalException if an error occurs     */  private boolean checkAddRestrictions( IALNodeDescription nodeDesc, String parentId, String nextSiblingId ) throws PortalException {    String newNodeId = nodeDesc.getId();    ALNode newNode = null;    if ( newNodeId == null ) {      if ( nodeDesc instanceof IALChannelDescription )        newNode = new ALChannel((IALChannelDescription)nodeDesc);      else        newNode = new ALFolder((IALFolderDescription)nodeDesc);    } else        newNode = getLayoutNode(newNodeId);    ALNode parentNode = getLayoutNode(parentId);    if ( !(parentNode.getNodeType()==IUserLayoutNodeDescription.FOLDER ) )      throw new PortalException ("The target parent node should be a folder!");    //if ( checkRestriction(parentNode,RestrictionTypes.IMMUTABLE_RESTRICTION,"false") ) {    if ( !parentNode.getNodeDescription().isImmutable() ) {     // Checking children related restrictions     Vector restrictions = parentNode.getRestrictionsByPath("children");     for ( int i = 0; i < restrictions.size(); i++ ) {         IUserLayoutRestriction restriction = (IUserLayoutRestriction)restrictions.get(i);         if ( (restriction.getRestrictionType() & RestrictionTypes.DEPTH_RESTRICTION) == 0 &&                !restriction.checkRestriction(newNode) )            return false;     }     // Checking parent related restrictions     restrictions = newNode.getRestrictionsByPath("parent");     for ( int i = 0; i < restrictions.size(); i++ ) {          IUserLayoutRestriction restriction = (IUserLayoutRestriction)restrictions.get(i);          if ( (restriction.getRestrictionType() & RestrictionTypes.DEPTH_RESTRICTION) == 0 &&                !restriction.checkRestriction(parentNode) )            return false;     }     // Considering two cases if the node is new or it is already in the user layout     if ( newNodeId != null ) {      // Checking depth restrictions for the node and all its descendants (if there are any)      if ( !checkDepthRestrictions(newNodeId,parentId) )         return false;     } else         return checkRestriction(newNode,RestrictionTypes.DEPTH_RESTRICTION,(getDepth(parentId)+1)+"");     // Checking sibling nodes order     return changeSiblingNodesPriorities(newNode,parentId,nextSiblingId);    } else        return false;  }  /**     * Checks the necessary restrictions while moving a node     * @param nodeId a <code>String</code> node ID of a node to be moved     * @param newParentId a <code>String</code> new parent node ID     * @param nextSiblingId a <code>String</code> next sibling node ID     * @return a boolean value     * @exception PortalException if an error occurs     */  private boolean checkMoveRestrictions( String nodeId, String newParentId, String nextSiblingId ) throws PortalException {  	    ALNode node = getLayoutNode(nodeId);    ALNode oldParentNode = getLayoutNode(node.getParentNodeId());    ALFolder newParentNode = getLayoutFolder(newParentId);    /*if ( checkRestriction(oldParentNode,RestrictionTypes.IMMUTABLE_RESTRICTION,"false") &&         checkRestriction(newParentNode,RestrictionTypes.IMMUTABLE_RESTRICTION,"false") ) {*/    if ( !oldParentNode.getNodeDescription().isImmutable() && !newParentNode.getNodeDescription().isImmutable() ) {     if ( !oldParentNode.equals(newParentNode) ) {      // Checking children related restrictions      Vector restrictions = newParentNode.getRestrictionsByPath("children");      for ( int i = 0; i < restrictions.size(); i++ ) {         IUserLayoutRestriction restriction = (IUserLayoutRestriction)restrictions.get(i);         if ( (restriction.getRestrictionType() & RestrictionTypes.DEPTH_RESTRICTION) == 0 &&                !restriction.checkRestriction(node) )            return false;      }      // Checking parent related restrictions      restrictions = node.getRestrictionsByPath("parent");      for ( int i = 0; i < restrictions.size(); i++ ) {          IUserLayoutRestriction restriction = (IUserLayoutRestriction)restrictions.get(i);          if ( (restriction.getRestrictionType() & RestrictionTypes.DEPTH_RESTRICTION) == 0 &&                !restriction.checkRestriction(newParentNode) )            return false;      }      // Checking depth restrictions for the node and all its descendants      if ( !checkDepthRestrictions(nodeId,newParentId) )            return false;     }      // Checking sibling nodes order in the line where the node is being moved to      //String firstChildId = newParentNode.getFirstChildNodeId();      //return (firstChildId!=null)?changeSiblingNodesPriorities(firstChildId):true;      return changeSiblingNodesPriorities(node,newParentId,nextSiblingId);    } else        return false;  }  /**     * Checks the necessary restrictions while deleting a node     * @param nodeId a <code>String</code> node ID of a node to be deleted     * @return a boolean value     * @exception PortalException if an error occurs     */  private boolean checkDeleteRestrictions( String nodeId ) throws PortalException {    ALNode node = getLayoutNode(nodeId);    if ( nodeId == null || node == null ) return true;    //if ( checkRestriction(node.getParentNodeId(),RestrictionTypes.IMMUTABLE_RESTRICTION,"false") ) {    if ( !getLayoutNode(node.getParentNodeId()).getNodeDescription().isImmutable() ) {         // Checking the unremovable restriction on the node to be deleted         //return checkRestriction(nodeId,RestrictionTypes.UNREMOVABLE_RESTRICTION,"false");         return !node.getNodeDescription().isUnremovable();    } else         return false;  }  /**     * Recursively checks the depth restrictions beginning with a given node     * @param nodeId a <code>String</code> node ID     * @param newParentId a <code>String</code> new parent node ID     * @return a boolean value     * @exception PortalException if an error occurs     */  private boolean checkDepthRestrictions(String nodeId,String newParentId) throws PortalException {    if ( nodeId == null ) return true;    int nodeDepth = getDepth(nodeId);    int parentDepth = getDepth(newParentId);    if ( nodeDepth == parentDepth+1 ) return true;    return checkDepthRestrictions(nodeId,newParentId,nodeDepth);  }  /**     * Recursively checks the depth restrictions beginning with a given node     * @param nodeId a <code>String</code> node ID     * @param newParentId a <code>String</code> new parent node ID     * @param parentDepth a parent depth     * @return a boolean value     * @exception PortalException if an error occurs     */  private boolean checkDepthRestrictions(String nodeId,String newParentId,int parentDepth) throws PortalException {    ALNode node = getLayoutNode(nodeId);    // Checking restrictions for the node    if ( !checkRestriction(nodeId,RestrictionTypes.DEPTH_RESTRICTION,(parentDepth+1)+"") )            return false;    if ( node.getNodeType() == IUserLayoutNodeDescription.FOLDER ) {     for ( String nextId = ((ALFolder)node).getFirstChildNodeId(); nextId != null; nextId = node.getNextNodeId() ) {      node = getLayoutNode(nextId);      if ( !checkDepthRestrictions(nextId,node.getParentNodeId(),parentDepth+1) )            return false;     }    }    return true;  }  /**     * Gets the tree depth for a given node     * @param nodeId a <code>String</code> node ID     * @return a depth value     * @exception PortalException if an error occurs     */  public int getDepth(String nodeId) throws PortalException {	 int depth = 0;	 for ( String parentId = getParentId(nodeId); parentId != null; parentId = getParentId(parentId), depth++ );	 return depth;  }  /**     * Moves the node to the lost folder     * @param nodeId a <code>String</code> node ID     * @return a boolean value     * @exception PortalException if an error occurs     */  private boolean moveNodeToLostFolder(String nodeId) throws PortalException {   ALFolder lostFolder = getLayoutFolder(IALFolderDescription.LOST_FOLDER_ID);   if ( lostFolder == null ) {    lostFolder = ALFolder.createLostFolder();   }    // Moving the node to the lost folder    return moveNode(nodeId,IALFolderDescription.LOST_FOLDER_ID,null);  }  /**     * Gets the restriction specified by the parameters below     * @param node a <code>ALNode</code> node     * @param restrictionType a restriction type     * @param restrictionPath a <code>String</code> restriction path     * @return a <code>IUserLayoutRestriction</code> instance     * @exception PortalException if an error occurs     */  private static IUserLayoutRestriction getRestriction( ALNode node, int restrictionType, String restrictionPath ) throws PortalException {     return node.getRestriction(UserLayoutRestriction.getRestrictionName(restrictionType,restrictionPath));  }   /**     * Return a priority restriction for the given node.     * @return a <code>PriorityRestriction</code> object     * @exception PortalException if an error occurs     */  public static PriorityRestriction getPriorityRestriction( ALNode node ) throws PortalException {     PriorityRestriction priorRestriction = getPriorityRestriction(node,UserLayoutRestriction.LOCAL_RESTRICTION);     if ( priorRestriction == null ) {       priorRestriction = (PriorityRestriction)         UserLayoutRestrictionFactory.createRestriction(RestrictionTypes.PRIORITY_RESTRICTION,"0-"+java.lang.Integer.MAX_VALUE,UserLayoutRestriction.LOCAL_RESTRICTION);     }     return priorRestriction;  }  /**     * Return a priority restriction for the given node.     * @return a <code>PriorityRestriction</code> object     * @exception PortalException if an error occurs     */  private static PriorityRestriction getPriorityRestriction( ALNode node, String restrictionPath ) throws PortalException {     return (PriorityRestriction) getRestriction(node,RestrictionTypes.PRIORITY_RESTRICTION,restrictionPath);  }  /**	   * Change if it's possible priority values for all the sibling nodes	   * @param nodeId a <code>String</code> any node ID from the sibling line to be checked	   * @return a boolean value	   * @exception PortalException if an error occurs	   */  protected boolean changeSiblingNodesPriorities( String nodeId ) throws PortalException {         	int tmpPriority = Integer.MAX_VALUE;	String firstNodeId = getFirstSiblingNode(nodeId).getId();	// Fill out the vector by priority values	for ( String nextId = firstNodeId; nextId != null; ) {	  ALNode nextNode = getLayoutNode(nextId);	  int[] nextRange = getPriorityRestriction(nextNode).getRange();	  int value = Math.min(nextRange[1],tmpPriority-1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -