Update of /var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository In directory james.mmbase.org:/tmp/cvs-serv3772/src/java/com/finalist/cmsc/repository
Modified Files: RepositoryUtil.java Log Message: CMSC-681 Asset Maintenance See also: http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository See also: http://www.mmbase.org/jira/browse/CMSC-681 Index: RepositoryUtil.java =================================================================== RCS file: /var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -b -r1.30 -r1.31 --- RepositoryUtil.java 16 Dec 2008 07:56:00 -0000 1.30 +++ RepositoryUtil.java 16 Dec 2008 10:50:36 -0000 1.31 @@ -1,12 +1,10 @@ /* - -This software is OSI Certified Open Source Software. -OSI Certified is a certification mark of the Open Source Initiative. - -The license (Mozilla version 1.0) can be read at the MMBase site. -See http://www.MMBase.org/license - -*/ + * + * This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source + * Initiative. + * + * The license (Mozilla version 1.0) can be read at the MMBase site. See http://www.MMBase.org/license + */ package com.finalist.cmsc.repository; import java.util.*; @@ -61,12 +59,12 @@ /** * The first key in this LinkedMap is the root nodemanager of the tree. */ - private static LinkedHashMap<String,String> treeManagers = new LinkedHashMap<String, String>(); + private static LinkedHashMap<String, String> treeManagers = new LinkedHashMap<String, String>(); /** - * Return node managers names and fields which are involved in the navigation tree - * The key is the nodemanager name. The value is the field for the path fragment - * The first element is the root node manager in the tree. + * Return node managers names and fields which are involved in the navigation tree The key is the nodemanager name. + * The value is the field for the path fragment The first element is the root node manager in the tree. + * * @return Map with nodemanager names and fields */ public static LinkedHashMap<String, String> getTreeManagers() { @@ -74,28 +72,27 @@ } /** - * This method is used on startup of MMBase to fill the information about treeManagers - * and path fragment fields - * This method is synchronized on the class (static method) to make sure only one managers is added - * at the same time. - * - * @param manager name of nodemanager which is used in the tree - * @param fragmentFieldname name of field which is used in the path of a tree item - * @param root This nodemanager maintains the nodes which are root tree items + * This method is used on startup of MMBase to fill the information about treeManagers and path fragment fields This + * method is synchronized on the class (static method) to make sure only one managers is added at the same time. + * + * @param manager + * name of nodemanager which is used in the tree + * @param fragmentFieldname + * name of field which is used in the path of a tree item + * @param root + * This nodemanager maintains the nodes which are root tree items */ public static synchronized void registerTreeManager(String manager, String fragmentFieldname, boolean root) { if (root) { - LinkedHashMap<String,String> tempManagers = new LinkedHashMap<String, String>(treeManagers); + LinkedHashMap<String, String> tempManagers = new LinkedHashMap<String, String>(treeManagers); treeManagers.clear(); treeManagers.put(manager, fragmentFieldname); treeManagers.putAll(tempManagers); - } - else { + } else { treeManagers.put(manager, fragmentFieldname); } } - private RepositoryUtil() { // utility } @@ -139,16 +136,22 @@ return contentchannel.getRelatedNodes(COLLECTIONCHANNEL, null, null); } - /** gets the root number - * @param cloud - MMbase cloud + /** + * gets the root number + * + * @param cloud + * - MMbase cloud * @return root node number */ public static String getRoot(Cloud cloud) { return getRootNode(cloud).getStringValue("number"); } - /** gets the root node - * @param cloud - MMbase cloud + /** + * gets the root node + * + * @param cloud + * - MMbase cloud * @return root node */ public static Node getRootNode(Cloud cloud) { @@ -170,17 +173,22 @@ return number == getRootNode(cloud).getNumber(); } - - /** gets the Trash number - * @param cloud - MMbase cloud + /** + * gets the Trash number + * + * @param cloud + * - MMbase cloud * @return trash node number */ public static String getTrash(Cloud cloud) { return getTrashNode(cloud).getStringValue("number"); } - /** gets the Trash node - * @param cloud - MMbase cloud + /** + * gets the Trash node + * + * @param cloud + * - MMbase cloud * @return trash node */ public static Node getTrashNode(Cloud cloud) { @@ -202,7 +210,6 @@ return number == getTrashNode(cloud).getNumber(); } - public static void appendChild(Cloud cloud, String parent, String child) { TreeUtil.appendChild(cloud, parent, child, CHILDREL); } @@ -222,8 +229,10 @@ /** * check that the source item is not a parent of the destination item * - * @param sourceChannel - source item - * @param destChannel - destination item + * @param sourceChannel + * - source item + * @param destChannel + * - destination item * @return <code>true</code> when the source item is a parent */ public static boolean isParent(Node sourceChannel, Node destChannel) { @@ -236,7 +245,9 @@ /** * Find path to root - * @param node - node + * + * @param node + * - node * @return List with the path to the root. First item is the root and last is the node */ public static List<Node> getPathToRoot(Node node) { @@ -245,8 +256,11 @@ /** * Creates a string that represents the root path. - * @param cloud - MMbase cloud - * @param node - MMbase node + * + * @param cloud + * - MMbase cloud + * @param node + * - MMbase node * @return path to root */ public static String getPathToRootString(Cloud cloud, String node) { @@ -255,7 +269,9 @@ /** * Creates a string that represents the root path. - * @param node - MMbase node + * + * @param node + * - MMbase node * @return path to root */ public static String getPathToRootString(Node node) { @@ -264,8 +280,11 @@ /** * Creates a string that represents the root path. - * @param node - MMbase node - * @param includeRoot - include the root pathfragment + * + * @param node + * - MMbase node + * @param includeRoot + * - include the root pathfragment * @return path to root */ public static String getPathToRootString(Node node, boolean includeRoot) { @@ -274,8 +293,11 @@ /** * Creates a string that represents the titles. - * @param cloud - MMbase cloud - * @param node - node number + * + * @param cloud + * - MMbase cloud + * @param node + * - node number * @return titles of nodes in path */ public static String getTitlesString(Cloud cloud, String node) { @@ -284,9 +306,13 @@ /** * Creates a string that represents the titles. - * @param cloud - MMbase cloud - * @param node - node number - * @param includeRoot - include the root node + * + * @param cloud + * - MMbase cloud + * @param node + * - node number + * @param includeRoot + * - include the root node * @return titles of nodes in path */ public static String getTitlesString(Cloud cloud, String node, boolean includeRoot) { @@ -295,8 +321,11 @@ /** * Creates a string that represents the titles. - * @param node - MMbase node - * @param includeRoot - include the root node + * + * @param node + * - MMbase node + * @param includeRoot + * - include the root node * @return titles of nodes in path */ public static String getTitlesString(Node node, boolean includeRoot) { @@ -305,8 +334,11 @@ /** * Method that finds the Channel node using a path as input. - * @param cloud - MMbase cloud - * @param path - path of channel + * + * @param cloud + * - MMbase cloud + * @param path + * - path of channel * @return node with channel path */ public static Node getChannelFromPath(Cloud cloud, String path) { @@ -315,9 +347,13 @@ /** * Method that finds the Channel node using a path as input. - * @param cloud - MMbase cloud - * @param path - path of channel - * @param root - node to start search + * + * @param cloud + * - MMbase cloud + * @param path + * - path of channel + * @param root + * - node to start search * @return node with channel path */ public static Node getChannelFromPath(Cloud cloud, String path, Node root) { @@ -326,10 +362,15 @@ /** * Method that finds the Channel node using a path as input. - * @param cloud - MMbase cloud - * @param path - path of channel - * @param root - node to start search - * @param useCache - use path cache + * + * @param cloud + * - MMbase cloud + * @param path + * - path of channel + * @param root + * - node to start search + * @param useCache + * - use path cache * @return node with channel path */ public static Node getChannelFromPath(Cloud cloud, String path, Node root, boolean useCache) { @@ -339,14 +380,15 @@ /** * Get child channel nodes - * @param parentNode - parent + * + * @param parentNode + * - parent * @return List of children */ public static NodeList getChildren(Node parentNode) { return TreeUtil.getChildren(parentNode, TreeUtil.convertToList(treeManagers), CHILDREL); } - public static boolean hasChild(Node parentChannel, String fragment) { return TreeUtil.hasChild(parentChannel, fragment, treeManagers, CHILDREL); } @@ -355,10 +397,15 @@ return TreeUtil.getChild(parentChannel, fragment, treeManagers, CHILDREL); } - /** Reorder content in channel - * @param cloud - MMbase cloud - * @param parentNode - parent - * @param children - new order + /** + * Reorder content in channel + * + * @param cloud + * - MMbase cloud + * @param parentNode + * - parent + * @param children + * - new order * @return changed numbers */ public static List<Integer> reorderContent(Cloud cloud, String parentNode, String children) { @@ -366,10 +413,15 @@ return RelationUtil.reorder(parent, children, CONTENTREL, CONTENTELEMENT); } - /** Reorder content in channel - * @param cloud - MMbase cloud - * @param parentNode - parent - * @param children - new order + /** + * Reorder content in channel + * + * @param cloud + * - MMbase cloud + * @param parentNode + * - parent + * @param children + * - new order * @return changed numbers */ public static List<Integer> reorderContent(Cloud cloud, String parentNode, String[] children) { @@ -377,12 +429,17 @@ return RelationUtil.reorder(parent, children, CONTENTREL, CONTENTELEMENT); } - - /** Reorder content in channel - * @param cloud - MMbase cloud - * @param parentNode - parent - * @param children - new order - * @param offset - start reorder from this index + /** + * Reorder content in channel + * + * @param cloud + * - MMbase cloud + * @param parentNode + * - parent + * @param children + * - new order + * @param offset + * - start reorder from this index * @return changed numbers */ public static List<Integer> reorderContent(Cloud cloud, String parentNode, String[] children, int offset) { @@ -390,17 +447,22 @@ return RelationUtil.reorder(parent, children, CONTENTREL, CONTENTELEMENT, offset); } - - /** Get sorted ContentChannel child nodes - * @param parentNode - parent + /** + * Get sorted ContentChannel child nodes + * + * @param parentNode + * - parent * @return list of sorted children */ public static NodeList getContentChannelOrderedChildren(Node parentNode) { return SearchUtil.findRelatedOrderedNodeList(parentNode, CONTENTCHANNEL, CHILDREL, NAME_FIELD); } - /** Get sorted child nodes - * @param parentNode - parent + /** + * Get sorted child nodes + * + * @param parentNode + * - parent * @return list of sorted children */ public static NodeList getOrderedChildren(Node parentNode) { @@ -409,35 +471,46 @@ return channels; } - /** Depth of path - * @param path - path + /** + * Depth of path + * + * @param path + * - path * @return level */ public static int getLevel(String path) { return TreeUtil.getLevel(path); } - /** Get number of children - * @param parent - parent + /** + * Get number of children + * + * @param parent + * - parent * @return number of children */ public static int getChildCount(Node parent) { return TreeUtil.getChildCount(parent, "object", CHILDREL); } - /** Get number of ContentChannel children - * @param parent - parent + /** + * Get number of ContentChannel children + * + * @param parent + * - parent * @return number of children */ public static int getContentChannelChildCount(Node parent) { return TreeUtil.getChildCount(parent, CONTENTCHANNEL, CHILDREL); } - /** * Create the relation to the creationchannel. - * @param content - Content Node - * @param channelNumber - String channel number + * + * @param content + * - Content Node + * @param channelNumber + * - String channel number */ public static void addCreationChannel(Node content, String channelNumber) { addCreationChannel(content, content.getCloud().getNode(channelNumber)); @@ -445,27 +518,37 @@ /** * Create the relation to the creationchannel. - * @param content - Content Node - * @param channel - Channel Node + * + * @param content + * - Content Node + * @param channel + * - Channel Node */ public static void addCreationChannel(Node content, Node channel) { log.debug("Creationchannel " + channel.getNumber()); - RelationManager creationChannel = content.getCloud().getRelationManager(CONTENTELEMENT, CONTENTCHANNEL, CREATIONREL); + RelationManager creationChannel = content.getCloud().getRelationManager(CONTENTELEMENT, CONTENTCHANNEL, + CREATIONREL); content.createRelation(channel, creationChannel).commit(); } /** * Check if a contentnode has a creationchannel - * @param content - Content Node + * + * @param content + * - Content Node * @return true if the node has a related creation channel */ public static boolean hasCreationChannel(Node content) { - int count = content.countRelatedNodes(content.getCloud().getNodeManager(CONTENTCHANNEL), CREATIONREL, DESTINATION); + int count = content + .countRelatedNodes(content.getCloud().getNodeManager(CONTENTCHANNEL), CREATIONREL, DESTINATION); return count > 0; } - /** Get creation channel - * @param content - Content Node + /** + * Get creation channel + * + * @param content + * - Content Node * @return Creation channel */ public static Node getCreationChannel(Node content) { @@ -481,8 +564,11 @@ return (creationNode != null) && (creationNode.getNumber() == channelNode.getNumber()); } - /** Remove creation relations for the given contentelement - * @param content A contentelment + /** + * Remove creation relations for the given contentelement + * + * @param content + * A contentelment */ public static void removeCreationRelForContent(Node content) { if (!ContentElementUtil.isContentElement(content)) { @@ -495,8 +581,11 @@ } } - /** Remove creation relations for the given assetelement - * @param content A assetelment + /** + * Remove creation relations for the given assetelement + * + * @param content + * A assetelment */ public static void removeCreationRelForAsset(Node asset) { if (!AssetElementUtil.isAssetElement(asset)) { @@ -511,8 +600,11 @@ /** * Create the relation to the creationchannel. - * @param content - Content Node - * @param channelNumber - String channel number + * + * @param content + * - Content Node + * @param channelNumber + * - String channel number */ public static void addContentToChannel(Node content, String channelNumber) { Node channelNode = content.getCloud().getNode(channelNumber); @@ -527,8 +619,8 @@ // or if the creationchannel is the trash channel Node creationNode = getCreationChannel(content); boolean isOrphan = (creationNode == null); - if(!isOrphan) { - if(isTrash(creationNode)) { + if (!isOrphan) { + if (isTrash(creationNode)) { isOrphan = true; removeCreationRelForContent(content); removeContentFromChannel(content, getTrashNode(cloud)); @@ -544,7 +636,7 @@ relation.setIntValue(TreeUtil.RELATION_POS_FIELD, childCount + 1); relation.commit(); - if(isOrphan) { + if (isOrphan) { addCreationChannel(content, channelNode); } // remove delete relation with this channel, if any still exist @@ -554,8 +646,11 @@ /** * Create the relation to the creationchannel. - * @param asset - Asset Node - * @param channelNumber - String channel number + * + * @param asset + * - Asset Node + * @param channelNumber + * - String channel number */ public static void addAssetToChannel(Node asset, String channelNumber) { Node channelNode = asset.getCloud().getNode(channelNumber); @@ -569,14 +664,14 @@ // or if the creationchannel is the trash channel Node creationNode = getCreationChannel(asset); boolean isOrphan = (creationNode == null); - if(!isOrphan) { - if(isTrash(creationNode)) { + if (!isOrphan) { + if (isTrash(creationNode)) { isOrphan = true; removeCreationRelForAsset(asset); } } - if(isOrphan) { + if (isOrphan) { RelationManager creationChannel = cloud.getRelationManager(ASSETELEMENT, CONTENTCHANNEL, CREATIONREL); asset.createRelation(channelNode, creationChannel).commit(); } @@ -596,8 +691,11 @@ return isLinkedToChannel; } - /** Check if a contentnode has a contentchannel - * @param content - Content Node + /** + * Check if a contentnode has a contentchannel + * + * @param content + * - Content Node * @return true if the node has a related workflowitem */ public static boolean hasContentChannel(Node content) { @@ -619,8 +717,7 @@ } public static int countCreatedContent(Node channelNode) { - return channelNode.countRelatedNodes(channelNode.getCloud().getNodeManager( - CONTENTELEMENT), CREATIONREL, SOURCE); + return channelNode.countRelatedNodes(channelNode.getCloud().getNodeManager(CONTENTELEMENT), CREATIONREL, SOURCE); } public static NodeList getCreatedElements(Node channel) { @@ -645,60 +742,76 @@ } public static int countLinkedContent(Node channelNode) { - int contentCount = channelNode.countRelatedNodes(channelNode.getCloud().getNodeManager( - CONTENTELEMENT), CONTENTREL, DESTINATION); + int contentCount = channelNode.countRelatedNodes(channelNode.getCloud().getNodeManager(CONTENTELEMENT), + CONTENTREL, DESTINATION); return contentCount; } - public static int countLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, null, offset, maxNumber, year, month, day); + public static int countLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, + boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, null, offset, + maxNumber, year, month, day); return Queries.count(query); } - public static int countLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day); + public static int countLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, + boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, + offset, maxNumber, year, month, day); return Queries.count(query); } public static int countCreatedAsset(Node channelNode) { - int contentCount = channelNode.countRelatedNodes(channelNode.getCloud().getNodeManager( - ASSETELEMENT), CREATIONREL, SOURCE); + int contentCount = channelNode.countRelatedNodes(channelNode.getCloud().getNodeManager(ASSETELEMENT), + CREATIONREL, SOURCE); return contentCount; } - public static int countCreatedAsset(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, null, offset, maxNumber, year, month, day); + public static int countCreatedAsset(Node channel, List<String> assettypes, String orderby, String direction, + boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, null, offset, + maxNumber, year, month, day); return Queries.count(query); } - public static int countCreatedAsset(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day); + public static int countCreatedAsset(Node channel, List<String> assettypes, String orderby, String direction, + boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, + maxNumber, year, month, day); return Queries.count(query); } - public static NodeList getLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, null, offset, maxNumber, year, month, day); + public static NodeList getLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, + boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, null, offset, + maxNumber, year, month, day); return query.getNodeManager().getList(query); } - - public static NodeList getLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day); + public static NodeList getLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, + boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, + offset, maxNumber, year, month, day); return query.getNodeManager().getList(query); } - - public static NodeList getLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day, HashMap<String, Object> extraParameters) { - NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day, extraParameters); + public static NodeList getLinkedElements(Node channel, List<String> contenttypes, String orderby, String direction, + boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day, + HashMap<String, Object> extraParameters) { + NodeQuery query = createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, + offset, maxNumber, year, month, day, extraParameters); return query.getNodeManager().getList(query); } - - public static NodeQuery createLinkedContentQuery(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { - return createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day, null); + public static NodeQuery createLinkedContentQuery(Node channel, List<String> contenttypes, String orderby, + String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { + return createLinkedContentQuery(channel, contenttypes, orderby, direction, useLifecycle, archive, offset, + maxNumber, year, month, day, null); } - public static NodeQuery createLinkedContentQuery(Node channel, List<String> contenttypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day, HashMap<String, Object> extraParameters) { + public static NodeQuery createLinkedContentQuery(Node channel, List<String> contenttypes, String orderby, + String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, + int day, HashMap<String, Object> extraParameters) { String destinationManager = CONTENTELEMENT; if (contenttypes != null && contenttypes.size() == 1) { @@ -710,10 +823,9 @@ if (orderby == null) { orderby = CONTENTREL + ".pos"; } - query = SearchUtil.createRelatedNodeListQuery(channel, destinationManager, - CONTENTREL, null, null, orderby, direction); - } - else { + query = SearchUtil.createRelatedNodeListQuery(channel, destinationManager, CONTENTREL, null, null, orderby, + direction); + } else { if (orderby == null) { orderby = CONTENTREL + ".pos"; } @@ -722,8 +834,9 @@ if (contentchannels.isEmpty()) { throw new IllegalArgumentException("contentchannels or collectionchannel is empty; should be at least one."); } - query = SearchUtil.createRelatedNodeListQuery(contentchannels, destinationManager,CONTENTREL); - SearchUtil.addFeatures(query, contentchannels.getNode(0), destinationManager, CONTENTREL, null, null, orderby, direction); + query = SearchUtil.createRelatedNodeListQuery(contentchannels, destinationManager, CONTENTREL); + SearchUtil.addFeatures(query, contentchannels.getNode(0), destinationManager, CONTENTREL, null, null, orderby, + direction); } if (contenttypes != null && contenttypes.size() > 1) { @@ -743,25 +856,25 @@ ContentElementUtil.addArchiveConstraint(channel, query, date, archive); } - if(year != -1 || month != -1 || day != -1) { + if (year != -1 || month != -1 || day != -1) { Field field = query.getCloud().getNodeManager("contentelement").getField("publishdate"); StepField basicStepField = query.getStepField(field); - if(year != -1) { - SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, - Integer.valueOf(year), FieldValueDateConstraint.YEAR)); + if (year != -1) { + SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, Integer.valueOf(year), + FieldValueDateConstraint.YEAR)); } - if(month != -1) { - SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, - Integer.valueOf(month), FieldValueDateConstraint.MONTH)); + if (month != -1) { + SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, Integer.valueOf(month), + FieldValueDateConstraint.MONTH)); } - if(day != -1) { - SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, - Integer.valueOf(day), FieldValueDateConstraint.DAY_OF_MONTH)); + if (day != -1) { + SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, Integer.valueOf(day), + FieldValueDateConstraint.DAY_OF_MONTH)); } } - if(extraParameters != null) { - for(String key:extraParameters.keySet()) { + if (extraParameters != null) { + for (String key : extraParameters.keySet()) { Object value = extraParameters.get(key); Field field = query.getCloud().getNodeManager("contentelement").getField(key); StepField basicStepField = query.getStepField(field); @@ -773,29 +886,37 @@ return query; } - public static NodeList getCreatedAssets(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, null, offset, maxNumber, year, month, day); + public static NodeList getCreatedAssets(Node channel, List<String> assettypes, String orderby, String direction, + boolean useLifecycle, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, null, offset, + maxNumber, year, month, day); return query.getNodeManager().getList(query); } - - public static NodeList getCreatedAssets(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { - NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day); + public static NodeList getCreatedAssets(Node channel, List<String> assettypes, String orderby, String direction, + boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { + NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, + maxNumber, year, month, day); return query.getNodeManager().getList(query); } - - public static NodeList getCreatedAssets(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day, HashMap<String, Object> extraParameters) { - NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day, extraParameters); + public static NodeList getCreatedAssets(Node channel, List<String> assettypes, String orderby, String direction, + boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day, + HashMap<String, Object> extraParameters) { + NodeQuery query = createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, + maxNumber, year, month, day, extraParameters); return query.getNodeManager().getList(query); } - public static NodeQuery createCreatedAssetQuery(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { - return createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, maxNumber, year, month, day, null); + public static NodeQuery createCreatedAssetQuery(Node channel, List<String> assettypes, String orderby, + String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day) { + return createCreatedAssetQuery(channel, assettypes, orderby, direction, useLifecycle, archive, offset, maxNumber, + year, month, day, null); } - - public static NodeQuery createCreatedAssetQuery(Node channel, List<String> assettypes, String orderby, String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, int day, HashMap<String, Object> extraParameters) { + public static NodeQuery createCreatedAssetQuery(Node channel, List<String> assettypes, String orderby, + String direction, boolean useLifecycle, String archive, int offset, int maxNumber, int year, int month, + int day, HashMap<String, Object> extraParameters) { String sourceManager = ASSETELEMENT; if (assettypes != null && assettypes.size() == 1) { @@ -804,16 +925,16 @@ NodeQuery query; if (isContentChannel(channel)) { - query = SearchUtil.createRelatedNodeListQuery(channel, sourceManager, - CREATIONREL, null, null, orderby, direction, SOURCE); - } - else { + query = SearchUtil.createRelatedNodeListQuery(channel, sourceManager, CREATIONREL, null, null, orderby, + direction, SOURCE); + } else { NodeList contentchannels = SearchUtil.findRelatedNodeList(channel, CONTENTCHANNEL, COLLECTIONREL); if (contentchannels.isEmpty()) { throw new IllegalArgumentException("contentchannels or collectionchannel is empty; should be at least one."); } - query = SearchUtil.createRelatedNodeListQuery(contentchannels, sourceManager,CREATIONREL); - SearchUtil.addFeatures(query, contentchannels.getNode(0), sourceManager, CREATIONREL, null, null, orderby, direction); + query = SearchUtil.createRelatedNodeListQuery(contentchannels, sourceManager, CREATIONREL); + SearchUtil.addFeatures(query, contentchannels.getNode(0), sourceManager, CREATIONREL, null, null, orderby, + direction); } if (assettypes != null && assettypes.size() > 1) { @@ -833,25 +954,25 @@ AssetElementUtil.addArchiveConstraint(channel, query, date, archive); } - if(year != -1 || month != -1 || day != -1) { + if (year != -1 || month != -1 || day != -1) { Field field = query.getCloud().getNodeManager("assetelement").getField("publishdate"); StepField basicStepField = query.getStepField(field); - if(year != -1) { - SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, - Integer.valueOf(year), FieldValueDateConstraint.YEAR)); + if (year != -1) { + SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, Integer.valueOf(year), + FieldValueDateConstraint.YEAR)); } - if(month != -1) { - SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, - Integer.valueOf(month), FieldValueDateConstraint.MONTH)); + if (month != -1) { + SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, Integer.valueOf(month), + FieldValueDateConstraint.MONTH)); } - if(day != -1) { - SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, - Integer.valueOf(day), FieldValueDateConstraint.DAY_OF_MONTH)); + if (day != -1) { + SearchUtil.addConstraint(query, new BasicFieldValueDateConstraint(basicStepField, Integer.valueOf(day), + FieldValueDateConstraint.DAY_OF_MONTH)); } } - if(extraParameters != null) { - for(String key:extraParameters.keySet()) { + if (extraParameters != null) { + for (String key : extraParameters.keySet()) { Object value = extraParameters.get(key); Field field = query.getCloud().getNodeManager("assetelement").getField(key); StepField basicStepField = query.getStepField(field); @@ -869,7 +990,8 @@ public static void removeContentFromChannel(Node content, Node channelNode) { // remove the relations to this content from this channel - RelationIterator contentRelIter = content.getRelations(CONTENTREL, getNodeManager(content.getCloud()), SOURCE).relationIterator(); + RelationIterator contentRelIter = content.getRelations(CONTENTREL, getNodeManager(content.getCloud()), SOURCE) + .relationIterator(); while (contentRelIter.hasNext()) { Relation relation = contentRelIter.nextRelation(); if (relation.getDestination().equals(channelNode) || relation.getSource().equals(channelNode)) { @@ -881,7 +1003,8 @@ } public static void removeContentFromAllChannels(Node content) { - RelationIterator contentRelIter = content.getRelations(CONTENTREL, getNodeManager(content.getCloud()), SOURCE).relationIterator(); + RelationIterator contentRelIter = content.getRelations(CONTENTREL, getNodeManager(content.getCloud()), SOURCE) + .relationIterator(); while (contentRelIter.hasNext()) { Relation relation = contentRelIter.nextRelation(); RepositoryUtil.addDeletionRelation(content, relation.getSource()); @@ -890,11 +1013,11 @@ } /** - * Makes sure the supplied contentelement will have at least one content - * and one creation channel. If the node has to little, it will relate - * to the trash contentchannel. + * Makes sure the supplied contentelement will have at least one content and one creation channel. If the node has to + * little, it will relate to the trash contentchannel. * - * @param contentelement The contentelement to repair the channels of. + * @param contentelement + * The contentelement to repair the channels of. */ public static void repairChannels(Node contentelement) { repairCreationChannel(contentelement); @@ -902,10 +1025,11 @@ } /** - * Makes sure the supplied contentelement will have at least one - * creation channel. If the node has none, it will relate - * to the trash channel. - * @param contentelement The contentelement to repair + * Makes sure the supplied contentelement will have at least one creation channel. If the node has none, it will + * relate to the trash channel. + * + * @param contentelement + * The contentelement to repair */ public static void repairCreationChannel(Node contentelement) { if (!hasCreationChannel(contentelement)) { @@ -916,10 +1040,11 @@ } /** - * Makes sure the supplied contentelement will have at least one - * content channel. If the node has none, it will relate - * to the trash channel. - * @param contentelement The contentelement to repair + * Makes sure the supplied contentelement will have at least one content channel. If the node has none, it will + * relate to the trash channel. + * + * @param contentelement + * The contentelement to repair */ public static void repairContentChannels(Node contentelement) { if (!hasContentChannel(contentelement)) { @@ -935,8 +1060,8 @@ } public static int countDeletionChannels(Node contentNode) { - return contentNode.countRelatedNodes(contentNode.getCloud().getNodeManager( - CONTENTCHANNEL), DELETIONREL, DESTINATION); + return contentNode.countRelatedNodes(contentNode.getCloud().getNodeManager(CONTENTCHANNEL), DELETIONREL, + DESTINATION); } public static NodeList getDeletionChannels(Node elementNode) { @@ -946,8 +1071,10 @@ /** * Create the relation to the deletion relation with this node. * - * @param contentNode - Content Node - * @param channelNumber - Channel Node + * @param contentNode + * - Content Node + * @param channelNumber + * - Channel Node */ public static void addDeletionRelation(Node contentNode, String channelNumber) { Node channel = contentNode.getCloud().getNode(channelNumber); @@ -955,14 +1082,12 @@ } public static void addDeletionRelation(Node contentNode, Node channel) { - RelationManager rm = contentNode.getCloud().getRelationManager( - CONTENTELEMENT, CONTENTCHANNEL, DELETIONREL); + RelationManager rm = contentNode.getCloud().getRelationManager(CONTENTELEMENT, CONTENTCHANNEL, DELETIONREL); contentNode.createRelation(channel, rm).commit(); } public static void addAssetDeletionRelation(Node AssetNode, Node channel) { - RelationManager rm = AssetNode.getCloud().getRelationManager( - ASSETELEMENT, CONTENTCHANNEL, DELETIONREL); + RelationManager rm = AssetNode.getCloud().getRelationManager(ASSETELEMENT, CONTENTCHANNEL, DELETIONREL); AssetNode.createRelation(channel, rm).commit(); } @@ -972,11 +1097,12 @@ } public static void removeDeletionRels(Node contentNode, Node channelNode) { - RelationIterator relIter = contentNode.getRelations(DELETIONREL, getNodeManager(contentNode.getCloud()), DESTINATION).relationIterator(); + RelationIterator relIter = contentNode.getRelations(DELETIONREL, getNodeManager(contentNode.getCloud()), + DESTINATION).relationIterator(); while (relIter.hasNext()) { Relation relation = relIter.nextRelation(); if (relation.getDestination().equals(channelNode) || relation.getSource().equals(channelNode)) { - log.info("removing a found deletionrel with:"+channelNode); + log.info("removing a found deletionrel with:" + channelNode); relation.delete(true); } } @@ -986,7 +1112,7 @@ String[] fragments = TreeUtil.getPathFragments(path); Node parentChannel = getRootNode(cloud); String rootPathFragment = parentChannel.getStringValue(FRAGMENT_FIELD); - if (! rootPathFragment.equals(fragments[0])) { + if (!rootPathFragment.equals(fragments[0])) { throw new IllegalArgumentException("path does not start with root pathfragment (" + rootPathFragment + ")"); } @@ -997,8 +1123,7 @@ Node contentChannel = RepositoryUtil.createChannel(cloud, fragment, fragment); RepositoryUtil.appendChild(parentChannel, contentChannel); parentChannel = contentChannel; - } - else { + } else { parentChannel = RepositoryUtil.getChild(parentChannel, fragment); } } @@ -1048,8 +1173,10 @@ /** * Get the role for the user for a page * - * @param cloud Cloud with user - * @param channel get role for this channel + * @param cloud + * Cloud with user + * @param channel + * get role for this channel * @return UserRole - rights of a user */ public static UserRole getRole(Cloud cloud, int channel) { @@ -1059,8 +1186,10 @@ /** * Get the role for the user for a channel * - * @param group Node of group - * @param channel get role for this channel + * @param group + * Node of group + * @param channel + * get role for this channel * @return UserRole - rights of a user */ public static UserRole getRole(Node group, Node channel) { @@ -1070,27 +1199,33 @@ /** * Get the role for the user for a channel * - * @param cloud Cloud with user - * @param channel get role for this channel - * @param rightsInherited inherit rights from parent chennal + * @param cloud + * Cloud with user + * @param channel + * get role for this channel + * @param rightsInherited + * inherit rights from parent chennal * @return UserRole - rights of a user */ public static UserRole getRole(Cloud cloud, Node channel, boolean rightsInherited) { - TreeMap<String,UserRole> channelsWithRole = SecurityUtil.getLoggedInRoleMap(cloud, treeManagers, CHILDREL); + TreeMap<String, UserRole> channelsWithRole = SecurityUtil.getLoggedInRoleMap(cloud, treeManagers, CHILDREL); return SecurityUtil.getRole(channel, rightsInherited, channelsWithRole); } /** * Get the role for the user for a channel * - * @param group Node of group - * @param channel get role for this channel - * @param rightsInherited inherit rights from parent chennal + * @param group + * Node of group + * @param channel + * get role for this channel + * @param rightsInherited + * inherit rights from parent chennal * @return UserRole - rights of a user */ public static UserRole getRole(Node group, Node channel, boolean rightsInherited) { // retrieve a TreeMap where the channels (keys) are ordered on level and path - TreeMap<String,UserRole> channelsWithRole = SecurityUtil.getNewRolesMap(); + TreeMap<String, UserRole> channelsWithRole = SecurityUtil.getNewRolesMap(); SecurityUtil.fillChannelsWithRole(group, channelsWithRole, treeManagers, CHILDREL); return SecurityUtil.getRole(channel, rightsInherited, channelsWithRole); } @@ -1108,18 +1243,17 @@ if (info == null) { info = new RepositoryInfo(); cloud.setProperty(RepositoryInfo.class.getName(), info); - TreeMap<String,UserRole> channelsWithRole = SecurityUtil.getLoggedInRoleMap(cloud, treeManagers, CHILDREL); + TreeMap<String, UserRole> channelsWithRole = SecurityUtil.getLoggedInRoleMap(cloud, treeManagers, CHILDREL); - for(Map.Entry<String,UserRole> entry : channelsWithRole.entrySet()) { + for (Map.Entry<String, UserRole> entry : channelsWithRole.entrySet()) { UserRole role = entry.getValue(); if (!Role.NONE.equals(role.getRole())) { String path = entry.getKey(); Node channel = getChannelFromPath(cloud, path); - if(channel != null) { + if (channel != null) { if (isRoot(channel)) { info.expand(channel.getNumber()); - } - else { + } else { List<Node> pathNodes = getPathToRoot(channel); for (Node pathNode : pathNodes) { info.expand(pathNode.getNumber()); @@ -1134,7 +1268,7 @@ public static RolesInfo getRolesInfo(Cloud cloud, Node group) { RolesInfo info = new RolesInfo(); - TreeMap<String,UserRole> channelsWithRole = SecurityUtil.getRoleMap(treeManagers, CHILDREL, group); + TreeMap<String, UserRole> channelsWithRole = SecurityUtil.getRoleMap(treeManagers, CHILDREL, group); for (String path : channelsWithRole.keySet()) { Node channel = getChannelFromPath(cloud, path); info.expand(channel.getNumber()); @@ -1142,14 +1276,13 @@ return info; } - - /** - * This is the method for a USER, the old ones want a GROUP... - * (even although the are called getRoleForUser(..) + * This is the method for a USER, the old ones want a GROUP... (even although the are called getRoleForUser(..) * - * @param channel channel to get role for - * @param user user to get role for + * @param channel + * channel to get role for + * @param user + * user to get role for * @return User Role */ public static UserRole getUserRole(Node channel, Node user) { @@ -1160,8 +1293,11 @@ /** * Check if the role has rights on the Recyclebin - * @param cloud Cloud - * @param roleName specified roleName + * + * @param cloud + * Cloud + * @param roleName + * specified roleName * @return boolean */ public static boolean hasRecyclebinRights(Cloud cloud, String roleName) { @@ -1172,17 +1308,17 @@ if (role != null && roleName.equals(role.getRole().getName())) { return true; - } - else { + } else { return false; } } /** * get all Content Channels + * * @return content channel list */ - public static NodeList getAllContentChannels(Cloud cloud){ + public static NodeList getAllContentChannels(Cloud cloud) { NodeList contentChannels = getContentChannelOrderedChildren(getRootNode(cloud)); contentChannels.add(0, getRootNode(cloud)); return contentChannels; @@ -1192,5 +1328,3 @@ RepositoryUtil.addDeletionRelation(asset, channelNode); } } - - \ No newline at end of file _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs