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

📄 aggregatedlayoutmanager.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            return false; 	              ALNode node = getLayoutNode(nodeId);    	 	    // If the node is being moved to the same position	    if ( parentId.equals(node.getParentNodeId()) )	        if ( CommonUtils.nvl(nextSiblingId).equals(CommonUtils.nvl(node.getNextNodeId())))		        return true;                   // Checking restrictions if the parent is not the lost folder        if ( !parentId.equals(IALFolderDescription.LOST_FOLDER_ID) )            if ( !canMoveNode(nodeId,parentId,nextSiblingId) )                return false;             ALFolder targetFolder = getLayoutFolder(parentId);        ALFolder sourceFolder = getLayoutFolder(node.getParentNodeId());        String sourcePrevNodeId = node.getPreviousNodeId();        String sourceNextNodeId = node.getNextNodeId();        ALNode targetNextNode = getLayoutNode(nextSiblingId);        ALNode targetPrevNode = null, sourcePrevNode = null, sourceNextNode = null;        String prevSiblingId = null;        // If the nextNode != null we calculate the prev node from it otherwise we have to run to the last node in the sibling line        if ( targetNextNode != null )            targetPrevNode = getLayoutNode(targetNextNode.getPreviousNodeId());        else            targetPrevNode = getLastSiblingNode(targetFolder.getFirstChildNodeId());        if ( targetPrevNode != null ) {            targetPrevNode.setNextNodeId(nodeId);            prevSiblingId = targetPrevNode.getId();        }        // Changing the previous node id for the new next sibling node        if ( targetNextNode != null )            targetNextNode.setPreviousNodeId(nodeId);        if ( nodeId.equals(sourceFolder.getFirstChildNodeId()) ) {            // Set the new first child node ID to the source folder            sourceFolder.setFirstChildNodeId(node.getNextNodeId());        }        String firstChildId = targetFolder.getFirstChildNodeId();        if ( firstChildId == null || firstChildId.equals(nextSiblingId) ) {            // Set the new first child node ID to the target folder            targetFolder.setFirstChildNodeId(nodeId);        }        // Set the new next node ID for the source previous node        if ( sourcePrevNodeId != null ) {           sourcePrevNode =  getLayoutNode(sourcePrevNodeId);           sourcePrevNode.setNextNodeId(sourceNextNodeId);        }        // Set the new previous node ID for the source next node        if ( sourceNextNodeId != null ) {            sourceNextNode = getLayoutNode(sourceNextNodeId);            sourceNextNode.setPreviousNodeId(sourcePrevNodeId);        }        node.setParentNodeId(parentId);        node.setNextNodeId(nextSiblingId);        node.setPreviousNodeId(prevSiblingId);        // TO UPDATE THE APPROPRIATE INFO IN THE DB        // TO BE DONE !!!!!!!!!!!        boolean result = true;        if ( autoCommit ) {            if ( sourcePrevNode != null ) result &= layoutStore.updateUserLayoutNode(person,userProfile,sourcePrevNode);            if ( sourceNextNode != null ) result &= layoutStore.updateUserLayoutNode(person,userProfile,sourceNextNode);            if ( targetPrevNode != null ) result &= layoutStore.updateUserLayoutNode(person,userProfile,targetPrevNode);            if ( targetNextNode != null ) result &= layoutStore.updateUserLayoutNode(person,userProfile,targetNextNode);            result &= layoutStore.updateUserLayoutNode(person,userProfile,targetFolder);            result &= layoutStore.updateUserLayoutNode(person,userProfile,sourceFolder);            // Changing the node being moved            result &= layoutStore.updateUserLayoutNode(person,userProfile,node);        }              if (result) {            // Inform the layout listeners            LayoutMoveEvent ev = new LayoutMoveEvent(this, getNode(nodeId), getParentId(nodeId));            for (Iterator i = listeners.iterator(); i.hasNext();) {                LayoutEventListener lel=(LayoutEventListener)i.next();                if (node.getNodeDescription().getType() == IUserLayoutNodeDescription.CHANNEL) {                    lel.channelMoved(ev);                } else {                    lel.folderMoved(ev);                }            }        }        updateCacheKey();        return result;    }    public synchronized boolean deleteNode(String nodeId) throws PortalException {       if ( nodeId == null ) return false;       ALNode node = getLayoutNode(nodeId);       if ( node == null ) return false;       // Checking restrictions       if ( !canDeleteNode(nodeId) ) {           log.debug("The node with ID = '" + nodeId + "' cannot be deleted");           return false;       }              // Inform the layout listeners       LayoutMoveEvent ev = new LayoutMoveEvent(this, node.getNodeDescription(), node.getParentNodeId());       for(Iterator i = listeners.iterator(); i.hasNext();) {           LayoutEventListener lel = (LayoutEventListener)i.next();           if(getNode(nodeId).getType() == IUserLayoutNodeDescription.CHANNEL) {               lel.channelDeleted(ev);           } else {               lel.folderDeleted(ev);           }       }       // Deleting the node from the parent       ALFolder parentFolder = getLayoutFolder(node.getParentNodeId());       boolean result = true;       if ( nodeId.equals(parentFolder.getFirstChildNodeId()) ) {         // Set the new first child node ID to the source folder         parentFolder.setFirstChildNodeId(node.getNextNodeId());         // Update it in the database         if ( autoCommit ) result = layoutStore.updateUserLayoutNode(person,userProfile,parentFolder);       }       // Changing the next node id for the previous sibling node       // and the previous node for the next sibling node       String prevSiblingId = node.getPreviousNodeId();       String nextSiblingId = node.getNextNodeId();       if ( prevSiblingId != null ) {        ALNode prevNode = getLayoutNode(prevSiblingId);        prevNode.setNextNodeId(nextSiblingId);        if ( autoCommit ) result = layoutStore.updateUserLayoutNode(person,userProfile,prevNode);       }       if ( nextSiblingId != null ) {        ALNode nextNode = getLayoutNode(nextSiblingId);        nextNode.setPreviousNodeId(prevSiblingId);        if ( autoCommit ) result = layoutStore.updateUserLayoutNode(person,userProfile,nextNode);       }       // DELETE THE NODE FROM THE DB       if ( autoCommit )         result = layoutStore.deleteUserLayoutNode(person,userProfile,node);              // Deleting the node and its children from the hashtable and returning the result value       cleanLayoutData(nodeId,result);              updateCacheKey();              return result;    }        private void cleanLayoutData( String nodeId, boolean result ) throws PortalException {    	ALNode node = getLayoutNode(nodeId);    	result = (layout.getLayoutData().remove(nodeId)!=null) && result;        if ( node.getNodeType() == IUserLayoutNodeDescription.FOLDER ) {         // Loop for all children          String firstChildId = ((ALFolder)node).getFirstChildNodeId();          for ( String nextNodeId = firstChildId; nextNodeId != null; ) {           cleanLayoutData(nextNodeId,result);           nextNodeId = getLayoutNode(nextNodeId).getNextNodeId();          }         }      }    public synchronized IUserLayoutNodeDescription addNode(IUserLayoutNodeDescription nodeDesc, String parentId,String nextSiblingId) throws PortalException {        // Checking restrictions        if ( !canAddNode(nodeDesc,parentId,nextSiblingId) )            return null;        ALFolder parentFolder = getLayoutFolder(parentId);        ALNode nextNode = getLayoutNode(nextSiblingId);        ALNode prevNode =  null;        // If the nextNode != null we calculate the prev node from it otherwise we have to run to the last node in the sibling line        if ( nextNode != null )             prevNode = getLayoutNode(nextNode.getPreviousNodeId());        else             prevNode = getLastSiblingNode( parentFolder.getFirstChildNodeId());        // If currently a fragment is loaded the node desc should have a fragment ID        if ( isFragmentLoaded() )          ((IALNodeDescription)nodeDesc).setFragmentId(fragmentId);        ALNode layoutNode=ALNode.createALNode(nodeDesc);        // Setting the parent node ID        layoutNode.setParentNodeId(parentId);        if ( prevNode != null )             layoutNode.setPreviousNodeId(prevNode.getId());        if ( nextNode != null )             layoutNode.setNextNodeId(nextSiblingId);        // Add the new node to the database and get the node with a new node ID        if ( autoCommit )            layoutNode = layoutStore.addUserLayoutNode(person,userProfile,layoutNode);        else {           IALNodeDescription desc = layoutNode.getNodeDescription();           desc.setId(layoutStore.getNextNodeId(person));           if ( desc.getType() == IUserLayoutNodeDescription.CHANNEL )               layoutStore.fillChannelDescription((IALChannelDescription)desc);  	          }                  String nodeId = layoutNode.getId();        // Putting the new node into the hashtable        layout.getLayoutData().put(nodeId,layoutNode);        if ( prevNode != null )             prevNode.setNextNodeId(nodeId);        if ( nextNode != null )             nextNode.setPreviousNodeId(nodeId);        // Setting new child node ID to the parent node        if ( prevNode == null )            parentFolder.setFirstChildNodeId(nodeId);               if ( autoCommit ) {            // TO UPDATE ALL THE NEIGHBOR NODES IN THE DATABASE            if ( nextNode != null )                layoutStore.updateUserLayoutNode(person,userProfile,nextNode);            if ( prevNode != null )                layoutStore.updateUserLayoutNode(person,userProfile,prevNode);                // Update the parent node            layoutStore.updateUserLayoutNode(person,userProfile,parentFolder);        }                  // Inform the layout listeners        LayoutEvent ev = new LayoutEvent(this, layoutNode.getNodeDescription());        for (Iterator i = listeners.iterator(); i.hasNext();) {            LayoutEventListener lel = (LayoutEventListener)i.next();            if (layoutNode.getNodeDescription().getType() == IUserLayoutNodeDescription.CHANNEL) {                lel.channelAdded(ev);            } else {                lel.folderAdded(ev);            }        }                      updateCacheKey();                  return layoutNode.getNodeDescription();    }    private void changeDescendantsBooleanProperties (IALNodeDescription nodeDesc,IALNodeDescription oldNodeDesc, String nodeId) throws PortalException {      changeDescendantsBooleanProperties(nodeDesc.isHidden()==oldNodeDesc.isHidden(),nodeDesc.isImmutable()==oldNodeDesc.isImmutable(),                                         nodeDesc.isUnremovable()==oldNodeDesc.isUnremovable(),nodeDesc,nodeId);      updateCacheKey();    }    private void changeDescendantsBooleanProperties (boolean hiddenValuesMatch, boolean immutableValuesMatch, boolean unremovableValuesMatch,                                                                                IALNodeDescription nodeDesc, String nodeId) throws PortalException {          ALNode node = getLayoutNode(nodeId);          if ( node.getNodeType() == IUserLayoutNodeDescription.FOLDER ) {           // Loop for all children            String firstChildId = ((ALFolder)node).getFirstChildNodeId();            for ( String nextNodeId = firstChildId; nextNodeId != null; ) {             ALNode currentNode = getLayoutNode(nextNodeId);             // Checking the hidden property if it's changed             if ( !hiddenValuesMatch ) {                 // Checking the hidden node restriction                 boolean canChange = checkRestriction(currentNode,RestrictionTypes.HIDDEN_RESTRICTION,CommonUtils.boolToStr(nodeDesc.isHidden()));                 // Checking the hidden parent node related restriction                 canChange &= checkRestriction(currentNode.getParentNodeId(),RestrictionTypes.HIDDEN_RESTRICTION,"children",CommonUtils.boolToStr(nodeDesc.isHidden()));              // Checking the hidden children node related restrictions              if ( currentNode.getNodeType() == IUserLayoutNodeDescription.FOLDER ) {               ALFolder folder = (ALFolder) node;               //Loop for all children               for ( String nextId = folder.getFirstChildNodeId(); nextId != null; nextId = getLayoutNode(nextId).getNextNodeId() )                canChange &= checkRestriction(nextId,RestrictionTypes.HIDDEN_RESTRICTION,"parent",CommonUtils.boolToStr(nodeDesc.isHidden()));              }                // Changing the hidden value if canChange is true                if ( canChange )                 currentNode.getNodeDescription().setHidden(nodeDesc.isHidden());             }             // Checking the immutable property if it's changed             if ( !immutableValuesMatch ) {                 // Checking the immutable node restriction                 boolean canChange = checkRestriction(currentNode,RestrictionTypes.IMMUTABLE_RESTRICTION,CommonUtils.boolToStr(nodeDesc.isImmutable()));                 // Checking the immutable parent node related restriction                 canChange &= checkRestriction(currentNode.getParentNodeId(),RestrictionTypes.IMMUTABLE_RESTRICTION,"children",CommonUtils.boolToStr(nodeDesc.isImmutable()));              // Checking the immutable children node related restrictions              if ( currentNode.getNodeType() == IUserLayoutNodeDescription.FOLDER ) {               ALFolder folder = (ALFolder) node;               //Loop for all children               for ( String nextId = folder.getFirstChildNodeId(); nextId != null; nextId = getLayoutNode(nextId).getNextNodeId() )                canChange &= checkRestriction(nextId,RestrictionTypes.IMMUTABLE_RESTRICTION,"parent",CommonUtils.boolToStr(nodeDesc.isImmutable()));              }                // Changing the immutable value if canChange is true                if ( canChange )                 currentNode.getNodeDescription().setImmutable(nodeDesc.isImmutable());             }             // Checking the unremovable property if it's changed             if ( !unremovableValuesMatch ) {                 // Checking the unremovable node restriction                 boolean canChange = checkRestriction(currentNode,RestrictionTypes.UNREMOVABLE_RESTRICTION,CommonUtils.boolToStr(nodeDesc.isUnremovable()));                 // Checking the unremovable parent node related restriction                 canChange &= checkRestriction(currentNode.getParentNodeId(),RestrictionTypes.UNREMOVABLE_RESTRICTION,"children",CommonUtils.boolToStr(nodeDesc.isUnremovable()));              // Checking the unremovable children node related restrictions              if ( currentNode.getNodeType() == IUserLayoutNodeDescription.FOLDER ) {               ALFolder folder = (ALFolder) node;               //Loop for all children               for ( String nextId = folder.getFirstChildNodeId(); nextId != null; nextId = getLayoutNode(nextId).getNextNodeId() )                canChange &= checkRestriction(nextId,RestrictionType

⌨️ 快捷键说明

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