You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(3) |
Oct
(191) |
Nov
(124) |
Dec
(74) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(20) |
Feb
(20) |
Mar
(38) |
Apr
(67) |
May
(18) |
Jun
(6) |
Jul
(27) |
Aug
|
Sep
(20) |
Oct
(7) |
Nov
(5) |
Dec
(21) |
2006 |
Jan
(4) |
Feb
(4) |
Mar
(8) |
Apr
(26) |
May
(6) |
Jun
(17) |
Jul
(12) |
Aug
(3) |
Sep
(3) |
Oct
(10) |
Nov
|
Dec
(7) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(3) |
Jun
(8) |
Jul
|
Aug
|
Sep
(12) |
Oct
|
Nov
(10) |
Dec
(3) |
2008 |
Jan
(8) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
From: Nico K. <nkl...@us...> - 2007-06-04 07:39:16
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10757/remotepublishing Modified Files: project.properties project.xml Log Message: Added support for updates of relations between nodes Index: project.properties =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** project.properties 17 Oct 2006 10:02:54 -0000 1.2 --- project.properties 4 Jun 2007 07:39:03 -0000 1.3 *************** *** 3,6 **** --- 3,9 ---- maven.multiproject.type=mmbase-module + mmbase.version=1.8.4-20070320 + mmbasermmci.version=1.8.2-20061020 + # Specifies the version of the jdk in use. maven.compile.source=1.5 Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** project.xml 18 Apr 2007 07:53:54 -0000 1.6 --- project.xml 4 Jun 2007 07:39:03 -0000 1.7 *************** *** 5,9 **** <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.12-SNAPSHOT</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> --- 5,9 ---- <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.12</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> *************** *** 24,28 **** <groupId>mmbase</groupId> <artifactId>mmbase</artifactId> ! <version>1.8.1-20060910</version> <url>http://www.mmbase.org/</url> </dependency> --- 24,28 ---- <groupId>mmbase</groupId> <artifactId>mmbase</artifactId> ! <version>${mmbase.version}</version> <url>http://www.mmbase.org/</url> </dependency> *************** *** 30,34 **** <groupId>mmbase</groupId> <artifactId>mmbase-rmmci</artifactId> ! <version>1.8.1-20060921</version> <url>http://www.mmbase.org/</url> </dependency> --- 30,34 ---- <groupId>mmbase</groupId> <artifactId>mmbase-rmmci</artifactId> ! <version>${mmbasermmci.version}</version> <url>http://www.mmbase.org/</url> </dependency> |
From: Nico K. <nkl...@us...> - 2007-06-04 07:39:16
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10757/remotepublishing/src/org/mmbase/remotepublishing Modified Files: PublishManager.java PublishException.java Log Message: Added support for updates of relations between nodes Index: PublishException.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PublishException.java 18 Jul 2004 14:59:22 -0000 1.1 --- PublishException.java 4 Jun 2007 07:39:02 -0000 1.2 *************** *** 15,24 **** - /** - * @author Nico Klasens - * @version $Revision$ - */ public class PublishException extends Exception { /** * @param message exception message --- 15,22 ---- public class PublishException extends Exception { + private static final long serialVersionUID = -5600625093903580389L; + /** * @param message exception message Index: PublishManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PublishManager.java 18 Apr 2007 07:50:11 -0000 1.5 --- PublishManager.java 4 Jun 2007 07:39:02 -0000 1.6 *************** *** 115,137 **** * @param localNode the node to be published * @param remoteCloudInfo the external cloud * @return the published copy of inNode * @throws PublishException - when publication fails */ ! public static Node publishNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo) throws PublishException { synchronized (publishLock) { ! log.debug("publishNode called with node (number,type)" + ! localNode.getNumber() + "," + localNode.getNodeManager().getName() + ")"); NodeManager nm = localNode.getNodeManager(); ! if (nm.getName().equals(MMBASE_PUBLISH_MANAGER)) { throw new PublishException("Cannot publish publishing info!"); } ! if (isPublished(localCloudInfo, localNode.getNumber(), remoteCloudInfo) || isImported(localCloudInfo, localNode.getNumber(), remoteCloudInfo)) { throw new PublishException("Attempt to publish Node #" + localNode.getNumber() + " twice to the same cloud"); } ! if (isRelation(localNode)) { if ((localNode.getValue("rnumber") == null) || --- 115,149 ---- * @param localNode the node to be published * @param remoteCloudInfo the external cloud + * @param createRelations create the relations to other nodes * @return the published copy of inNode * @throws PublishException - when publication fails */ ! public static Node createNodeAndRelations(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, boolean createRelations) throws PublishException { synchronized (publishLock) { ! Node remoteNode = createNode(localCloudInfo, localNode, remoteCloudInfo); ! if (createRelations) { ! cloneRelations(localCloudInfo, localNode, remoteCloudInfo); ! } ! return remoteNode; ! } ! } + private static Node createNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo) + throws PublishException { + synchronized (publishLock) { + log.debug("publishNode called with node (number,type)" + + localNode.getNumber() + "," + localNode.getNodeManager().getName() + ")"); + NodeManager nm = localNode.getNodeManager(); ! if (nm.getName().equals(MMBASE_PUBLISH_MANAGER)) { throw new PublishException("Cannot publish publishing info!"); } ! if (isPublished(localCloudInfo, localNode.getNumber(), remoteCloudInfo) || isImported(localCloudInfo, localNode.getNumber(), remoteCloudInfo)) { throw new PublishException("Attempt to publish Node #" + localNode.getNumber() + " twice to the same cloud"); } ! if (isRelation(localNode)) { if ((localNode.getValue("rnumber") == null) || *************** *** 140,144 **** throw new PublishException("Attempt to publish invalid relation"); } ! // relations should only be published when both the source and the destination node are either // 1) published to the other cloud --- 152,156 ---- throw new PublishException("Attempt to publish invalid relation"); } ! // relations should only be published when both the source and the destination node are either // 1) published to the other cloud *************** *** 151,171 **** } } ! // copy the node to the remote cloud Node remoteNode = cloneNode(localCloudInfo, localNode, remoteCloudInfo); ! if (remoteNode == null) { throw new PublishException("cloneNodeRemote for node #" + localNode.getNumber() + " returned null"); } else { ! if (log.isDebugEnabled()) { ! //getNumber is a rmi call to the other server don't want that unless debugging ! log.debug("cloned the node to the new cloud new node(number,type)" + ! remoteNode.getNumber() + "," + remoteNode.getNodeManager().getName() + ")"); ! } } createPublishingInfo(localCloudInfo, localNode, remoteCloudInfo, remoteNode); - cloneRelations(localCloudInfo, localNode, remoteCloudInfo); - return remoteNode; } --- 163,181 ---- } } ! // copy the node to the remote cloud Node remoteNode = cloneNode(localCloudInfo, localNode, remoteCloudInfo); ! if (remoteNode == null) { throw new PublishException("cloneNodeRemote for node #" + localNode.getNumber() + " returned null"); } else { ! if (log.isDebugEnabled()) { ! //getNumber is a rmi call to the other server don't want that unless debugging ! log.debug("cloned the node to the new cloud new node(number,type)" + ! remoteNode.getNumber() + "," + remoteNode.getNodeManager().getName() + ")"); ! } } createPublishingInfo(localCloudInfo, localNode, remoteCloudInfo, remoteNode); return remoteNode; } *************** *** 296,305 **** result.addAll(localNode.getRelations(null, nodeManager, "destination")); ! RelationIterator ri = result.relationIterator(); ! if (ri.hasNext()) { ! log.debug("the local node has relations"); ! } while (ri.hasNext()) { ! Relation rel = ri.nextRelation(); Node relatedNode = null; --- 306,318 ---- result.addAll(localNode.getRelations(null, nodeManager, "destination")); ! cloneRelations(localCloudInfo, localNode, remoteCloudInfo, result); ! } ! ! private static void cloneRelations(CloudInfo localCloudInfo, Node localNode, ! CloudInfo remoteCloudInfo, List<Relation> result) throws PublishException { ! ! Iterator<Relation> ri = result.iterator(); while (ri.hasNext()) { ! Relation rel = ri.next(); Node relatedNode = null; *************** *** 324,328 **** log.debug("the related object is published/imported and the relation is also published " + "(we will just update the relation node)"); ! updatePublishedNodes(localCloudInfo, rel); } else { --- 337,341 ---- log.debug("the related object is published/imported and the relation is also published " + "(we will just update the relation node)"); ! updateNodesAndRelations(localCloudInfo, rel, true, true); } else { *************** *** 332,336 **** } else { log.debug("the related object is published/imported but the relation is not yet published"); ! publishNode(localCloudInfo, rel, remoteCloudInfo); } } else { --- 345,349 ---- } else { log.debug("the related object is published/imported but the relation is not yet published"); ! createNodeAndRelations(localCloudInfo, rel, remoteCloudInfo, true); } } else { *************** *** 376,380 **** * @param localNode The node to be checked * @return <code>true</code> if the node has been published to the other cloud - * @deprecated */ public static boolean isPublished(Node localNode) { --- 389,392 ---- *************** *** 424,428 **** * @param remoteCloudInfo the cloud to which the node is published * @return <code>true</code> if node has been published to cloud - * @deprecated */ public static boolean isPublished(Node localNode, CloudInfo remoteCloudInfo) { --- 436,439 ---- *************** *** 514,518 **** * @param remoteCloudInfo the Cloud from which the node might be published * @return <cdeo>true</code> if node was imported from cloud - * @deprecated */ public static boolean isImported(Node localNode, CloudInfo remoteCloudInfo) { --- 525,528 ---- *************** *** 562,566 **** CloudInfo sourceCloudInfo = localCloudInfo; Node sourceNode = localNode; ! Map<Integer, List<Node>> nodesListMap = getPublishedNodes(sourceCloudInfo, sourceNode.getNumber()); Iterator<Integer> cloudNumberIterator = nodesListMap.keySet().iterator(); --- 572,576 ---- CloudInfo sourceCloudInfo = localCloudInfo; Node sourceNode = localNode; ! Map<Integer, List<Node>> nodesListMap = getPublishedNodesIncludeCorrupt(sourceCloudInfo, sourceNode.getNumber()); Iterator<Integer> cloudNumberIterator = nodesListMap.keySet().iterator(); *************** *** 580,585 **** Node destinationNode = localNode; //TODO: need to find the reference part to change the invoke name ! CloudInfo sourceCloudInfo = getSourceCloud(destinationCloudInfo, destinationNode); ! unLinkNode(sourceCloudInfo, destinationCloudInfo, destinationNode.getNumber()); } } --- 590,596 ---- Node destinationNode = localNode; //TODO: need to find the reference part to change the invoke name ! int destionationNumber = destinationNode.getNumber(); ! CloudInfo sourceCloudInfo = getSourceCloud(destinationCloudInfo, destionationNumber); ! unLinkNode(sourceCloudInfo, destinationCloudInfo, destionationNumber); } } *************** *** 720,724 **** * @return List of all remote nodes */ ! public static Map<Integer,List<Node>> getPublishedNodes(Node localNode) { return getPublishedNodes(CloudInfo.getDefaultCloudInfo(), localNode.getNumber()); } --- 731,735 ---- * @return List of all remote nodes */ ! public static Map<Integer,Node> getPublishedNodes(Node localNode) { return getPublishedNodes(CloudInfo.getDefaultCloudInfo(), localNode.getNumber()); } *************** *** 731,735 **** * @return List of all remote nodes */ ! public static Map<Integer,List<Node>> getPublishedNodes(CloudInfo localCloudInfo, int localNumber) { NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); return getPublishedNodes(publishInfoNodes); --- 742,746 ---- * @return List of all remote nodes */ ! public static Map<Integer,Node> getPublishedNodes(CloudInfo localCloudInfo, int localNumber) { NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); return getPublishedNodes(publishInfoNodes); *************** *** 742,758 **** * @return List of all remote nodes */ ! public static Map<Integer, List<Node>> getPublishedNodes(NodeList publishInfoNodes) { NodeIterator ni = publishInfoNodes.nodeIterator(); ! Map<Integer,List<Node>> returnMap = new HashMap<Integer,List<Node>>(); while (ni.hasNext()) { Node admin = ni.nextNode(); int destinationCloudNumber = admin.getIntValue(DESTINATION_CLOUD); ! List<Node> publishNodesList = returnMap.get(destinationCloudNumber); ! if (publishNodesList==null) { ! publishNodesList = new ArrayList<Node>(); ! returnMap.put(destinationCloudNumber, publishNodesList); } Node remotePublishedNode = getRemoteNode(admin); ! publishNodesList.add(remotePublishedNode); } --- 753,770 ---- * @return List of all remote nodes */ ! public static Map<Integer, Node> getPublishedNodes(NodeList publishInfoNodes) { NodeIterator ni = publishInfoNodes.nodeIterator(); ! Map<Integer,Node> returnMap = new HashMap<Integer,Node>(); while (ni.hasNext()) { Node admin = ni.nextNode(); int destinationCloudNumber = admin.getIntValue(DESTINATION_CLOUD); ! if (returnMap.containsKey(destinationCloudNumber)) { ! log.error( ! "Detected multiple instances of a publish-info node, but it should only be one " + ! "in all xases (published from or imported to the local cloud). " + ! "still returning the first node"); } Node remotePublishedNode = getRemoteNode(admin); ! returnMap.put(destinationCloudNumber, remotePublishedNode); } *************** *** 760,763 **** --- 772,823 ---- } + /** + * Get the published node numbers from all remote clouds + * + * @param localNode The node thas has been published + * @return List of all remote nodes + */ + public static Map<Integer,Integer> getPublishedNodeNumbers(Node localNode) { + return getPublishedNodeNumbers(CloudInfo.getDefaultCloudInfo(), localNode.getNumber()); + } + + /** + * Get the published node numbers from all remote clouds + * + * @param localCloudInfo The source cloud + * @param localNumber The node number that has been published + * @return List of all remote nodes + */ + public static Map<Integer,Integer> getPublishedNodeNumbers(CloudInfo localCloudInfo, int localNumber) { + NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); + return getPublishedNodeNumbers(publishInfoNodes); + } + + /** + * Get the published node numbers from all remote clouds + * + * @param publishInfoNodes The publish Info Nodes + * @return List of all remote nodes + */ + public static Map<Integer, Integer> getPublishedNodeNumbers(NodeList publishInfoNodes) { + NodeIterator ni = publishInfoNodes.nodeIterator(); + Map<Integer, Integer> returnMap = new HashMap<Integer,Integer>(); + while (ni.hasNext()) { + Node admin = ni.nextNode(); + int destinationCloudNumber = admin.getIntValue(DESTINATION_CLOUD); + if (returnMap.containsKey(destinationCloudNumber)) { + log.error( + "Detected multiple instances of a publish-info node, but it should only be one " + + "in all xases (published from or imported to the local cloud). " + + "still returning the first node"); + } + int destinationNodeNumber = admin.getIntValue(DESTINATION_NUMBER); + returnMap.put(destinationCloudNumber, destinationNodeNumber); + } + + return returnMap; + } + + private static Node getRemoteNode(Node admin) { int destinationCloudNumber = admin.getIntValue(DESTINATION_CLOUD); *************** *** 814,823 **** * Gets the source cloud of this destination node * @param destinationCloudInfo destination cloud to which the destination node are published ! * @param destinationNode a published node * @return the sourceCloud from which the destinationNode was published * or null if node was not imported */ ! private static CloudInfo getSourceCloud(CloudInfo destinationCloudInfo, Node destinationNode) { ! Node adminNode = getPublishInfoNode(destinationCloudInfo, destinationNode.getNumber(), destinationCloudInfo); if (adminNode == null) { --- 874,883 ---- * Gets the source cloud of this destination node * @param destinationCloudInfo destination cloud to which the destination node are published ! * @param destinationNumber a published node * @return the sourceCloud from which the destinationNode was published * or null if node was not imported */ ! private static CloudInfo getSourceCloud(CloudInfo destinationCloudInfo, int destinationNumber) { ! Node adminNode = getPublishInfoNode(destinationCloudInfo, destinationNumber, destinationCloudInfo); if (adminNode == null) { *************** *** 883,886 **** --- 943,947 ---- } } + /** *************** *** 889,895 **** * @param localCloudInfo the cloud from which the local node are published * @param localNode the source node * @throws PublishException - when publication fails **/ ! public static void updatePublishedNodes(CloudInfo localCloudInfo, Node localNode) throws PublishException { synchronized (publishLock) { --- 950,974 ---- * @param localCloudInfo the cloud from which the local node are published * @param localNode the source node + * @param updateNode sync the node + * @param updateRelations sync the relations to other nodes * @throws PublishException - when publication fails **/ ! public static void updateNodesAndRelations(CloudInfo localCloudInfo, Node localNode, ! boolean updateNode, boolean updateRelations) throws PublishException { ! updateNodesAndRelations(localCloudInfo, localNode, updateNode, updateRelations, null); ! } ! ! /** ! * syncronize all nodes that are published from this one ! * ! * @param localCloudInfo the cloud from which the local node are published ! * @param localNode the source node ! * @param updateNode sync the node ! * @param updateRelations sync the relations to other nodes ! * @param relatedNodes relations between localnode and these numbers should be updated ! * @throws PublishException - when publication fails ! **/ ! public static void updateNodesAndRelations(CloudInfo localCloudInfo, Node localNode, ! boolean updateNode, boolean updateRelations, List<Integer> relatedNodes) throws PublishException { synchronized (publishLock) { *************** *** 908,912 **** } ! Map<Integer,List<Node>> publishedNodesMap = getPublishedNodes(publishInfoNodes); Iterator<Integer> cloudNumberIterator = publishedNodesMap.keySet().iterator(); --- 987,991 ---- } ! Map<Integer,Node> publishedNodesMap = getPublishedNodes(publishInfoNodes); Iterator<Integer> cloudNumberIterator = publishedNodesMap.keySet().iterator(); *************** *** 914,921 **** int remoteCloudNumber = cloudNumberIterator.next(); CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); ! Iterator<Node> remoteNodeIterator = publishedNodesMap.get(remoteCloudNumber).iterator(); ! while (remoteNodeIterator.hasNext()) { ! Node remoteNode = remoteNodeIterator.next(); ! syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } --- 993,1012 ---- int remoteCloudNumber = cloudNumberIterator.next(); CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); ! Node remoteNode = publishedNodesMap.get(remoteCloudNumber); ! if (updateNode && updateRelations) { ! syncNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); ! } ! else { ! if (updateNode) { ! syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); ! } ! if (updateRelations) { ! if (relatedNodes != null && relatedNodes.size() > 0) { ! syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode, relatedNodes); ! } ! else { ! syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); ! } ! } } } *************** *** 939,955 **** } ! private static void syncNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, Node remoteNode) throws PublishException { if (remoteNode != null) { ! syncFields(localCloudInfo, localNode, remoteCloudInfo, remoteNode); ! syncAliasses(localNode, remoteNode); ! remoteNode.commit(); ! updatePublishInfoNode(localCloudInfo, remoteCloudInfo, remoteNode.getNumber()); syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } ! public static void updatePublishedNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo) throws PublishException { synchronized (publishLock) { if (!isPublished(localCloudInfo, localNode)) { --- 1030,1054 ---- } ! private static void syncNodeAndRelations(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, Node remoteNode) throws PublishException { if (remoteNode != null) { ! syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } + public static void syncNode(CloudInfo localCloudInfo, Node localNode, + CloudInfo remoteCloudInfo, Node remoteNode) { + if (remoteNode != null) { + syncFields(localCloudInfo, localNode, remoteCloudInfo, remoteNode); + boolean aliasChanged = syncAliasses(localNode, remoteNode); + if (aliasChanged || remoteNode.isChanged()) { + remoteNode.commit(); + updatePublishInfoNode(localCloudInfo, remoteCloudInfo, remoteNode.getNumber()); + } + } + } ! public static void updatePublishedNodeAndRelations(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo) throws PublishException { synchronized (publishLock) { if (!isPublished(localCloudInfo, localNode)) { *************** *** 958,962 **** Node remoteNode = getPublishedNode(localCloudInfo, localNode, remoteCloudInfo); ! syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } --- 1057,1061 ---- Node remoteNode = getPublishedNode(localCloudInfo, localNode, remoteCloudInfo); ! syncNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } *************** *** 983,990 **** } ! private static void syncAliasses(Node localNode, Node remoteNode) { StringList list = localNode.getAliases(); StringList outList = remoteNode.getAliases(); ! int outListSize = outList.size(); for (int x = 0; x < outListSize; x++) { --- 1082,1090 ---- } ! private static boolean syncAliasses(Node localNode, Node remoteNode) { StringList list = localNode.getAliases(); StringList outList = remoteNode.getAliases(); ! boolean aliasChanged = false; ! int outListSize = outList.size(); for (int x = 0; x < outListSize; x++) { *************** *** 992,995 **** --- 1092,1096 ---- if (!list.contains(remoateAlias)) { remoteNode.deleteAlias(remoateAlias); + aliasChanged = true; } } *************** *** 1000,1043 **** if (!outList.contains(localAlias)) { remoteNode.createAlias(localAlias); } } } ! private static void syncRelations( CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, Node remoteNode) throws PublishException { ! if (localNode.getNodeManager().getAllowedRelations().isEmpty()) { return; } ! ! RelationList remoteRelationList = remoteNode.getRelations(); ! int size = remoteRelationList.size(); ! for (int x = 0; x < size; x++) { ! Relation remoteRelation = remoteRelationList.getRelation(x); ! ! Node adminNode = getPublishInfoNode(localCloudInfo, remoteRelation.getNumber(), remoteCloudInfo); ! if (adminNode != null) { ! boolean deleted = false; ! try { ! Node sourceNode = localCloudInfo.getCloud().getNode(adminNode.getIntValue(SOURCE_NUMBER)); ! if (sourceNode == null) { ! deleted = true; ! } ! ! } catch(NotFoundException nfe) { ! deleted = true; ! } ! if (deleted) { ! if (log.isDebugEnabled()) { ! //getNumber is a rmi call to the other server don't want that unless debugging ! log.debug("found publishinginfo for remote relation " + remoteRelation.getNumber() + ! ", but the node is deleted. localCloud is onwer. Unlink and delete remoteRelation"); } ! deleteNodeFromRemoteCloud(localCloudInfo, remoteRelation, remoteCloudInfo); ! } ! } ! } ! ! cloneRelations(localCloudInfo, localNode, remoteCloudInfo); } /** --- 1101,1199 ---- if (!outList.contains(localAlias)) { remoteNode.createAlias(localAlias); + aliasChanged = true; } } + return aliasChanged; } ! public static void syncRelations( CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, Node remoteNode) throws PublishException { if (localNode.getNodeManager().getAllowedRelations().isEmpty()) { return; } ! if (remoteNode != null) { ! RelationList remoteRelationList = remoteNode.getRelations(); ! removeRemoteRelationWhenLocalRemoved(localCloudInfo, remoteCloudInfo, remoteRelationList); ! cloneRelations(localCloudInfo, localNode, remoteCloudInfo); ! } ! } ! ! public static void syncRelations( CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, ! Node remoteNode, List<Integer> relatedNodes) throws PublishException { ! if (localNode.getNodeManager().getAllowedRelations().isEmpty()) { ! return; ! } ! if (remoteNode != null) { ! String remoteNumbers = ""; ! for (Integer localNumber : relatedNodes) { ! int remoteNumber = getDestinationNumber(localCloudInfo, remoteCloudInfo, localNumber); ! if (remoteNumber > -1) { ! remoteNumbers += (remoteNumbers.length() > 0) ? "," + remoteNumber : remoteNumber; } ! } ! if (remoteNumbers.length() > 0) { ! List<Node> remoteRelationList = new ArrayList<Node>(); ! ! NodeManager insrel = remoteCloudInfo.getCloud().getNodeManager("insrel"); ! NodeList relations = insrel.getList("snumber = " + remoteNode.getNumber() + " AND dnumber in (" + remoteNumbers + ")" , null, null); ! remoteRelationList.addAll(relations); ! relations = insrel.getList("dnumber = " + remoteNode.getNumber() + " AND snumber in (" + remoteNumbers + ")" , null, null); ! remoteRelationList.addAll(relations); ! ! String localNumbers = ""; ! for (Integer localNumber : relatedNodes) { ! localNumbers += (localNumbers.length() > 0) ? "," + localNumber : localNumber; ! } ! ! List<Relation> localRelationList = new ArrayList<Relation>(); ! NodeManager insrellocal = localCloudInfo.getCloud().getNodeManager("insrel"); ! NodeList relationslocal = insrellocal.getList("snumber = " + localNode.getNumber() + " AND dnumber in (" + localNumbers + ")" , null, null); ! for (Iterator<Node> iterator = relationslocal.iterator(); iterator.hasNext();) { ! Node localRel = iterator.next(); ! localRelationList.add(localRel.toRelation()); ! } ! relationslocal = insrellocal.getList("dnumber = " + localNode.getNumber() + " AND snumber in (" + localNumbers + ")" , null, null); ! for (Iterator<Node> iterator = relationslocal.iterator(); iterator.hasNext();) { ! Node localRel = iterator.next(); ! localRelationList.add(localRel.toRelation()); ! } ! ! removeRemoteRelationWhenLocalRemoved(localCloudInfo, remoteCloudInfo, remoteRelationList); ! cloneRelations(localCloudInfo, localNode, remoteCloudInfo, localRelationList); ! } ! } } + + + + + private static void removeRemoteRelationWhenLocalRemoved(CloudInfo localCloudInfo, + CloudInfo remoteCloudInfo, List<Node> remoteRelationList) { + int size = remoteRelationList.size(); + for (int x = 0; x < size; x++) { + Node remoteRelation = remoteRelationList.get(x); + + Node adminNode = getPublishInfoNode(localCloudInfo, remoteRelation.getNumber(), remoteCloudInfo); + if (adminNode != null) { + boolean deleted = false; + try { + Node sourceNode = localCloudInfo.getCloud().getNode(adminNode.getIntValue(SOURCE_NUMBER)); + if (sourceNode == null) { + deleted = true; + } + + } catch(NotFoundException nfe) { + deleted = true; + } + if (deleted) { + if (log.isDebugEnabled()) { + //getNumber is a rmi call to the other server don't want that unless debugging + log.debug("found publishinginfo for remote relation " + remoteRelation.getNumber() + + ", but the node is deleted. localCloud is onwer. Unlink and delete remoteRelation"); + } + deleteNodeFromRemoteCloud(localCloudInfo, remoteRelation, remoteCloudInfo); + } + } + } + } /** *************** *** 1062,1066 **** NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); ! Map<Integer, List<Node>> publishedNodesMap = getPublishedNodes(publishInfoNodes); log.debug("the node is published on " + publishedNodesMap.size() + " clouds"); --- 1218,1222 ---- NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); ! Map<Integer, List<Node>> publishedNodesMap = getPublishedNodesIncludeCorrupt(publishInfoNodes); log.debug("the node is published on " + publishedNodesMap.size() + " clouds"); *************** *** 1085,1088 **** --- 1241,1280 ---- } + /** + * Get the published nodes from all remote clouds + * + * @param localCloudInfo The source cloud + * @param localNumber The node number that has been published + * @return List of all remote nodes + */ + public static Map<Integer,List<Node>> getPublishedNodesIncludeCorrupt(CloudInfo localCloudInfo, int localNumber) { + NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); + return getPublishedNodesIncludeCorrupt(publishInfoNodes); + } + + /** + * Get the published nodes from all remote clouds + * + * @param publishInfoNodes The publish Info Nodes + * @return List of all remote nodes + */ + private static Map<Integer, List<Node>> getPublishedNodesIncludeCorrupt(NodeList publishInfoNodes) { + NodeIterator ni = publishInfoNodes.nodeIterator(); + Map<Integer,List<Node>> returnMap = new HashMap<Integer,List<Node>>(); + while (ni.hasNext()) { + Node admin = ni.nextNode(); + int destinationCloudNumber = admin.getIntValue(DESTINATION_CLOUD); + List<Node> publishNodesList = returnMap.get(destinationCloudNumber); + if (publishNodesList==null) { + publishNodesList = new ArrayList<Node>(); + returnMap.put(destinationCloudNumber, publishNodesList); + } + Node remotePublishedNode = getRemoteNode(admin); + publishNodesList.add(remotePublishedNode); + } + + return returnMap; + } + private static void deleteNodeFromRemoteCloud(CloudInfo localCloudInfo, Node remoteNode, CloudInfo remoteCloudInfo) { //get a list of relations from the remote node *************** *** 1121,1125 **** public static void unLinkImportedNode(int number) { CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! unLinkNode(localCloudInfo, localCloudInfo.getCloud().getNode(number)); } --- 1313,1318 ---- public static void unLinkImportedNode(int number) { CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! CloudInfo sourceCloudInfo = getSourceCloud(localCloudInfo, number); ! unLinkNode(sourceCloudInfo, localCloudInfo, number); } |
From: Nico K. <nkl...@us...> - 2007-06-04 07:39:16
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10757/remotepublishing/src/org/mmbase/remotepublishing/util Modified Files: PublishUtil.java Log Message: Added support for updates of relations between nodes Index: PublishUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/PublishUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PublishUtil.java 18 Apr 2007 07:48:28 -0000 1.5 --- PublishUtil.java 4 Jun 2007 07:39:04 -0000 1.6 *************** *** 20,23 **** --- 20,24 ---- import org.mmbase.bridge.*; import org.mmbase.module.core.*; + import org.mmbase.remotepublishing.builders.PublishingQueueBuilder; import org.mmbase.util.logging.*; *************** *** 74,78 **** public static void publishOrUpdateNode(Cloud cloud, int number, Date publishDate) { log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, -1, "update", publishDate); } --- 75,79 ---- public static void publishOrUpdateNode(Cloud cloud, int number, Date publishDate) { log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, -1, PublishingQueueBuilder.ACTION_UPDATE, publishDate, null); } *************** *** 97,101 **** public static void removeNode(Cloud cloud, int number, Date publishDate) { log.debug("removeNode with number = " + number); ! createQueueNode(cloud, number, -1, "remove", publishDate); } --- 98,103 ---- public static void removeNode(Cloud cloud, int number, Date publishDate) { log.debug("removeNode with number = " + number); ! String action = PublishingQueueBuilder.ACTION_REMOVE; ! createQueueNode(cloud, number, -1, action, publishDate, null); } *************** *** 143,148 **** public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, Date publishDate) { log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, cloudNumber, "update", publishDate); } --- 145,171 ---- public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, Date publishDate) { + publishOrUpdateNode(cloud, number, cloudNumber, publishDate, true); + } + + public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, Date publishDate, boolean relations) { log.debug("PublishOrUpdateNode with number = " + number); ! String action; ! if (relations) { ! action = PublishingQueueBuilder.ACTION_UPDATE; ! } ! else { ! action = PublishingQueueBuilder.ACTION_UPDATE_NODE; ! } ! ! createQueueNode(cloud, number, cloudNumber, action, publishDate, null); ! } ! ! public static void publishOrUpdateRelations(Cloud cloud, int number, List<Integer> relatedNodes) { ! publishOrUpdateRelations(cloud, number, -1, relatedNodes); ! } ! ! public static void publishOrUpdateRelations(Cloud cloud, int number, int cloudNumber, List<Integer> relatedNodes) { ! String action = PublishingQueueBuilder.ACTION_UPDATE_RELATIONS; ! createQueueNode(cloud, number, cloudNumber, action, null, relatedNodes); } *************** *** 151,165 **** } ! private static void createQueueNode(Cloud cloud, int number, int cloudNumber, String action, Date publishDate) { NodeManager nodeManager = cloud.getNodeManager("publishqueue"); Node node = nodeManager.createNode(); ! node.setIntValue("sourcenumber", number); ! node.setStringValue("action", action); if (cloudNumber > 0) { ! node.setIntValue("destinationcloud", cloudNumber); } if (publishDate != null) { ! node.setDateValue("publishdate", publishDate); } node.commit(); } --- 174,197 ---- } ! private static void createQueueNode(Cloud cloud, int number, int cloudNumber, String action, ! Date publishDate, List<Integer> relatedNodes) { NodeManager nodeManager = cloud.getNodeManager("publishqueue"); Node node = nodeManager.createNode(); ! node.setIntValue(PublishingQueueBuilder.FIELD_SOURCENUMBER, number); ! node.setStringValue(PublishingQueueBuilder.FIELD_ACTION, action); if (cloudNumber > 0) { ! node.setIntValue(PublishingQueueBuilder.FIELD_DESTINATIONCLOUD, cloudNumber); } if (publishDate != null) { ! node.setDateValue(PublishingQueueBuilder.FIELD_PUBLISHDATE, publishDate); ! } ! if (relatedNodes != null && relatedNodes.size() > 0) { ! String localNumbers = ""; ! for (Integer localNumber : relatedNodes) { ! localNumbers += (localNumbers.length() > 0) ? "," + localNumber : localNumber; ! } ! node.setStringValue(PublishingQueueBuilder.FIELD_RELATEDNODES, localNumbers); } + node.commit(); } |
From: Nico K. <nkl...@us...> - 2007-06-04 07:39:16
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10757/remotepublishing/config/applications/Publisher/builders Modified Files: publishqueue.xml Log Message: Added support for updates of relations between nodes Index: publishqueue.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/publishqueue.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** publishqueue.xml 16 Dec 2006 13:14:49 -0000 1.3 --- publishqueue.xml 4 Jun 2007 07:39:04 -0000 1.4 *************** *** 99,103 **** <!-- update , delete , publish --> <name>action</name> ! <type state="persistent" size="12" notnull="true">STRING</type> </db> </field> --- 99,103 ---- <!-- update , delete , publish --> <name>action</name> ! <type state="persistent" size="32" notnull="true">STRING</type> </db> </field> *************** *** 167,170 **** --- 167,190 ---- </db> </field> + + <field> + <gui> + <guiname xml:lang="us">relatednodes</guiname> + <guiname xml:lang="en">relatednodes</guiname> + <guiname xml:lang="nl">relatednodes</guiname> + </gui> + <editor> + <positions> + <input>5</input> + <list>5</list> + <search>5</search> + </positions> + </editor> + <datatype base="field" xmlns="http://www.mmbase.org/xmlns/datatypes"/> + <db> + <name>relatednodes</name> + <type state="persistent" size="4096" notnull="true">STRING</type> + </db> + </field> </fieldlist> |
From: Nico K. <nkl...@us...> - 2007-05-25 13:00:01
|
Update of /cvsroot/mmapps/mmapps/mmcommons In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11641/mmcommons Modified Files: project.xml Log Message: version 1.3.7 Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/project.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** project.xml 17 Oct 2006 10:02:24 -0000 1.8 --- project.xml 25 May 2007 12:59:58 -0000 1.9 *************** *** 6,10 **** <artifactId>mmcommons</artifactId> <name>MMBase Commons</name> ! <currentVersion>1.3.6.2</currentVersion> <package>net.sf.mmapps.commons</package> <shortDescription>MMCommons - Java components for MMbase apps</shortDescription> --- 6,10 ---- <artifactId>mmcommons</artifactId> <name>MMBase Commons</name> ! <currentVersion>1.3.7</currentVersion> <package>net.sf.mmapps.commons</package> <shortDescription>MMCommons - Java components for MMbase apps</shortDescription> |
From: Nico K. <nkl...@us...> - 2007-05-25 12:58:56
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/web In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11166/mmcommons/src/java/net/sf/mmapps/commons/web Modified Files: FriendlyUrlFilter.java Log Message: Some small fixes Index: FriendlyUrlFilter.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/web/FriendlyUrlFilter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FriendlyUrlFilter.java 17 Oct 2006 10:02:23 -0000 1.3 --- FriendlyUrlFilter.java 25 May 2007 12:58:45 -0000 1.4 *************** *** 83,86 **** --- 83,94 ---- return; } + } catch(IOException ioe) { + if (ioe.getMessage().indexOf("Broken pipe") > -1) { + log.info("IO error " + ioe.getMessage()); + } + else { + log.error("IO error " + ioe); + } + return; } catch (Exception ex) { log.fatal("can't process exclude pattern", ex); |
From: Nico K. <nkl...@us...> - 2007-05-25 12:58:52
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11166/mmcommons/src/java/net/sf/mmapps/commons/util Modified Files: HttpUtil.java KeywordUtil.java Log Message: Some small fixes Index: KeywordUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/KeywordUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** KeywordUtil.java 6 Apr 2006 10:00:33 -0000 1.1 --- KeywordUtil.java 25 May 2007 12:58:46 -0000 1.2 *************** *** 62,66 **** "tamelijk", "te", "tegen", "ten", "tenzij", "ter", "terwijl", "thans", "tijdens", "toch", "toe", "toen", "toenmaals", "toenmalig", "tot", "totdat", "tussen", "uit", ! "uitg", "uitgezonderd", "vaak", "vakgr", "van", "vanaf", "vandaan", "vanuit", "vanwege", "veeleer", "verder", "vert", "vervolgens", "vol", "volgens", "voor", "vooraf", "vooral", "vooralsnog", "voorbij", "voordat", "voordezen", "voordien", --- 62,66 ---- "tamelijk", "te", "tegen", "ten", "tenzij", "ter", "terwijl", "thans", "tijdens", "toch", "toe", "toen", "toenmaals", "toenmalig", "tot", "totdat", "tussen", "uit", ! "uitg", "uitgezonderd", "vaak", "vaker", "van", "vanaf", "vandaan", "vanuit", "vanwege", "veeleer", "verder", "vert", "vervolgens", "vol", "volgens", "voor", "vooraf", "vooral", "vooralsnog", "voorbij", "voordat", "voordezen", "voordien", Index: HttpUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/HttpUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HttpUtil.java 24 Jul 2006 09:01:21 -0000 1.5 --- HttpUtil.java 25 May 2007 12:58:46 -0000 1.6 *************** *** 132,139 **** public static String getServerDocRoot(HttpServletRequest request) { StringBuffer s = new StringBuffer(); ! s.append(request.getScheme()).append("://") ! .append(request.getServerName()).append(':') ! .append(Integer.toString(request.getServerPort())) ! .append('/'); return s.toString(); } --- 132,142 ---- public static String getServerDocRoot(HttpServletRequest request) { StringBuffer s = new StringBuffer(); ! s.append(request.getScheme()).append("://").append(request.getServerName()); ! ! int serverPort = request.getServerPort(); ! if (serverPort != 80 && serverPort != 443 ) { ! s.append(':').append(Integer.toString(serverPort)); ! } ! s.append('/'); return s.toString(); } |
From: Nico K. <nkl...@us...> - 2007-04-18 07:53:56
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs16:/tmp/cvs-serv9185/remotepublishing Modified Files: project.xml Log Message: SNAPSHOT version for 1.0.12 Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** project.xml 18 Apr 2007 07:50:35 -0000 1.5 --- project.xml 18 Apr 2007 07:53:54 -0000 1.6 *************** *** 5,9 **** <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.11</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> --- 5,9 ---- <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.12-SNAPSHOT</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> |
From: Nico K. <nkl...@us...> - 2007-04-18 07:50:41
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs16:/tmp/cvs-serv7890/remotepublishing Modified Files: project.xml Log Message: version 1.0.11 Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** project.xml 16 Dec 2006 13:14:50 -0000 1.4 --- project.xml 18 Apr 2007 07:50:35 -0000 1.5 *************** *** 5,9 **** <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.10</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> --- 5,9 ---- <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.11</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> |
From: Nico K. <nkl...@us...> - 2007-04-18 07:50:17
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders In directory sc8-pr-cvs16:/tmp/cvs-serv7770/remotepublishing/config/applications/Publisher/builders Modified Files: remotenodes.xml Log Message: Don't publish nodes which are modified before their last publication timestamp Index: remotenodes.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/remotenodes.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** remotenodes.xml 16 Dec 2006 13:14:49 -0000 1.3 --- remotenodes.xml 18 Apr 2007 07:50:11 -0000 1.4 *************** *** 52,58 **** </positions> </editor> ! <datatype xmlns="http://www.mmbase.org/xmlns/datatypes"> ! <default value="now" /> ! </datatype> <db> <name>timestamp</name> --- 52,56 ---- </positions> </editor> ! <datatype base="lastmodified" xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> <name>timestamp</name> |
From: Nico K. <nkl...@us...> - 2007-04-18 07:50:16
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders In directory sc8-pr-cvs16:/tmp/cvs-serv7770/remotepublishing/src/org/mmbase/remotepublishing/builders Modified Files: PublishingQueueBuilder.java Log Message: Don't publish nodes which are modified before their last publication timestamp Index: PublishingQueueBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingQueueBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PublishingQueueBuilder.java 16 Dec 2006 13:14:50 -0000 1.3 --- PublishingQueueBuilder.java 18 Apr 2007 07:50:11 -0000 1.4 *************** *** 17,24 **** import java.rmi.NoSuchObjectException; import java.util.*; - import java.util.regex.Matcher; - import java.util.regex.Pattern; - - import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory; import org.mmbase.bridge.*; --- 17,20 ---- *************** *** 29,33 **** import org.mmbase.module.core.MMObjectNode; import org.mmbase.remotepublishing.CloudInfo; - import org.mmbase.remotepublishing.CloudManager; import org.mmbase.remotepublishing.PublishManager; import org.mmbase.remotepublishing.PublishListener; --- 25,28 ---- *************** *** 65,69 **** **/ public boolean init() { ! Map params = getInitParameters("mmbase/remotepublishing"); remoteCloudName = (String) params.get("remotecloud"); --- 60,64 ---- **/ public boolean init() { ! Map<String,Object> params = getInitParameters("mmbase/remotepublishing"); remoteCloudName = (String) params.get("remotecloud"); *************** *** 124,128 **** try { ! List nodes = builder.getNodes(query); if (nodes.isEmpty()) { throw new BridgeException("can not find cloud with name(" --- 119,123 ---- try { ! List<MMObjectNode> nodes = builder.getNodes(query); if (nodes.isEmpty()) { throw new BridgeException("can not find cloud with name(" *************** *** 130,134 **** + ") in nameServerCloud"); } ! return ((MMObjectNode)nodes.get(0)).getNumber(); } catch (SearchQueryException e) { --- 125,129 ---- + ") in nameServerCloud"); } ! return nodes.get(0).getNumber(); } catch (SearchQueryException e) { *************** *** 317,321 **** int number = node.getIntValue("sourcenumber"); if (localCloudInfo.getCloud().hasNode(number)) { ! listener.publishedFailed(localCloudInfo.getCloud().getNode(number),e.getMessage()); } } --- 312,326 ---- int number = node.getIntValue("sourcenumber"); if (localCloudInfo.getCloud().hasNode(number)) { ! StringBuffer message = new StringBuffer(); ! Throwable t = e; ! while(t != null) { ! message.append(t.getMessage()); ! t = t.getCause(); ! if(t != null) { ! message.append(" | "); ! } ! } ! ! listener.publishedFailed(localCloudInfo.getCloud().getNode(number),message.toString()); } } *************** *** 327,333 **** private void publish(CloudInfo localCloudInfo, Node publishQueueNode) { - //FIXME: add this timestamp as debug information for performance inspector - long timestamp = System.currentTimeMillis(); - int localNodeNumber = publishQueueNode.getIntValue("sourcenumber"); int remoteCloudNumber = publishQueueNode.getIntValue("destinationcloud"); --- 332,335 ---- *************** *** 347,351 **** localNodeNumber); } ! PublishManager.updatePublishedNodes(localCloudInfo, localNode); } else { --- 349,353 ---- localNodeNumber); } ! PublishManager.updatePublishedNodes(localCloudInfo, localNode); } else { *************** *** 371,376 **** throw new BridgeException("PublishManager could not publish " + localNode.getNumber(), e); } finally { ! //FIXME: add this finally block as debug information for performance inspector ! log.debug("Published one node("+localNode.getNumber()+") in "+(System.currentTimeMillis()-timestamp)+" ms!"); } } --- 373,377 ---- throw new BridgeException("PublishManager could not publish " + localNode.getNumber(), e); } finally { ! log.debug("Published one node("+localNode.getNumber()+")"); } } *************** *** 383,391 **** publishQueueNode.commit(); } - - - private Cloud getAdminCloud() { - return CloudProviderFactory.getCloudProvider().getAdminCloud(); - } public static void addPublishListener(PublishListener publishListener) { --- 384,387 ---- |
From: Nico K. <nkl...@us...> - 2007-04-18 07:50:15
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs16:/tmp/cvs-serv7770/remotepublishing/src/org/mmbase/remotepublishing Modified Files: PublishManager.java Log Message: Don't publish nodes which are modified before their last publication timestamp Index: PublishManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PublishManager.java 16 Dec 2006 13:14:45 -0000 1.4 --- PublishManager.java 18 Apr 2007 07:50:11 -0000 1.5 *************** *** 36,40 **** import org.mmbase.bridge.RelationManager; import org.mmbase.bridge.StringList; ! import org.mmbase.remotepublishing.util.GenericNodeList; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; --- 36,40 ---- import org.mmbase.bridge.RelationManager; import org.mmbase.bridge.StringList; ! import org.mmbase.datatypes.DataType; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; *************** *** 66,73 **** * * @author Finalist IT - * @version $Revision$ */ public final class PublishManager { private static final String SOURCE_CLOUD = "sourcecloud"; private static final String SOURCE_NUMBER = "sourcenumber"; --- 66,73 ---- * * @author Finalist IT */ public final class PublishManager { + private static final String TIMESTAMP = "timestamp"; private static final String SOURCE_CLOUD = "sourcecloud"; private static final String SOURCE_NUMBER = "sourcenumber"; *************** *** 356,360 **** admin.setIntValue(DESTINATION_CLOUD, CloudInfo.getCloudNumberInRemoteCloud(localCloudInfo, remoteCloudInfo)); admin.setIntValue(DESTINATION_NUMBER, remoteNumber); - admin.setDateValue("timestamp", new Date()); admin.commit(); --- 356,359 ---- *************** *** 365,369 **** admin.setIntValue(DESTINATION_CLOUD, CloudInfo.getCloudNumberInRemoteCloud(remoteCloudInfo, remoteCloudInfo)); admin.setIntValue(DESTINATION_NUMBER, remoteNumber); - admin.setDateValue("timestamp", new Date()); admin.commit(); } --- 364,367 ---- *************** *** 557,562 **** * deleted too. * ! * @param sourceCloudInfo source cloud info which the source node got from ! * @param sourceNode Node from which to remove the publish info */ public static void unLinkNode(CloudInfo localCloudInfo, Node localNode) { --- 555,560 ---- * deleted too. * ! * @param localCloudInfo source cloud info which the source node got from ! * @param localNode Node from which to remove the publish info */ public static void unLinkNode(CloudInfo localCloudInfo, Node localNode) { *************** *** 613,621 **** synchronized (publishLock) { // remove info in source cloud ! NodeManager sourcenm = sourceCloudInfo.getCloud().getNodeManager(MMBASE_PUBLISH_MANAGER); ! NodeList sourcenl = sourcenm.getList("destinationnumber=" + destinationNumber + ! " AND sourcecloud=" + CloudInfo.getCloudNumberInRemoteCloud(sourceCloudInfo, sourceCloudInfo) + ! " AND destinationcloud=" + CloudInfo.getCloudNumberInRemoteCloud(sourceCloudInfo, destinationCloudInfo), ! null, null); int sourcenlSize = sourcenl.size(); // There shouldn't be more then one, but just clean up all records --- 611,615 ---- synchronized (publishLock) { // remove info in source cloud ! NodeList sourcenl = getSourceInfoNodes(sourceCloudInfo, destinationCloudInfo, destinationNumber); int sourcenlSize = sourcenl.size(); // There shouldn't be more then one, but just clean up all records *************** *** 625,635 **** // remove info in destination cloud ! NodeManager destnm = destinationCloudInfo.getCloud().getNodeManager(MMBASE_PUBLISH_MANAGER); ! NodeList destnl = destnm.getList("destinationnumber=" + destinationNumber + ! " AND sourcecloud=" + CloudInfo.getCloudNumberInRemoteCloud(destinationCloudInfo, sourceCloudInfo) + ! " AND destinationcloud=" + CloudInfo.getCloudNumberInRemoteCloud(destinationCloudInfo, destinationCloudInfo), ! null, null); int destnlSize = destnl.size(); ! // There shouldn't be more then one, but just clean up all records for(int i = 0; i < destnlSize; i++) { destnl.getNode(i).delete(true); --- 619,625 ---- // remove info in destination cloud ! NodeList destnl = getDestinationNodes(sourceCloudInfo, destinationCloudInfo, destinationNumber); int destnlSize = destnl.size(); ! // There shouldn't be more then one, but just clean up all records for(int i = 0; i < destnlSize; i++) { destnl.getNode(i).delete(true); *************** *** 638,641 **** --- 628,667 ---- } + private static NodeList getDestinationNodes(CloudInfo sourceCloudInfo, + CloudInfo destinationCloudInfo, int destinationNumber) { + NodeManager destnm = destinationCloudInfo.getCloud().getNodeManager(MMBASE_PUBLISH_MANAGER); + NodeList destnl = destnm.getList("destinationnumber=" + destinationNumber + + " AND sourcecloud=" + CloudInfo.getCloudNumberInRemoteCloud(destinationCloudInfo, sourceCloudInfo) + + " AND destinationcloud=" + CloudInfo.getCloudNumberInRemoteCloud(destinationCloudInfo, destinationCloudInfo), + null, null); + return destnl; + } + + private static NodeList getSourceInfoNodes(CloudInfo sourceCloudInfo, + CloudInfo destinationCloudInfo, int destinationNumber) { + NodeManager sourcenm = sourceCloudInfo.getCloud().getNodeManager(MMBASE_PUBLISH_MANAGER); + NodeList sourcenl = sourcenm.getList("destinationnumber=" + destinationNumber + + " AND sourcecloud=" + CloudInfo.getCloudNumberInRemoteCloud(sourceCloudInfo, sourceCloudInfo) + + " AND destinationcloud=" + CloudInfo.getCloudNumberInRemoteCloud(sourceCloudInfo, destinationCloudInfo), + null, null); + return sourcenl; + } + + + private static void updatePublishInfoNode(CloudInfo sourceCloudInfo, CloudInfo destinationCloudInfo, + int destinationNumber) { + + synchronized (publishLock) { + // remove info in source cloud + NodeList sourcenl = getSourceInfoNodes(sourceCloudInfo, destinationCloudInfo, destinationNumber); + int sourcenlSize = sourcenl.size(); + // There shouldn't be more then one, but just clean up all records + for(int i = 0; i < sourcenlSize; i++) { + sourcenl.getNode(i).commit(); + } + } + } + + /** * Get the published nodes from a remote cloud. What should be kept in mind is that *************** *** 646,650 **** * @param remoteCloudInfo the remote cloud * @return the remote node or null if not published - * @deprecated */ public static Node getPublishedNode(Node localNode, CloudInfo remoteCloudInfo) { --- 672,675 ---- *************** *** 694,698 **** * @param localNode The node thas has been published * @return List of all remote nodes - * @deprecated */ public static Map<Integer,List<Node>> getPublishedNodes(Node localNode) { --- 719,722 ---- *************** *** 708,713 **** */ public static Map<Integer,List<Node>> getPublishedNodes(CloudInfo localCloudInfo, int localNumber) { ! NodeIterator ni = getPublishInfoNodes(localCloudInfo, localNumber).nodeIterator(); Map<Integer,List<Node>> returnMap = new HashMap<Integer,List<Node>>(); while (ni.hasNext()) { --- 732,747 ---- */ public static Map<Integer,List<Node>> getPublishedNodes(CloudInfo localCloudInfo, int localNumber) { ! NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); ! return getPublishedNodes(publishInfoNodes); ! } + /** + * Get the published nodes from all remote clouds + * + * @param publishInfoNodes The publish Info Nodes + * @return List of all remote nodes + */ + public static Map<Integer, List<Node>> getPublishedNodes(NodeList publishInfoNodes) { + NodeIterator ni = publishInfoNodes.nodeIterator(); Map<Integer,List<Node>> returnMap = new HashMap<Integer,List<Node>>(); while (ni.hasNext()) { *************** *** 719,736 **** returnMap.put(destinationCloudNumber, publishNodesList); } ! CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(destinationCloudNumber); ! Node remotePublishedNode = remoteCloudInfo.getCloud().getNode(admin.getIntValue(DESTINATION_NUMBER)); publishNodesList.add(remotePublishedNode); } return returnMap; ! } - /** - * - * @param localNode - * @return - * @deprecated - */ public static Collection<Integer> getPublishedClouds(Node localNode) { return getPublishedClouds(CloudInfo.getDefaultCloudInfo(), localNode.getNumber()); --- 753,770 ---- returnMap.put(destinationCloudNumber, publishNodesList); } ! Node remotePublishedNode = getRemoteNode(admin); publishNodesList.add(remotePublishedNode); } return returnMap; ! } ! ! private static Node getRemoteNode(Node admin) { ! int destinationCloudNumber = admin.getIntValue(DESTINATION_CLOUD); ! CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(destinationCloudNumber); ! Node remotePublishedNode = remoteCloudInfo.getCloud().getNode(admin.getIntValue(DESTINATION_NUMBER)); ! return remotePublishedNode; ! } public static Collection<Integer> getPublishedClouds(Node localNode) { return getPublishedClouds(CloudInfo.getDefaultCloudInfo(), localNode.getNumber()); *************** *** 863,874 **** return; } ! //TODO: ! // List<CloudInfo> remoteCloudInfoList ! // for () { ! // CloudInfo remoteInfo = ; ! // Cloud remoteCloud = remoteInfo.getRemoteCloud(); ! // updatePublishNode(localNode,remoteCloud); ! // } ! Map<Integer,List<Node>> publishedNodesMap = getPublishedNodes(localCloudInfo, localNode.getNumber()); Iterator<Integer> cloudNumberIterator = publishedNodesMap.keySet().iterator(); --- 897,912 ---- return; } ! NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNode.getNumber()); ! ! Date lastmodified = getLastModifiedDate(localNode); ! for (Iterator<Node> iterator = publishInfoNodes.iterator(); iterator.hasNext();) { ! Node publishInfoNode = iterator.next(); ! Date timestamp = publishInfoNode.getDateValue(TIMESTAMP); ! if (lastmodified.before(timestamp)) { ! iterator.remove(); ! } ! } ! ! Map<Integer,List<Node>> publishedNodesMap = getPublishedNodes(publishInfoNodes); Iterator<Integer> cloudNumberIterator = publishedNodesMap.keySet().iterator(); *************** *** 885,888 **** --- 923,942 ---- } + private static Date getLastModifiedDate(Node localNode) { + for (Iterator<Field> iterator = localNode.getNodeManager().getFields().iterator(); iterator.hasNext();) { + Field field = iterator.next(); + if (field.getType() == Field.TYPE_DATETIME) { + DataType dtype = field.getDataType(); + while (dtype != null && !"lastmodified".equals(dtype.getName())) { + dtype = dtype.getOrigin(); + } + if (dtype != null) { + return localNode.getDateValue(field.getName()); + } + } + } + return new Date(); + } + private static void syncNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo, Node remoteNode) throws PublishException { *************** *** 891,899 **** syncAliasses(localNode, remoteNode); remoteNode.commit(); syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } ! public static void updatePublishedNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo) throws PublishException { synchronized (publishLock) { if (!isPublished(localCloudInfo, localNode)) { --- 945,955 ---- syncAliasses(localNode, remoteNode); remoteNode.commit(); + updatePublishInfoNode(localCloudInfo, remoteCloudInfo, remoteNode.getNumber()); syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } ! ! public static void updatePublishedNode(CloudInfo localCloudInfo, Node localNode, CloudInfo remoteCloudInfo) throws PublishException { synchronized (publishLock) { if (!isPublished(localCloudInfo, localNode)) { *************** *** 988,992 **** * delete the remote instances of a node(with relations and relation information) * @param localNode the local node to remove - * @deprecated */ public static void deletePublishedNode(Node localNode) { --- 1044,1047 ---- *************** *** 1005,1009 **** if (isPublished(localCloudInfo, localNumber)) { ! Map<Integer, List<Node>> publishedNodesMap = getPublishedNodes(localCloudInfo, localNumber); log.debug("the node is published on " + publishedNodesMap.size() + " clouds"); --- 1060,1066 ---- if (isPublished(localCloudInfo, localNumber)) { ! NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNumber); ! ! Map<Integer, List<Node>> publishedNodesMap = getPublishedNodes(publishInfoNodes); log.debug("the node is published on " + publishedNodesMap.size() + " clouds"); |
From: Nico K. <nkl...@us...> - 2007-04-18 07:48:33
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs16:/tmp/cvs-serv6952/remotepublishing/src/org/mmbase/remotepublishing Modified Files: CloudInfo.java PublishListener.java Log Message: Code cleanup Index: PublishListener.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishListener.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PublishListener.java 16 Dec 2006 13:14:45 -0000 1.2 --- PublishListener.java 18 Apr 2007 07:48:28 -0000 1.3 *************** *** 3,10 **** import org.mmbase.bridge.Node; - /** - * @author Jeoffrey Bakker, Finalist IT Group - * @version $Revision$, $Date$ - */ public interface PublishListener { void published(Node publishedNode); --- 3,6 ---- Index: CloudInfo.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/CloudInfo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CloudInfo.java 16 Dec 2006 13:14:45 -0000 1.1 --- CloudInfo.java 18 Apr 2007 07:48:28 -0000 1.2 *************** *** 9,15 **** import org.mmbase.bridge.Cloud; import org.mmbase.bridge.Node; - import org.mmbase.bridge.NodeIterator; - import org.mmbase.bridge.implementation.BasicCloud; - import org.mmbase.bridge.util.SearchUtil; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; --- 9,12 ---- *************** *** 60,70 **** } - /** - * - * @param remoteCloudInfo - * @param remoteCloudNumber - * @return - * @deprecated - */ public static CloudInfo getCloudInfo(CloudInfo remoteCloudInfo, int remoteCloudNumber) { CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); --- 57,60 ---- *************** *** 117,121 **** private CloudInfo() { ! } --- 107,111 ---- private CloudInfo() { ! // prevent instantiation } |
From: Nico K. <nkl...@us...> - 2007-04-18 07:48:33
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util In directory sc8-pr-cvs16:/tmp/cvs-serv6952/remotepublishing/src/org/mmbase/remotepublishing/util Modified Files: PublishUtil.java Log Message: Code cleanup Index: PublishUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/PublishUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PublishUtil.java 16 Dec 2006 13:14:49 -0000 1.4 --- PublishUtil.java 18 Apr 2007 07:48:28 -0000 1.5 *************** *** 113,122 **** } ! public static void removeFromQueue(Node node, List clouds) { log.debug("removeFromQueue with number = " + node.getNumber()); NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); ! for (Iterator cloudIter = clouds.iterator(); cloudIter.hasNext();) { ! Node cloudNode = (Node) cloudIter.next(); NodeList list = nodeManager.getList("[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber() + " and sourcecloud = " + cloudNode.getNumber() , null, null); NodeIterator iter = list.nodeIterator(); --- 113,122 ---- } ! public static void removeFromQueue(Node node, List<Node> clouds) { log.debug("removeFromQueue with number = " + node.getNumber()); NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); ! for (Iterator<Node> cloudIter = clouds.iterator(); cloudIter.hasNext();) { ! Node cloudNode = cloudIter.next(); NodeList list = nodeManager.getList("[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber() + " and sourcecloud = " + cloudNode.getNumber() , null, null); NodeIterator iter = list.nodeIterator(); |
From: Nico K. <nkl...@us...> - 2006-12-16 13:15:31
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7431/remotepublishing/src/org/mmbase/remotepublishing/util Modified Files: GenericNodeList.java GenericNodeIterator.java PublishUtil.java Log Message: Performance improvements Index: PublishUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/PublishUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PublishUtil.java 17 Oct 2006 10:02:54 -0000 1.3 --- PublishUtil.java 16 Dec 2006 13:14:49 -0000 1.4 *************** *** 100,103 **** --- 100,116 ---- } + public static void removeFromQueue(Node node) { + log.debug("removeFromQueue with number = " + node.getNumber()); + NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); + + NodeList list = nodeManager.getList( + "[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber(), null, null); + NodeIterator iter = list.nodeIterator(); + while (iter.hasNext()) { + Node element = iter.nextNode(); + element.delete(); + } + } + public static void removeFromQueue(Node node, List clouds) { log.debug("removeFromQueue with number = " + node.getNumber()); Index: GenericNodeList.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/GenericNodeList.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenericNodeList.java 18 Apr 2006 09:27:19 -0000 1.2 --- GenericNodeList.java 16 Dec 2006 13:14:49 -0000 1.3 *************** *** 30,34 **** * * @author Nico Klasens (Finalist IT Group) - * @version $Id$ */ public class GenericNodeList extends ArrayList implements NodeList { --- 30,33 ---- Index: GenericNodeIterator.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/GenericNodeIterator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenericNodeIterator.java 18 Apr 2006 09:27:19 -0000 1.2 --- GenericNodeIterator.java 16 Dec 2006 13:14:49 -0000 1.3 *************** *** 23,27 **** * * @author Nico Klasens (Finalist IT Group) - * @version $Id$ */ public class GenericNodeIterator implements NodeIterator { --- 23,26 ---- |
From: Nico K. <nkl...@us...> - 2006-12-16 13:15:27
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7431/remotepublishing/src/org/mmbase/remotepublishing/builders Modified Files: PublishingQueueBuilder.java Log Message: Performance improvements Index: PublishingQueueBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingQueueBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PublishingQueueBuilder.java 17 Oct 2006 10:02:54 -0000 1.2 --- PublishingQueueBuilder.java 16 Dec 2006 13:14:50 -0000 1.3 *************** *** 14,26 **** --- 14,32 ---- package org.mmbase.remotepublishing.builders; + import java.rmi.ConnectException; + import java.rmi.NoSuchObjectException; import java.util.*; + import java.util.regex.Matcher; + import java.util.regex.Pattern; import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory; import org.mmbase.bridge.*; + import org.mmbase.bridge.util.SearchUtil; import org.mmbase.cache.CachePolicy; import org.mmbase.module.core.MMBase; import org.mmbase.module.core.MMObjectBuilder; import org.mmbase.module.core.MMObjectNode; + import org.mmbase.remotepublishing.CloudInfo; import org.mmbase.remotepublishing.CloudManager; import org.mmbase.remotepublishing.PublishManager; *************** *** 42,45 **** --- 48,52 ---- /** thread performing the task */ private static Thread thread = null; + private static int maxtrying = 5; int remoteCloudNumber = -1; *************** *** 77,81 **** if (thread == null) { ! thread = new Thread(this, "PublishQueue " + remoteCloudName); thread.setDaemon(true); thread.start(); --- 84,88 ---- if (thread == null) { ! thread = new Thread(this, "PublishQueue to " + remoteCloudName); thread.setDaemon(true); thread.start(); *************** *** 139,142 **** --- 146,163 ---- MMBase.getMMBase(); + try { + Thread.sleep(interval); + } + catch (InterruptedException e) { + log.warn("Interupted while sleeping , continuning"); + } + + try { + linkTypedefs(); + } + catch (Exception e) { + log.error("Problem with linking typedefs together", e); + } + while (true) { try { *************** *** 151,156 **** } else { ! Cloud cloud = getAdminCloud(); ! NodeManager nodeManager = cloud.getNodeManager("publishqueue"); NodeQuery query = nodeManager.createQuery(); --- 172,177 ---- } else { ! CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! NodeManager nodeManager = localCloudInfo.getCloud().getNodeManager("publishqueue"); NodeQuery query = nodeManager.createQuery(); *************** *** 158,165 **** FieldValueConstraint failStatus = query.createConstraint(statusField, FieldCompareConstraint.NOT_EQUAL, "fail"); ! query.setCaseSensitive(failStatus, false); FieldValueConstraint doneStatus = query.createConstraint(statusField, FieldCompareConstraint.NOT_EQUAL, "done"); ! query.setCaseSensitive(doneStatus, false); Constraint statusComposite = query.createConstraint( failStatus, CompositeConstraint.LOGICAL_AND, doneStatus); --- 179,186 ---- FieldValueConstraint failStatus = query.createConstraint(statusField, FieldCompareConstraint.NOT_EQUAL, "fail"); ! query.setCaseSensitive(failStatus, true); FieldValueConstraint doneStatus = query.createConstraint(statusField, FieldCompareConstraint.NOT_EQUAL, "done"); ! query.setCaseSensitive(doneStatus, true); Constraint statusComposite = query.createConstraint( failStatus, CompositeConstraint.LOGICAL_AND, doneStatus); *************** *** 180,233 **** query.setConstraint(composite); } query.setCachePolicy(CachePolicy.NEVER); ! NodeList list = nodeManager.getList(query); ! for (int x = 0; x < list.size(); x++) { ! Node node = list.getNode(x); ! try { ! if (node.getStringValue("action").equalsIgnoreCase("update")) { ! try { ! if (isAllowedToPublish(node)) { ! publish(node); ! node.setStringValue("status", "done"); ! node.commit(); ! } ! } ! catch (BridgeException e) { ! log.error("Nodenumber : " + node.getNumber() + ", " + e, e); ! node.setStringValue("status", "fail"); ! node.commit(); ! for(PublishListener listener : publishListeners) { ! int number = node.getIntValue("sourcenumber"); ! if (cloud.hasNode(number)) { ! listener.publishedFailed(cloud.getNode(number)); ! } ! } ! } ! } ! else { ! if (node.getStringValue("action").equalsIgnoreCase("remove")) { ! try { ! removeNode(node); ! } ! catch (BridgeException e) { ! log.error("Removing published node (" + node.getNumber() + ") failed", e); ! node.setStringValue("status", "fail"); ! node.commit(); ! for(PublishListener listener : publishListeners) { ! int number = node.getIntValue("sourcenumber"); ! if (cloud.hasNode(number)) { ! listener.publishedFailed(cloud.getNode(number)); } } ! } ! } ! } ! } ! catch (Throwable e) { ! log.error("Throwable error with nodenumber: " + node.getNumber() + ", " + e.getMessage()); ! log.debug(Logging.stackTrace(e)); ! } } } --- 201,270 ---- query.setConstraint(composite); } + query.setMaxNumber(10); query.setCachePolicy(CachePolicy.NEVER); ! NodeList list = null; ! while(list == null || !list.isEmpty()) { ! //FIXME: add this timestamp as debug information for performance inspector ! long timestamp = System.currentTimeMillis(); ! list = nodeManager.getList(query); ! ! for (int x = 0; x < list.size(); x++) { ! Node node = list.getNode(x); ! if(node != null) { ! try { ! // check if node is not removed from the cloud in between query and retrieval ! if (localCloudInfo.getCloud().hasNode(node.getNumber())) { ! if (node.getStringValue("action").equalsIgnoreCase("update")) { ! try { ! if (isAllowedToPublish(node)) { ! boolean finished = false; ! int trytimes = 0; ! while(!finished) { ! try { ! publish(localCloudInfo, node); ! finished=true; ! } catch (BridgeException e) { ! if ( handleRmiException(e) && ++trytimes<=maxtrying) { ! //if it was caused rmi connection exception and still within ! // the maximal tring times limitation, ! // continue to try publishing it again ! } else { ! //otherwise, throw the runtime exception ! throw e; ! } ! } ! }; ! node.setStringValue("status", "done"); ! node.commit(); ! } ! } ! catch (BridgeException e) { ! log.error("Nodenumber : " + node.getNumber() + ", " + e, e); ! publishFailed(localCloudInfo, node, e); ! } ! } ! else { ! if (node.getStringValue("action").equalsIgnoreCase("remove")) { ! try { ! removeNode(localCloudInfo, node); ! } ! catch (BridgeException e) { ! log.error("Removing published node (" + node.getNumber() + ") failed", e); ! publishFailed(localCloudInfo, node, e); ! } ! } } } ! } ! catch (Throwable e) { ! log.error("Throwable error with nodenumber: " + node.getNumber() + ", " + e.getMessage()); ! log.debug(Logging.stackTrace(e)); ! } ! } ! } //end for ! //FIXME: add this log message as debug information for performance inspector ! log.debug("Published total "+list.size()+" nodes in "+(System.currentTimeMillis()-timestamp)+" ms!"); } } *************** *** 235,291 **** } protected boolean isAllowedToPublish(Node publishQueueNode) { return true; } ! private void publish(Node publishQueueNode) { ! int number = publishQueueNode.getIntValue("sourcenumber"); ! int cloudNumber = publishQueueNode.getIntValue("destinationcloud"); ! Cloud cloud = getAdminCloud(); ! Cloud remoteCloud = CloudManager.getCloud(cloud, cloudNumber); ! Node node = cloud.getNode(number); ! String nodeManagerName = node.getNodeManager().getName(); try { ! if (!PublishManager.isImported(node)) { ! if (PublishManager.isPublished(node)) { ! if (node instanceof Relation) { log.debug(nodeManagerName + " update relation with number " + ! number); } else { log.debug(nodeManagerName + " update node with number " + ! number); } ! PublishManager.updatePublishedNodes(node); } else { ! if (node instanceof Relation) { log.debug(nodeManagerName + " publish relation with number " + ! number); } else { log.debug(nodeManagerName + " publish node with number " + ! number); } ! PublishManager.publishNode(node, remoteCloud); } for(PublishListener listener : publishListeners) { ! listener.published(node); } } ! else { ! log.debug("imported node in publishqueue " + node.getNumber()); } } catch (Exception e) { ! throw new BridgeException("PublishManager could not publish " + node.getNumber(), e); } } ! private void removeNode(Node publishQueueNode) { int number = publishQueueNode.getIntValue("sourcenumber"); - Cloud cloud = getAdminCloud(); ! PublishManager.deletePublishedNode(cloud, number); publishQueueNode.setStringValue("status", "done"); publishQueueNode.commit(); --- 272,383 ---- } + /** + * handle exception, if the root cause is RMI's connection broken, + * try to set cached cloud informaiton invalid. + * @param e the exception which we should handled. + * @return true, if the exception is caused by invalid RMI connect; false, otherwise. + */ + private boolean handleRmiException(BridgeException e) { + Throwable rootCause = e; + while (rootCause.getCause() != null) { + rootCause = rootCause.getCause(); + if (rootCause.getClass().getPackage().getName().startsWith("java.rmi")) { + break; + } + } + + if (rootCause instanceof ConnectException) { + //if root cause is rmi connection exception + String message = e.getCause().getMessage(); + log.debug("rmi connection exception:"+message); + int beginIndex = message.indexOf("rmi://"); + if (beginIndex >= 0) { + //if we know exactlly what cloud is died, we just reset this one + int endIndex = message.indexOf(" ", beginIndex); + String url = message.substring(beginIndex, endIndex); + CloudInfo.setCloudInvalid(url); + return true; + } else { + //if we aren't sure which cloud is died, reset all cached remote cloud + CloudInfo.setRemoteCloudsInvalid(); + return true; + } + + } else if (rootCause instanceof NoSuchObjectException){ + CloudInfo.setRemoteCloudsInvalid(); + return true; + } + return false; + } + + private void publishFailed(CloudInfo localCloudInfo, Node node, BridgeException e) { + node.setStringValue("status", "fail"); + node.commit(); + for(PublishListener listener : publishListeners) { + int number = node.getIntValue("sourcenumber"); + if (localCloudInfo.getCloud().hasNode(number)) { + listener.publishedFailed(localCloudInfo.getCloud().getNode(number),e.getMessage()); + } + } + } + protected boolean isAllowedToPublish(Node publishQueueNode) { return true; } ! private void publish(CloudInfo localCloudInfo, Node publishQueueNode) { ! //FIXME: add this timestamp as debug information for performance inspector ! long timestamp = System.currentTimeMillis(); ! ! int localNodeNumber = publishQueueNode.getIntValue("sourcenumber"); ! int remoteCloudNumber = publishQueueNode.getIntValue("destinationcloud"); ! CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); ! Node localNode = localCloudInfo.getCloud().getNode(localNodeNumber); ! String nodeManagerName = localNode.getNodeManager().getName(); try { ! if (!PublishManager.isImported(localCloudInfo, localNode)) { ! ! if (PublishManager.isPublished(localCloudInfo, localNode)) { ! if (localNode instanceof Relation) { log.debug(nodeManagerName + " update relation with number " + ! localNodeNumber); } else { log.debug(nodeManagerName + " update node with number " + ! localNodeNumber); } ! PublishManager.updatePublishedNodes(localCloudInfo, localNode); } else { ! if (localNode instanceof Relation) { log.debug(nodeManagerName + " publish relation with number " + ! localNodeNumber); } else { log.debug(nodeManagerName + " publish node with number " + ! localNodeNumber); } ! PublishManager.publishNode(localCloudInfo, localNode, remoteCloudInfo); } for(PublishListener listener : publishListeners) { ! listener.published(localNode); } } ! else { //if it is imported from other cloud, ignore this node ! log.debug("imported node in publishqueue " + localNode.getNumber()); } } catch (Exception e) { ! throw new BridgeException("PublishManager could not publish " + localNode.getNumber(), e); ! } finally { ! //FIXME: add this finally block as debug information for performance inspector ! log.debug("Published one node("+localNode.getNumber()+") in "+(System.currentTimeMillis()-timestamp)+" ms!"); } } ! private void removeNode(CloudInfo localCloudInfo, Node publishQueueNode) { int number = publishQueueNode.getIntValue("sourcenumber"); ! PublishManager.deletePublishedNode(localCloudInfo, number); publishQueueNode.setStringValue("status", "done"); publishQueueNode.commit(); *************** *** 304,306 **** --- 396,424 ---- publishListeners.remove(publishListener); } + + private void linkTypedefs() { + CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); + CloudInfo remoteCloudInfo = CloudInfo.getCloudInfoByName(remoteCloudName); + + NodeList typedefList = SearchUtil.findNodeList(localCloudInfo.getCloud(), "typedef"); + NodeIterator typedefIterator = typedefList.nodeIterator(); + while (typedefIterator.hasNext()) { + Node typedefNode = typedefIterator.nextNode(); + if (!PublishManager.isPublished(localCloudInfo, typedefNode)) { + // not published + Node remoteTypeDefNode = SearchUtil.findNode(remoteCloudInfo.getCloud(), "typedef", "name", typedefNode.getStringValue("name")); + if (remoteTypeDefNode != null) { + PublishManager.createPublishingInfo(localCloudInfo, typedefNode, remoteCloudInfo, remoteTypeDefNode); + + log.info("Added remoteinfo for typedef with name : " + typedefNode.getStringValue("name")); + } + else { + log.debug("No remote node found to link with for typedef with name : " + typedefNode.getStringValue("name")); + } + } + else { + log.debug("Found remoteinfo for typedef with name : " + typedefNode.getStringValue("name")); + } + } + } } |
From: Nico K. <nkl...@us...> - 2006-12-16 13:15:27
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7431/remotepublishing/src/org/mmbase/remotepublishing Modified Files: CloudManager.java PublishManager.java PublishListener.java Added Files: CloudInfo.java Log Message: Performance improvements Index: PublishListener.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PublishListener.java 17 Oct 2006 10:02:54 -0000 1.1 --- PublishListener.java 16 Dec 2006 13:14:45 -0000 1.2 *************** *** 9,12 **** public interface PublishListener { void published(Node publishedNode); ! void publishedFailed(Node publishedNode); } --- 9,12 ---- public interface PublishListener { void published(Node publishedNode); ! void publishedFailed(Node publishedNode, String systemMessage); } --- NEW FILE: CloudInfo.java --- package org.mmbase.remotepublishing; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.mmbase.bridge.BridgeException; import org.mmbase.bridge.Cloud; import org.mmbase.bridge.Node; import org.mmbase.bridge.NodeIterator; import org.mmbase.bridge.implementation.BasicCloud; import org.mmbase.bridge.util.SearchUtil; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; public class CloudInfo { private static final Logger log = Logging.getLoggerInstance(CloudInfo.class); public static final String CLOUD = "cloud"; private static final int DEFAULT_CLOUDINFO_NUMBER = Integer.MIN_VALUE; // this map used to cache cloudInfo instance. Cloud (in local) --> CloudInfo private static final Map<Integer, CloudInfo> instanceMap = new HashMap<Integer, CloudInfo>(); private static final Map<Integer, Cloud> cloudMap = new HashMap<Integer, Cloud>(); public static CloudInfo getDefaultCloudInfo() { if (instanceMap.containsKey(DEFAULT_CLOUDINFO_NUMBER)) { return instanceMap.get(DEFAULT_CLOUDINFO_NUMBER); } Cloud localCloud = CloudManager.getAdminCloud(); CloudInfo localCloudInfo = getCloudInfo(localCloud); instanceMap.put(DEFAULT_CLOUDINFO_NUMBER, localCloudInfo); cloudMap.put(localCloudInfo.getNumber(), localCloud); return localCloudInfo; } /** * * @param cloud * @return * @deprecated because this method use getCloudNode(cloud, cloud), it's expensive. */ public static CloudInfo getCloudInfo(Cloud cloud) { Node cloudNode = CloudManager.getCloudNode(cloud, cloud); CloudInfo cloudInfo = getCloudInfo(cloudNode); cloudMap.put(cloudNode.getNumber(), cloud); return cloudInfo; } public static CloudInfo getCloudInfo(int cloudNumber) { if (instanceMap.containsKey(cloudNumber)) { return instanceMap.get(cloudNumber); } CloudInfo localCloudInfo = getDefaultCloudInfo(); Node cloudNode = localCloudInfo.getCloud().getNode(cloudNumber); return getCloudInfo(cloudNode); } /** * * @param remoteCloudInfo * @param remoteCloudNumber * @return * @deprecated */ public static CloudInfo getCloudInfo(CloudInfo remoteCloudInfo, int remoteCloudNumber) { CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); if (remoteCloudInfo==null || localCloudInfo.equals(remoteCloudInfo)) { return getCloudInfo(remoteCloudNumber); } Node remoteCloudNode = CloudManager.getCloudNodeByNumber(remoteCloudInfo.getCloud(),remoteCloudNumber); String cloudName = remoteCloudNode.getStringValue("name"); Node cloudNode = CloudManager.getCloudNodeByName(localCloudInfo.getCloud(), cloudName); CloudInfo cloudInfo = getCloudInfo(cloudNode); return cloudInfo; } private static CloudInfo getCloudInfo(Node localCloudNode) { if (instanceMap.containsKey(localCloudNode.getNumber())){ return instanceMap.get(localCloudNode.getNumber()); } if (localCloudNode == null) { throw new BridgeException("can not find cloud with number(" + localCloudNode.getNumber() + ") in default admin cloud "); } if (CLOUD.equals(localCloudNode.getNodeManager().getName()) == false) { throw new BridgeException("the node(" + localCloudNode.getNumber() + ") is not a cloud node "); } CloudInfo cloudInfo = new CloudInfo(); cloudInfo.init(localCloudNode); instanceMap.put(cloudInfo.getNumber(), cloudInfo); return cloudInfo; } /** * * @param remoteCloudName * @return */ public static CloudInfo getCloudInfoByName(String remoteCloudName) { // FIXME: Does every cloud node have same name in different clouds? Node cloudNode = CloudManager.getCloudNodeByName(getDefaultCloudInfo().getCloud(), remoteCloudName); return getCloudInfo(cloudNode); } private String name; private int number; private String rmiurl; private final Map<Integer, Integer> remoteNumberMap = new HashMap<Integer, Integer>(); private CloudInfo() { } private void init(Node cloudNode) { this.name = cloudNode.getStringValue("name"); this.number = cloudNode.getNumber(); this.rmiurl = cloudNode.getStringValue("rmiurl"); } public String getName() { return name; } public int getNumber() { return number; } public String getRmiurl() { return rmiurl; } public Cloud getCloud() { return CloudInfo.getCloud(this.number); } public Integer getNumberInRemoteCloud(int remoteCloudNumber) { if(remoteNumberMap.containsKey(remoteCloudNumber)==false){ //get the name of the cloud CloudInfo remoteCloudInfo = getCloudInfo(remoteCloudNumber); Node nodeInRemoteCloud = CloudManager.getCloudNodeByName(remoteCloudInfo.getCloud(), this.name); int numberInRemoteCloud = nodeInRemoteCloud.getNumber(); remoteNumberMap.put(remoteCloudNumber, numberInRemoteCloud); } return remoteNumberMap.get(remoteCloudNumber); } public Integer getNumberInRemoteCloud(CloudInfo remoteCloudInfo) { return getNumberInRemoteCloud(remoteCloudInfo.getNumber()); } /* public Map<Integer,CloudInfo> getAllRemoteCloudInfo() { Map<Integer, CloudInfo> cloudInfoMap = new HashMap<Integer,CloudInfo>(); NodeIterator nodeIterator = this.getCloud().getNodeManager(CLOUD).getList( "number<>" + this.number, null, null).nodeIterator(); while (nodeIterator.hasNext()) { Node cloudNode = nodeIterator.nextNode(); CloudInfo cloudInfo = CloudInfo.getCloudInfo(cloudNode); cloudInfoMap.put(cloudNode.getNumber(),cloudInfo); } return cloudInfoMap; } */ /** * * @param cloudNumber * @return */ public static Cloud getCloud(int cloudNumber) { if (cloudMap.containsKey(cloudNumber)==false) { cloudMap.put(cloudNumber, CloudManager.getCloud(CloudManager.getAdminCloud(),cloudNumber)); } Cloud cloud = cloudMap.get(cloudNumber); return cloud; } public static int getCloudNumberInRemoteCloud(CloudInfo nameServerCloudInfo, CloudInfo cloudInfo) { CloudInfo localCloudInfo = getDefaultCloudInfo(); if (nameServerCloudInfo.equals(localCloudInfo)) { return cloudInfo.getNumber(); } if (cloudInfo.remoteNumberMap.containsKey(nameServerCloudInfo.getNumber())==false) { Node cloudNode = CloudManager.getCloudNode(nameServerCloudInfo.getCloud(), cloudInfo.getCloud()); cloudInfo.remoteNumberMap.put(nameServerCloudInfo.getNumber(), cloudNode.getNumber()); } return cloudInfo.remoteNumberMap.get(nameServerCloudInfo.getNumber()); } public static void setCloudInvalid(String url) { Iterator<CloudInfo> iterator = instanceMap.values().iterator(); CloudInfo localCloudInfo = getDefaultCloudInfo(); while (iterator.hasNext()) { CloudInfo cloudInfo = iterator.next(); if (url==null || "".equals(url.trim())) { //url==null means set all remote cloud invalid. if (cloudInfo.getNumber()==localCloudInfo.getNumber()) { //if it is local cloud, ignore continue; } log.debug("Found a cached remote cloud (name="+cloudInfo.getName()+", and rmiurl="+url+"), remove it from cloud instance cache"); cloudMap.remove(cloudInfo.getNumber()); } else if (url.equals(cloudInfo.getRmiurl())) { log.debug("Found a cached cloud (name="+cloudInfo.getName()+", and rmiurl="+url+"), remove it from cloud instance cache"); cloudMap.remove(cloudInfo.getName()); break; } } } public static void setRemoteCloudsInvalid() { //set all remote cloud to invalid setCloudInvalid(null); } } Index: CloudManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/CloudManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CloudManager.java 17 Oct 2006 10:02:54 -0000 1.2 --- CloudManager.java 16 Dec 2006 13:14:45 -0000 1.3 *************** *** 14,18 **** package org.mmbase.remotepublishing; ! import java.util.*; import org.mmbase.bridge.BridgeException; --- 14,21 ---- package org.mmbase.remotepublishing; ! import java.util.HashMap; ! import java.util.Map; ! ! import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory; import org.mmbase.bridge.BridgeException; *************** *** 32,35 **** --- 35,40 ---- private static final String CLOUD = "cloud"; + private static final String CLOUD_DEFAULT = "cloud.default"; + static Logger log = Logging.getLoggerInstance(CloudManager.class.getName()); *************** *** 37,41 **** //Utility class } ! /** * Get a cloud number based on the node name --- 42,46 ---- //Utility class } ! /** * Get a cloud number based on the node name *************** *** 69,74 **** */ public static int getCloudNumber(Cloud nameServerCloud, Cloud cloud) { //get the name of the cloud ! String cloudName = cloud.getNodeByAlias("cloud.default").getStringValue("name"); Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, "name", cloudName); --- 74,84 ---- */ public static int getCloudNumber(Cloud nameServerCloud, Cloud cloud) { + Node cloudNode = getCloudNode(nameServerCloud, cloud); + return cloudNode.getNumber(); + } + + public static Node getCloudNode(Cloud nameServerCloud, Cloud cloud) { //get the name of the cloud ! String cloudName = cloud.getNodeByAlias(CLOUD_DEFAULT).getStringValue("name"); Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, "name", cloudName); *************** *** 76,80 **** throw new BridgeException("remote cloud's number could not be established"); } ! return cloudNode.getNumber(); } --- 86,90 ---- throw new BridgeException("remote cloud's number could not be established"); } ! return cloudNode; } *************** *** 84,99 **** * * @param nameServerCloud the cloud containing the cloud nodes to use ! * @param name the name of the cloud ( in the cloud list) * @return cloud instance * @throws BridgeException if the cloud was not found */ ! public static Cloud getCloud(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloud = SearchUtil.findNode(nameServerCloud, CLOUD, "name", name); ! if (cloud == null) { throw new BridgeException("can not find cloud with name(" + name + ") in nameServerCloud"); } ! return getCloudFromNode(cloud); } --- 94,114 ---- * * @param nameServerCloud the cloud containing the cloud nodes to use ! * @param cloudName the name of the cloud ( in the cloud list) * @return cloud instance * @throws BridgeException if the cloud was not found */ ! public static Cloud getCloud(Cloud nameServerCloud, String cloudName) throws BridgeException { ! Node cloudNode = getCloudNodeByName(nameServerCloud, cloudName); ! return getCloudFromNode(cloudNode); ! } ! ! public static Node getCloudNodeByName(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, "name", name); ! if (cloudNode == null) { throw new BridgeException("can not find cloud with name(" + name + ") in nameServerCloud"); } ! return cloudNode; } *************** *** 102,120 **** * * @param nameServerCloud name cloud containing the cloud nodes to use ! * @param alias node number of alias of the cloud node * @return cloud instance * @throws BridgeException if the node does not exist */ ! public static Cloud getCloudByAlias(Cloud nameServerCloud, String alias) throws BridgeException { ! Node node = nameServerCloud.getNode(alias); ! if (node == null) { ! throw new BridgeException("Can not find cloud with alias(" ! + alias ! + ") in the nameServerCloud"); } ! return getCloudFromNode(node); } /** * Get a cloud object based on the node number --- 117,148 ---- * * @param nameServerCloud name cloud containing the cloud nodes to use ! * @param cloudAlias node number of alias of the cloud node * @return cloud instance * @throws BridgeException if the node does not exist */ ! public static Cloud getCloudByAlias(Cloud nameServerCloud, String cloudAlias) throws BridgeException { ! Node cloudNode = getCloudNodeByAlias(nameServerCloud, cloudAlias); ! return getCloudFromNode(cloudNode); ! } ! protected static Node getCloudNodeByAlias(Cloud nameServerCloud, String alias) throws BridgeException { ! Node cloudNode = nameServerCloud.getNode(alias); ! ! if (cloudNode == null) { ! throw new BridgeException("Can not find cloud with alias(" + alias ! + ") in the nameServerCloud"); } ! return cloudNode; } + public static Cloud getCloudWithName(Cloud cloud, String name) { + Node defaultCloud = cloud.getNode("cloud.default"); + if (name.equals(defaultCloud.getStringValue("name"))) { + return cloud; + } + int cloudNumber = CloudManager.getCloudNumber(cloud, name); + return CloudManager.getCloud(cloud, cloudNumber); + } + /** * Get a cloud object based on the node number *************** *** 134,137 **** --- 162,175 ---- return getCloudFromNode(node); } + + public static Node getCloudNodeByNumber(Cloud nameServerCloud, int number) throws BridgeException { + Node cloudNode = nameServerCloud.getNode(number); + if (cloudNode == null) { + throw new BridgeException("Can not find cloud with number(" + + number + + ") in the nameServerCloud"); + } + return cloudNode; + } /** *************** *** 142,146 **** * @return cloud instance */ ! private static Cloud getCloudFromNode(Node cloudNode) { if (!cloudNode.getNodeManager().getName().equals(CLOUD)) { throw new BridgeException("does not point to a cloud node"); --- 180,184 ---- * @return cloud instance */ ! public static Cloud getCloudFromNode(Node cloudNode) { if (!cloudNode.getNodeManager().getName().equals(CLOUD)) { throw new BridgeException("does not point to a cloud node"); *************** *** 154,158 **** if ((username != null) && !username.equals("")) { ! Map user = new HashMap(); user.put("username", username); user.put("password", password); --- 192,196 ---- if ((username != null) && !username.equals("")) { ! Map<String, String> user = new HashMap<String, String>(); user.put("username", username); user.put("password", password); *************** *** 161,163 **** --- 199,206 ---- return cloudContext.getCloud("mmbase"); } + + public static Cloud getAdminCloud() { + return CloudProviderFactory.getCloudProvider().getAdminCloud(); + } + } Index: PublishManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PublishManager.java 17 Oct 2006 10:02:54 -0000 1.3 --- PublishManager.java 16 Dec 2006 13:14:45 -0000 1.4 *************** *** 14,19 **** --- 14,25 ---- package org.mmbase.remotepublishing; + import java.util.ArrayList; import java.util.Collection; + import java.util.HashMap; import java.util.HashSet; + import java.util.Date; + import java.util.Iterator; + import java.util.List; [...1508 lines suppressed...] } ! unLinkNode(localCloud, remoteNode.getCloud(), remoteNode.getNumber()); remoteNode.delete(); } } --- 1058,1069 ---- } ! unLinkNode(localCloudInfo, remoteCloudInfo, remoteNode.getNumber()); remoteNode.delete(); } + public static void unLinkImportedNode(int number) { + CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); + unLinkNode(localCloudInfo, localCloudInfo.getCloud().getNode(number)); + } + } |
From: Nico K. <nkl...@us...> - 2006-12-16 13:14:55
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7431/remotepublishing Modified Files: project.xml Log Message: Performance improvements Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** project.xml 17 Oct 2006 10:02:54 -0000 1.3 --- project.xml 16 Dec 2006 13:14:50 -0000 1.4 *************** *** 5,9 **** <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.3</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> --- 5,9 ---- <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.10</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> |
From: Nico K. <nkl...@us...> - 2006-12-16 13:14:55
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv7431/remotepublishing/config/applications/Publisher/builders Modified Files: remotenodes.xml publishqueue.xml Log Message: Performance improvements Index: remotenodes.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/remotenodes.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** remotenodes.xml 17 Oct 2006 10:02:54 -0000 1.2 --- remotenodes.xml 16 Dec 2006 13:14:49 -0000 1.3 *************** *** 136,138 **** --- 136,149 ---- </field> </fieldlist> + + <indexlist> + <index name="src"> + <indexfield name="sourcenumber" /> + <indexfield name="sourcecloud" /> + </index> + <index name="dest"> + <indexfield name="destinationnumber" /> + <indexfield name="destinationcloud" /> + </index> + </indexlist> </builder> Index: publishqueue.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/publishqueue.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** publishqueue.xml 17 Oct 2006 10:02:54 -0000 1.2 --- publishqueue.xml 16 Dec 2006 13:14:49 -0000 1.3 *************** *** 140,144 **** <!-- update , delete , publish --> <name>status</name> ! <type state="persistent" size="500" notnull="true">STRING</type> </db> </field> --- 140,144 ---- <!-- update , delete , publish --> <name>status</name> ! <type state="persistent" size="32" notnull="true">STRING</type> </db> </field> *************** *** 168,170 **** --- 168,177 ---- </field> </fieldlist> + + <indexlist> + <index name="publishqueue"> + <indexfield name="status" /> + <indexfield name="publishdate" /> + </index> + </indexlist> </builder> |
From: Nico K. <nkl...@us...> - 2006-12-16 13:13:51
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6895/mmcommons/src/java/net/sf/mmapps/commons/bridge Modified Files: RelationUtil.java Log Message: eists and getRelation methods Index: RelationUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge/RelationUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RelationUtil.java 28 Jun 2006 08:25:24 -0000 1.3 --- RelationUtil.java 16 Dec 2006 13:13:47 -0000 1.4 *************** *** 7,11 **** import org.mmbase.bridge.*; import org.mmbase.bridge.util.SearchUtil; ! import org.mmbase.storage.search.AggregatedField; public class RelationUtil { --- 7,11 ---- import org.mmbase.bridge.*; import org.mmbase.bridge.util.SearchUtil; ! import org.mmbase.storage.search.*; public class RelationUtil { *************** *** 152,155 **** --- 152,181 ---- return relation; } + + public static boolean exists(NodeManager manager, int source, int destination) { + NodeList list = getRelations(manager, source, destination); + return !list.isEmpty(); + } + public static Relation getRelation(NodeManager manager, int source, int destination) { + NodeList list = getRelations(manager, source, destination); + if (!list.isEmpty()) { + Node node = list.getNode(9); + if (node.isRelation()) { + return node.toRelation(); + } + } + return null; + } + + public static NodeList getRelations(NodeManager manager, int source, int destination) { + NodeQuery query = manager.createQuery(); + Constraint s = SearchUtil.createEqualConstraint(query, manager.getField("snumber"), source); + Constraint d = SearchUtil.createEqualConstraint(query, manager.getField("dnumber"), destination); + Constraint composite = query.createConstraint(s, CompositeConstraint.LOGICAL_AND, d); + query.setConstraint(composite); + + NodeList list = manager.getList(query); + return list; + } } |
From: Nico K. <nkl...@us...> - 2006-12-16 13:13:31
|
Update of /cvsroot/mmapps/mmapps/mmcommons/resources/net/sf/mmapps/commons/util In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv6837/mmcommons/resources/net/sf/mmapps/commons/util Added Files: DateUtil_en.properties Log Message: Default english --- NEW FILE: DateUtil_en.properties --- #empty placeholder of default bundle, please change the default bundle |
From: Nico K. <nkl...@us...> - 2006-10-17 10:03:00
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2911/remotepublishing/src/org/mmbase/remotepublishing/util Modified Files: PublishUtil.java Log Message: Upgrade to mmbase 1.8 Index: PublishUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/PublishUtil.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PublishUtil.java 18 Apr 2006 09:41:38 -0000 1.2 --- PublishUtil.java 17 Oct 2006 10:02:54 -0000 1.3 *************** *** 14,24 **** package org.mmbase.remotepublishing.util; ! import java.util.Iterator; ! import java.util.List; import org.mmbase.bridge.*; import org.mmbase.module.core.*; import org.mmbase.util.logging.*; - import org.mmbase.remotepublishing.CloudFactory; --- 14,24 ---- package org.mmbase.remotepublishing.util; ! import java.util.*; ! ! import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory; import org.mmbase.bridge.*; import org.mmbase.module.core.*; import org.mmbase.util.logging.*; *************** *** 35,50 **** * @param objectNodenode the node to put in the publish queue **/ ! public static void PublishOrUpdateNode(MMObjectNode objectNodenode) { int number = objectNodenode.getIntValue("number"); ! PublishOrUpdateNode(number); } /** * add a node to the publish queue * @param node the node to put in the publish queue **/ ! public static void PublishOrUpdateNode(Node node) { int number = node.getNumber(); ! PublishOrUpdateNode(number); } --- 35,58 ---- * @param objectNodenode the node to put in the publish queue **/ ! public static void publishOrUpdateNode(MMObjectNode objectNodenode) { int number = objectNodenode.getIntValue("number"); ! publishOrUpdateNode(getAdminCloud(), number, null); } /** * add a node to the publish queue + * @param number the node to put in the publish queue + **/ + public static void publishOrUpdateNode(int number) { + publishOrUpdateNode(getAdminCloud(), number, null); + } + + /** + * add a node to the publish queue * @param node the node to put in the publish queue **/ ! public static void publishOrUpdateNode(Node node) { int number = node.getNumber(); ! publishOrUpdateNode(node.getCloud(), number, null); } *************** *** 52,65 **** * add a node to the publish queue * @param number the number of the node to put in the publish queue **/ ! public static void PublishOrUpdateNode(int number) { log.debug("PublishOrUpdateNode with number = " + number); ! Cloud cloud = CloudFactory.getAdminCloud(); ! NodeManager nodeManager = cloud.getNodeManager("publishqueue"); ! Node node = nodeManager.createNode(); ! node.setIntValue("sourcenumber", number); ! node.setIntValue("destinationcloud", -1); ! node.setStringValue("action", "update"); ! node.commit(); } --- 60,78 ---- * add a node to the publish queue * @param number the number of the node to put in the publish queue + * @param cloud cloud instance **/ ! public static void publishOrUpdateNode(Cloud cloud, int number) { ! publishOrUpdateNode(cloud, number, null); ! } ! ! /** ! * add a node to the publish queue ! * @param number the number of the node to put in the publish queue ! * @param cloud cloud instance ! * @param publishDate publish when this date has passed ! **/ ! public static void publishOrUpdateNode(Cloud cloud, int number, Date publishDate) { log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, -1, "update", publishDate); } *************** *** 70,74 **** public static void removeNode(MMObjectNode objectNodenode) { int number = objectNodenode.getIntValue("number"); ! removeNode(number); } --- 83,87 ---- public static void removeNode(MMObjectNode objectNodenode) { int number = objectNodenode.getIntValue("number"); ! removeNode(getAdminCloud(), number); } *************** *** 76,99 **** * add the node to the queue to remove all published instances of a node * @param number the number of the node to be removed **/ ! public static void removeNode(int number) { log.debug("removeNode with number = " + number); ! Cloud cloud = CloudFactory.getAdminCloud(); ! NodeManager nodeManager = cloud.getNodeManager("publishqueue"); ! Node node = nodeManager.createNode(); ! node.setIntValue("sourcenumber", number); ! node.setIntValue("destinationcloud", -1); ! node.setStringValue("action", "remove"); ! node.commit(); } ! public static void removeFromQueue(Node content, List clouds) { ! log.debug("removeFromQueue with number = " + content.getNumber()); ! Cloud cloud = CloudFactory.getAdminCloud(); ! NodeManager nodeManager = cloud.getNodeManager("publishqueue"); for (Iterator cloudIter = clouds.iterator(); cloudIter.hasNext();) { Node cloudNode = (Node) cloudIter.next(); ! NodeList list = nodeManager.getList("[status] != 'fail' and [status] != 'done' and sourcenumber = " + content.getNumber() + " and sourcecloud = " + cloudNode.getNumber() , null, null); NodeIterator iter = list.nodeIterator(); while (iter.hasNext()) { --- 89,110 ---- * add the node to the queue to remove all published instances of a node * @param number the number of the node to be removed + * @param cloud cloud instance **/ ! public static void removeNode(Cloud cloud, int number) { ! removeNode(cloud, number, null); ! } ! ! public static void removeNode(Cloud cloud, int number, Date publishDate) { log.debug("removeNode with number = " + number); ! createQueueNode(cloud, number, -1, "remove", publishDate); } ! public static void removeFromQueue(Node node, List clouds) { ! log.debug("removeFromQueue with number = " + node.getNumber()); ! NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); for (Iterator cloudIter = clouds.iterator(); cloudIter.hasNext();) { Node cloudNode = (Node) cloudIter.next(); ! NodeList list = nodeManager.getList("[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber() + " and sourcecloud = " + cloudNode.getNumber() , null, null); NodeIterator iter = list.nodeIterator(); while (iter.hasNext()) { *************** *** 104,127 **** } ! public static void PublishOrUpdateNode(Node node, Node cloudNode) { if (node == null) { ! log.error("Node = null"); } if (cloudNode == null) { ! log.error("CloudNode = null " + (node == null ? -1: node.getNumber())); } ! PublishOrUpdateNode(node.getNumber(), cloudNode.getNumber()); } ! public static void PublishOrUpdateNode(int number, int cloudNumber) { log.debug("PublishOrUpdateNode with number = " + number); ! Cloud cloud = CloudFactory.getAdminCloud(); NodeManager nodeManager = cloud.getNodeManager("publishqueue"); Node node = nodeManager.createNode(); node.setIntValue("sourcenumber", number); ! node.setIntValue("destinationcloud", cloudNumber); ! node.setStringValue("action", "update"); node.commit(); } ! } --- 115,154 ---- } ! public static void publishOrUpdateNode(Node node, Node cloudNode) { if (node == null) { ! throw new IllegalArgumentException("Node = null"); } if (cloudNode == null) { ! throw new IllegalArgumentException("CloudNode = null " + (node == null ? -1: node.getNumber())); } ! publishOrUpdateNode(node.getCloud(), node.getNumber(), cloudNode.getNumber()); } ! public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber) { ! publishOrUpdateNode(cloud, number, cloudNumber, null); ! } ! ! public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, Date publishDate) { log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, cloudNumber, "update", publishDate); ! } ! ! private static Cloud getAdminCloud() { ! return CloudProviderFactory.getCloudProvider().getAdminCloud(); ! } ! ! private static void createQueueNode(Cloud cloud, int number, int cloudNumber, String action, Date publishDate) { NodeManager nodeManager = cloud.getNodeManager("publishqueue"); Node node = nodeManager.createNode(); node.setIntValue("sourcenumber", number); ! node.setStringValue("action", action); ! if (cloudNumber > 0) { ! node.setIntValue("destinationcloud", cloudNumber); ! } ! if (publishDate != null) { ! node.setDateValue("publishdate", publishDate); ! } node.commit(); } ! } |
From: Nico K. <nkl...@us...> - 2006-10-17 10:03:00
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2911/remotepublishing/src/org/mmbase/remotepublishing/builders Modified Files: PublishingBuilder.java PublishingQueueBuilder.java PublishRelationBuilder.java Log Message: Upgrade to mmbase 1.8 Index: PublishingBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PublishingBuilder.java 18 Apr 2006 09:27:45 -0000 1.2 --- PublishingBuilder.java 17 Oct 2006 10:02:54 -0000 1.3 *************** *** 17,21 **** import org.mmbase.module.core.MMObjectBuilder; import org.mmbase.module.core.MMObjectNode; - import org.mmbase.module.corebuilders.FieldDefs; import org.mmbase.remotepublishing.action.PublishingAction; import org.mmbase.remotepublishing.action.PublishingActionDummy; --- 17,20 ---- *************** *** 77,81 **** if (number != -1) { if (publish) { ! PublishUtil.PublishOrUpdateNode(number); } else { --- 76,80 ---- if (number != -1) { if (publish) { ! PublishUtil.publishOrUpdateNode(number); } else { *************** *** 101,111 **** boolean publishnow = true; ! FieldDefs fielddefs = getField("publishnow"); ! if (fielddefs != null) { publishnow = objectNode.getBooleanValue("publishnow"); } // no publishnow field or publishnow field was true. if (publishnow) { ! PublishUtil.PublishOrUpdateNode(objectNode); } } --- 100,109 ---- boolean publishnow = true; ! if (getField("publishnow") != null) { publishnow = objectNode.getBooleanValue("publishnow"); } // no publishnow field or publishnow field was true. if (publishnow) { ! PublishUtil.publishOrUpdateNode(objectNode); } } Index: PublishingQueueBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingQueueBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PublishingQueueBuilder.java 18 Jul 2004 14:59:22 -0000 1.1 --- PublishingQueueBuilder.java 17 Oct 2006 10:02:54 -0000 1.2 *************** *** 14,28 **** package org.mmbase.remotepublishing.builders; ! import org.mmbase.bridge.BridgeException; ! import org.mmbase.bridge.Cloud; ! import org.mmbase.bridge.Node; ! import org.mmbase.bridge.NodeList; ! import org.mmbase.bridge.Relation; import org.mmbase.module.core.MMBase; import org.mmbase.module.core.MMObjectBuilder; import org.mmbase.module.core.MMObjectNode; - import org.mmbase.remotepublishing.CloudFactory; import org.mmbase.remotepublishing.CloudManager; import org.mmbase.remotepublishing.PublishManager; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; --- 14,32 ---- package org.mmbase.remotepublishing.builders; ! import java.util.*; ! ! import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory; ! ! import org.mmbase.bridge.*; ! import org.mmbase.cache.CachePolicy; import org.mmbase.module.core.MMBase; import org.mmbase.module.core.MMObjectBuilder; import org.mmbase.module.core.MMObjectNode; import org.mmbase.remotepublishing.CloudManager; import org.mmbase.remotepublishing.PublishManager; + import org.mmbase.remotepublishing.PublishListener; + import org.mmbase.storage.search.*; + import org.mmbase.storage.search.implementation.BasicFieldValueConstraint; + import org.mmbase.storage.search.implementation.NodeSearchQuery; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; *************** *** 33,37 **** * @version PublishingQueueBuilder.java,v 1.2 2003/07/28 09:43:51 nico Exp */ ! public class PublishingQueueBuilder extends MMObjectBuilder implements Runnable { private static Logger log = Logging.getLoggerInstance(PublishingQueueBuilder.class.getName()); --- 37,41 ---- * @version PublishingQueueBuilder.java,v 1.2 2003/07/28 09:43:51 nico Exp */ ! public class PublishingQueueBuilder extends MMObjectBuilder implements Runnable{ private static Logger log = Logging.getLoggerInstance(PublishingQueueBuilder.class.getName()); *************** *** 45,48 **** --- 49,54 ---- /** Milliseconds how long the thread will sleep */ private int interval = 60 * 1000; + + private static List<PublishListener> publishListeners = new ArrayList<PublishListener>(); /** *************** *** 52,58 **** **/ public boolean init() { ! remoteCloudName = getInitParameter("remotecloud"); if ((remoteCloudName != null) && (!"".equals(remoteCloudName))) { ! log.info("remote cloud wil be " + remoteCloudName); } else { --- 58,66 ---- **/ public boolean init() { ! Map params = getInitParameters("mmbase/remotepublishing"); ! ! remoteCloudName = (String) params.get("remotecloud"); if ((remoteCloudName != null) && (!"".equals(remoteCloudName))) { ! log.info("remote cloud will be " + remoteCloudName); } else { *************** *** 62,66 **** // Initialize the module. ! String intervalStr = getInitParameter("interval"); if (intervalStr == null) { throw new IllegalArgumentException("interval"); --- 70,74 ---- // Initialize the module. ! String intervalStr = (String) params.get("interval"); if (intervalStr == null) { throw new IllegalArgumentException("interval"); *************** *** 69,73 **** if (thread == null) { ! thread = new Thread(this); thread.setDaemon(true); thread.start(); --- 77,81 ---- if (thread == null) { ! thread = new Thread(this, "PublishQueue " + remoteCloudName); thread.setDaemon(true); thread.start(); *************** *** 86,99 **** public void setDefaults(MMObjectNode node) { ! node.setValue("timestamp", System.currentTimeMillis() / 1000); ! if ((remoteCloudNumber == -1) && (remoteCloudName != null)) { ! remoteCloudNumber = CloudManager.getCloudNumber(CloudFactory.getAdminCloud(), remoteCloudName); } node.setValue("destinationcloud", remoteCloudNumber); - node.setValue("status", "init"); } public void run() { log.info("Publishing Queue initialised"); --- 94,136 ---- public void setDefaults(MMObjectNode node) { ! super.setDefaults(node); if ((remoteCloudNumber == -1) && (remoteCloudName != null)) { ! remoteCloudNumber = getCloudNumber(remoteCloudName); } node.setValue("destinationcloud", remoteCloudNumber); } + /** + * Get number of cloud from local system + * @param name the name of the cloud ( in the cloud list) + * @return cloud node number + * @throws BridgeException if the cloud was not found + */ + public static int getCloudNumber(String name) throws BridgeException { + MMObjectBuilder builder = MMBase.getMMBase().getBuilder("cloud"); + NodeSearchQuery query = new NodeSearchQuery(builder); + StepField nameStepField = query.getField(builder.getField("name")); + BasicFieldValueConstraint cName = new BasicFieldValueConstraint(nameStepField, name); + cName.setOperator(FieldCompareConstraint.EQUAL); + query.setConstraint(cName); + + try { + List nodes = builder.getNodes(query); + if (nodes.isEmpty()) { + throw new BridgeException("can not find cloud with name(" + + name + + ") in nameServerCloud"); + } + return ((MMObjectNode)nodes.get(0)).getNumber(); + + } catch (SearchQueryException e) { + throw new BridgeException("can not find cloud with name(" + + name + + ") in nameServerCloud", e); + } + } + + public void run() { log.info("Publishing Queue initialised"); *************** *** 114,119 **** } else { ! Cloud cloud = CloudFactory.getAdminCloud(); ! NodeList list = cloud.getNodeManager("publishqueue").getList("[status] != 'fail' and [status] != 'done'", null, null); for (int x = 0; x < list.size(); x++) { --- 151,186 ---- } else { ! Cloud cloud = getAdminCloud(); ! NodeManager nodeManager = cloud.getNodeManager("publishqueue"); ! NodeQuery query = nodeManager.createQuery(); ! ! StepField statusField = query.getStepField(nodeManager.getField("status")); ! FieldValueConstraint failStatus = query.createConstraint(statusField, ! FieldCompareConstraint.NOT_EQUAL, "fail"); ! query.setCaseSensitive(failStatus, false); ! FieldValueConstraint doneStatus = query.createConstraint(statusField, ! FieldCompareConstraint.NOT_EQUAL, "done"); ! query.setCaseSensitive(doneStatus, false); ! Constraint statusComposite = query.createConstraint( ! failStatus, CompositeConstraint.LOGICAL_AND, doneStatus); ! ! if (!nodeManager.hasField("publishdate")) { ! query.setConstraint(statusComposite); ! } ! else { ! StepField publishDateField = query.getStepField(nodeManager.getField("publishdate")); ! Constraint publishNull = query.createConstraint(publishDateField); ! Constraint publishNow = query.createConstraint( ! publishDateField, FieldCompareConstraint.LESS_EQUAL, new Date()); ! ! Constraint publishDateComposite = query.createConstraint( ! publishNow, CompositeConstraint.LOGICAL_OR, publishNull); ! Constraint composite = query.createConstraint( ! statusComposite, CompositeConstraint.LOGICAL_AND, publishDateComposite); ! query.setConstraint(composite); ! } ! ! query.setCachePolicy(CachePolicy.NEVER); ! NodeList list = nodeManager.getList(query); for (int x = 0; x < list.size(); x++) { *************** *** 129,140 **** } catch (BridgeException e) { ! log.error("Nodenumber : " + node.getNumber() + ", " + e); node.setStringValue("status", "fail"); node.commit(); } } else { if (node.getStringValue("action").equalsIgnoreCase("remove")) { ! removeNode(node); } } --- 196,226 ---- } catch (BridgeException e) { ! log.error("Nodenumber : " + node.getNumber() + ", " + e, e); node.setStringValue("status", "fail"); node.commit(); + for(PublishListener listener : publishListeners) { + int number = node.getIntValue("sourcenumber"); + if (cloud.hasNode(number)) { + listener.publishedFailed(cloud.getNode(number)); + } + } } } else { if (node.getStringValue("action").equalsIgnoreCase("remove")) { ! try { ! removeNode(node); ! } ! catch (BridgeException e) { ! log.error("Removing published node (" + node.getNumber() + ") failed", e); ! node.setStringValue("status", "fail"); ! node.commit(); ! for(PublishListener listener : publishListeners) { ! int number = node.getIntValue("sourcenumber"); ! if (cloud.hasNode(number)) { ! listener.publishedFailed(cloud.getNode(number)); ! } ! } ! } } } *************** *** 149,157 **** } ! /** ! * @param publishQueueNode ! * @return ! */ ! private boolean isAllowedToPublish(Node publishQueueNode) { return true; } --- 235,239 ---- } ! protected boolean isAllowedToPublish(Node publishQueueNode) { return true; } *************** *** 160,164 **** int number = publishQueueNode.getIntValue("sourcenumber"); int cloudNumber = publishQueueNode.getIntValue("destinationcloud"); ! Cloud cloud = CloudFactory.getAdminCloud(); Cloud remoteCloud = CloudManager.getCloud(cloud, cloudNumber); Node node = cloud.getNode(number); --- 242,246 ---- int number = publishQueueNode.getIntValue("sourcenumber"); int cloudNumber = publishQueueNode.getIntValue("destinationcloud"); ! Cloud cloud = getAdminCloud(); Cloud remoteCloud = CloudManager.getCloud(cloud, cloudNumber); Node node = cloud.getNode(number); *************** *** 188,191 **** --- 270,277 ---- PublishManager.publishNode(node, remoteCloud); } + + for(PublishListener listener : publishListeners) { + listener.published(node); + } } else { *************** *** 199,214 **** private void removeNode(Node publishQueueNode) { int number = publishQueueNode.getIntValue("sourcenumber"); ! Cloud cloud = CloudFactory.getAdminCloud(); ! try { ! PublishManager.deletePublishedNode(cloud, number); ! publishQueueNode.setStringValue("status", "done"); ! publishQueueNode.commit(); ! } ! catch (Exception e) { ! log.debug(e.getMessage()); ! publishQueueNode.setStringValue("status", "fail"); ! publishQueueNode.commit(); ! } } } --- 285,306 ---- private void removeNode(Node publishQueueNode) { int number = publishQueueNode.getIntValue("sourcenumber"); ! Cloud cloud = getAdminCloud(); ! PublishManager.deletePublishedNode(cloud, number); ! publishQueueNode.setStringValue("status", "done"); ! publishQueueNode.commit(); ! } ! ! ! private Cloud getAdminCloud() { ! return CloudProviderFactory.getCloudProvider().getAdminCloud(); ! } ! ! public static void addPublishListener(PublishListener publishListener) { ! publishListeners.add(publishListener); ! } ! ! public static void removePublishListener(PublishListener publishListener) { ! publishListeners.remove(publishListener); } } Index: PublishRelationBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishRelationBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PublishRelationBuilder.java 18 Jul 2004 14:59:22 -0000 1.1 --- PublishRelationBuilder.java 17 Oct 2006 10:02:54 -0000 1.2 *************** *** 40,44 **** if (number != -1) { if (publish) { ! PublishUtil.PublishOrUpdateNode(number); } } --- 40,44 ---- if (number != -1) { if (publish) { ! PublishUtil.publishOrUpdateNode(number); } } *************** *** 50,54 **** if (publish) { ! PublishUtil.PublishOrUpdateNode(objectNode); } return retval; --- 50,54 ---- if (publish) { ! PublishUtil.publishOrUpdateNode(objectNode); } return retval; |
From: Nico K. <nkl...@us...> - 2006-10-17 10:03:00
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2911/remotepublishing/config/applications/Publisher/builders Modified Files: cloud.xml remotenodes.xml publishqueue.xml Log Message: Upgrade to mmbase 1.8 Index: remotenodes.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/remotenodes.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** remotenodes.xml 18 Jul 2004 14:59:22 -0000 1.1 --- remotenodes.xml 17 Oct 2006 10:02:54 -0000 1.2 *************** *** 1,4 **** <?xml version="1.0" encoding="UTF-8"?> - <!DOCTYPE builder PUBLIC "-//MMBase//DTD builder config 1.1//EN" "http://www.mmbase.org/dtd/builder_1_1.dtd"> <!-- * MMBase Remote Publishing --- 1,3 ---- *************** *** 14,21 **** * under the License. --> ! <builder name="remotenodes" maintainer="mmbase.org" version="1" extends="object"> <status>active</status> ! <classfile>Dummy</classfile> <searchage>14</searchage> --- 13,24 ---- * under the License. --> ! <builder xmlns="http://www.mmbase.org/xmlns/builder" ! xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ! xsi:schemaLocation="http://www.mmbase.org/xmlns/builder ! http://www.mmbase.org/xmlns/builder.xsd" ! name="remotenodes" maintainer="mmbase.org" version="1" extends="object"> <status>active</status> ! <!-- <class>RemotePublish.RemoteNodes</class> --> <searchage>14</searchage> *************** *** 41,45 **** <guiname xml:lang="en">TimeStamp</guiname> <guiname xml:lang="nl">TijdStempel</guiname> - <guitype>integer</guitype> </gui> <editor> --- 44,47 ---- *************** *** 50,57 **** </positions> </editor> ! <db> ! <name xml:lang="us">timestamp</name> ! <type state="persistent" notnull="true">INTEGER</type> ! </db> </field> <field> --- 52,62 ---- </positions> </editor> ! <datatype xmlns="http://www.mmbase.org/xmlns/datatypes"> ! <default value="now" /> ! </datatype> ! <db> ! <name>timestamp</name> ! <type key="false" notnull="false" state="persistent">DATETIME</type> ! </db> </field> <field> *************** *** 60,64 **** <guiname xml:lang="en">SourceCloud</guiname> <guiname xml:lang="nl">SourceCloud</guiname> - <guitype>integer</guitype> </gui> <editor> --- 65,68 ---- *************** *** 69,75 **** </positions> </editor> <db> ! <name xml:lang="us">sourcecloud</name> ! <type state="persistent" size="255" notnull="true">INTEGER</type> </db> </field> --- 73,80 ---- </positions> </editor> + <datatype xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> ! <name>sourcecloud</name> ! <type state="persistent" notnull="true">INTEGER</type> </db> </field> *************** *** 79,83 **** <guiname xml:lang="en">SourceNumber</guiname> <guiname xml:lang="nl">SourceNummer</guiname> - <guitype>integer</guitype> </gui> <editor> --- 84,87 ---- *************** *** 89,93 **** </editor> <db> ! <name xml:lang="us">sourcenumber</name> <type state="persistent" notnull="true">INTEGER</type> </db> --- 93,97 ---- </editor> <db> ! <name>sourcenumber</name> <type state="persistent" notnull="true">INTEGER</type> </db> *************** *** 98,102 **** <guiname xml:lang="en">DestinationCloud</guiname> <guiname xml:lang="nl">DestinationCloud</guiname> - <guitype>integer</guitype> </gui> <editor> --- 102,105 ---- *************** *** 107,113 **** </positions> </editor> <db> ! <name xml:lang="us">destinationcloud</name> ! <type state="persistent" size="255" notnull="true">INTEGER</type> </db> </field> --- 110,117 ---- </positions> </editor> + <datatype xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> ! <name>destinationcloud</name> ! <type state="persistent" notnull="true">INTEGER</type> </db> </field> *************** *** 118,122 **** <guiname xml:lang="en">DestinationNumber</guiname> <guiname xml:lang="nl">DestinationNumber</guiname> - <guitype>integer</guitype> </gui> <editor> --- 122,125 ---- *************** *** 128,132 **** </editor> <db> ! <name xml:lang="us">destinationnumber</name> <type state="persistent" notnull="true">INTEGER</type> </db> --- 131,135 ---- </editor> <db> ! <name>destinationnumber</name> <type state="persistent" notnull="true">INTEGER</type> </db> Index: cloud.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/cloud.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cloud.xml 18 Jul 2004 14:59:22 -0000 1.1 --- cloud.xml 17 Oct 2006 10:02:54 -0000 1.2 *************** *** 1,4 **** <?xml version="1.0" encoding="UTF-8"?> - <!DOCTYPE builder PUBLIC "-//MMBase//DTD builder config 1.1//EN" "http://www.mmbase.org/dtd/builder_1_1.dtd"> <!-- * MMBase Remote Publishing --- 1,3 ---- *************** *** 14,21 **** * under the License. --> ! <builder name="cloud" maintainer="mmbase.org" version="1" extends="object"> <status>active</status> ! <classfile>Dummy</classfile> <searchage>14</searchage> --- 13,24 ---- * under the License. --> ! <builder xmlns="http://www.mmbase.org/xmlns/builder" ! xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ! xsi:schemaLocation="http://www.mmbase.org/xmlns/builder ! http://www.mmbase.org/xmlns/builder.xsd" ! name="cloud" maintainer="mmbase.org" version="1" extends="object"> <status>active</status> ! <!-- <class>RemotePublish.Cloud</class> --> <searchage>14</searchage> *************** *** 41,45 **** <guiname xml:lang="en">name</guiname> <guiname xml:lang="nl">name</guiname> - <guitype>string</guitype> </gui> <editor> --- 44,47 ---- *************** *** 50,53 **** --- 52,56 ---- </positions> </editor> + <datatype base="line" xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> <name>name</name> *************** *** 61,65 **** <guiname xml:lang="en">username</guiname> <guiname xml:lang="nl">username</guiname> - <guitype>string</guitype> </gui> <editor> --- 64,67 ---- *************** *** 70,76 **** </positions> </editor> <db> ! <name>username</name> ! <type state="persistent" notnull="true" size="20">STRING</type> </db> </field> --- 72,79 ---- </positions> </editor> + <datatype base="line" xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> ! <name>username</name> ! <type state="persistent" notnull="true" size="20">STRING</type> </db> </field> *************** *** 80,84 **** <guiname xml:lang="en">password</guiname> <guiname xml:lang="nl">wachtwoord</guiname> - <guitype>string</guitype> </gui> <editor> --- 83,86 ---- *************** *** 89,92 **** --- 91,95 ---- </positions> </editor> + <datatype base="line" xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> <name>password</name> *************** *** 99,103 **** <guiname xml:lang="en">rmiurl</guiname> <guiname xml:lang="nl">rmiurl</guiname> - <guitype>string</guitype> </gui> <editor> --- 102,105 ---- *************** *** 108,111 **** --- 110,114 ---- </positions> </editor> + <datatype base="line" xmlns="http://www.mmbase.org/xmlns/datatypes" /> <db> <name>rmiurl</name> Index: publishqueue.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/config/applications/Publisher/builders/publishqueue.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** publishqueue.xml 18 Jul 2004 14:59:22 -0000 1.1 --- publishqueue.xml 17 Oct 2006 10:02:54 -0000 1.2 *************** *** 1,141 **** <?xml version="1.0" encoding="UTF-8"?> - <!DOCTYPE builder PUBLIC "-//MMBase//DTD builder config 1.1//EN" "http://www.mmbase.org/dtd/builder_1_1.dtd"> <!-- ! * MMBase Remote Publishing ! * ! * The contents of this file are subject to the Mozilla Public License ! * Version 1.0 (the "License"); you may not use this file except in ! * compliance with the License. You may obtain a copy of the License at ! * http://www.mozilla.org/MPL/ ! * ! * Software distributed under the License is distributed on an "AS IS" ! * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the ! * License for the specific language governing rights and limitations ! * under the License. --> ! <builder name="publishqueue" maintainer="mmbase.org" version="1" extends="object"> ! <status>active</status> ! <classfile>org.mmbase.remotepublishing.builders.PublishingQueueBuilder</classfile> ! <searchage>14</searchage> ! ! <names> ! <singular xml:lang="us">publishqueue</singular> ! <singular xml:lang="en">publishqueue</singular> ! <singular xml:lang="nl">publishqueue</singular> ! <plural xml:lang="us">publishqueues</plural> ! <plural xml:lang="en">publishqueues</plural> ! <plural xml:lang="nl">publishqueues</plural> ! </names> ! ! <descriptions> ! <description xml:lang="us">PublishQueue</description> ! <description xml:lang="en">PublishQueue</description> ! <description xml:lang="nl">PublishQueue</description> ! </descriptions> ! ! <properties> ! <property name="remotecloud">@publishqueue.remotecloud@</property> ! <property name="interval">60</property> ! </properties> ! <fieldlist> ! <field> ! <gui> ! <guiname xml:lang="us">TimeStamp</guiname> ! <guiname xml:lang="en">TimeStamp</guiname> ! <guiname xml:lang="nl">TijdStempel</guiname> ! <guitype>integer</guitype> ! </gui> ! <editor> ! <positions> ! <input>1</input> ! <list>1</list> ! <search>1</search> ! </positions> ! </editor> ! <db> ! <name>timestamp</name> ! <type state="persistent" notnull="true">INTEGER</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">nodenumber</guiname> ! <guiname xml:lang="en">nodenumber</guiname> ! <guiname xml:lang="nl">nodenumber</guiname> ! <guitype>integer</guitype> ! </gui> ! <editor> ! <positions> ! <input>2</input> ! <list>2</list> ! <search>2</search> ! </positions> ! </editor> ! <db> ! <name>sourcenumber</name> ! <type state="persistent" notnull="true">INTEGER</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">Action</guiname> ! <guiname xml:lang="en">Action</guiname> ! <guiname xml:lang="nl">Action</guiname> ! <guitype>string</guitype> ! </gui> ! <editor> ! <positions> ! <input>3</input> ! <list>3</list> ! <search>3</search> ! </positions> ! </editor> ! <db> ! <!-- update , delete , publish --> ! <name>action</name> ! <type state="persistent" size="12" notnull="true">STRING</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">DestinationCloud</guiname> ! <guiname xml:lang="en">DestinationCloud</guiname> ! <guiname xml:lang="nl">DestinationCloud</guiname> ! <guitype>integer</guitype> ! </gui> ! <editor> ! <positions> ! <input>4</input> ! <list>4</list> ! <search>4</search> ! </positions> ! </editor> ! <db> ! <name xml:lang="us">destinationcloud</name> ! <type state="persistent" notnull="true">INTEGER</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">status</guiname> ! <guiname xml:lang="en">status</guiname> ! <guiname xml:lang="nl">status</guiname> ! <guitype>string</guitype> ! </gui> ! <editor> ! <positions> ! <input>5</input> ! <list>5</list> ! <search>5</search> ! </positions> ! </editor> ! <db> ! <!-- update , delete , publish --> ! <name>status</name> ! <type state="persistent" size="500" notnull="true">STRING</type> ! </db> ! </field> ! </fieldlist> </builder> --- 1,170 ---- <?xml version="1.0" encoding="UTF-8"?> <!-- ! * MMBase Remote Publishing ! * ! * The contents of this file are subject to the Mozilla Public License ! * Version 1.0 (the "License"); you may not use this file except in ! * compliance with the License. You may obtain a copy of the License at ! * http://www.mozilla.org/MPL/ ! * ! * Software distributed under the License is distributed on an "AS IS" ! * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the ! * License for the specific language governing rights and limitations ! * under the License. --> ! <builder xmlns="http://www.mmbase.org/xmlns/builder" ! xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ! xsi:schemaLocation="http://www.mmbase.org/xmlns/builder ! http://www.mmbase.org/xmlns/builder.xsd" ! name="publishqueue" maintainer="mmbase.org" version="1" extends="object"> ! <status>active</status> ! <class>org.mmbase.remotepublishing.builders.PublishingQueueBuilder</class> ! <searchage>14</searchage> ! <names> ! <singular xml:lang="us">publishqueue</singular> ! <singular xml:lang="en">publishqueue</singular> ! <singular xml:lang="nl">publishqueue</singular> ! <plural xml:lang="us">publishqueues</plural> ! <plural xml:lang="en">publishqueues</plural> ! <plural xml:lang="nl">publishqueues</plural> ! </names> ! ! <descriptions> ! <description xml:lang="us">PublishQueue</description> ! <description xml:lang="en">PublishQueue</description> ! <description xml:lang="nl">PublishQueue</description> ! </descriptions> ! ! <properties> ! <property name="remotecloud">live.server</property> ! <property name="interval">60</property> ! </properties> ! ! <fieldlist> ! <field> ! <gui> ! <guiname xml:lang="us">TimeStamp</guiname> ! <guiname xml:lang="en">TimeStamp</guiname> ! <guiname xml:lang="nl">TijdStempel</guiname> ! </gui> ! <editor> ! <positions> ! <input>1</input> ! <list>1</list> ! <search>1</search> ! </positions> ! </editor> ! <datatype base="lastmodified" xmlns="http://www.mmbase.org/xmlns/datatypes" /> ! <db> ! <name>timestamp</name> ! <type key="false" notnull="false" state="system">DATETIME</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">nodenumber</guiname> ! <guiname xml:lang="en">nodenumber</guiname> ! <guiname xml:lang="nl">nodenumber</guiname> ! </gui> ! <editor> ! <positions> ! <input>2</input> ! <list>2</list> ! <search>2</search> ! </positions> ! </editor> ! <datatype base="integer" xmlns="http://www.mmbase.org/xmlns/datatypes" /> ! <db> ! <name>sourcenumber</name> ! <type state="persistent" notnull="true">INTEGER</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">Action</guiname> ! <guiname xml:lang="en">Action</guiname> ! <guiname xml:lang="nl">Action</guiname> ! </gui> ! <editor> ! <positions> ! <input>3</input> ! <list>3</list> ! <search>3</search> ! </positions> ! </editor> ! <datatype base="line" xmlns="http://www.mmbase.org/xmlns/datatypes" /> ! <db> ! <!-- update , delete , publish --> ! <name>action</name> ! <type state="persistent" size="12" notnull="true">STRING</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">DestinationCloud</guiname> ! <guiname xml:lang="en">DestinationCloud</guiname> ! <guiname xml:lang="nl">DestinationCloud</guiname> ! </gui> ! <editor> ! <positions> ! <input>4</input> ! <list>4</list> ! <search>4</search> ! </positions> ! </editor> ! <datatype xmlns="http://www.mmbase.org/xmlns/datatypes" /> ! <db> ! <name>destinationcloud</name> ! <type state="persistent" notnull="true">INTEGER</type> ! </db> ! </field> ! <field> ! <gui> ! <guiname xml:lang="us">status</guiname> ! <guiname xml:lang="en">status</guiname> ! <guiname xml:lang="nl">status</guiname> ! </gui> ! <editor> ! <positions> ! <input>5</input> ! <list>5</list> ! <search>5</search> ! </positions> ! </editor> ! <datatype base="line" xmlns="http://www.mmbase.org/xmlns/datatypes"> ! <default value="init"/> ! </datatype> ! <db> ! <!-- update , delete , publish --> ! <name>status</name> ! <type state="persistent" size="500" notnull="true">STRING</type> ! </db> ! </field> ! <field> ! <descriptions> ! <description xml:lang="nl"></description> ! <description xml:lang="en"></description> ! </descriptions> ! <gui> ! <guiname xml:lang="nl">Publicatie datum</guiname> ! <guiname xml:lang="en">Publishdate</guiname> ! </gui> ! <editor> ! <positions> ! <input>6</input> ! <list>-1</list> ! <search>-1</search> ! </positions> ! </editor> ! <datatype xmlns="http://www.mmbase.org/xmlns/datatypes"> ! <default value="now" /> ! </datatype> ! <db> ! <name>publishdate</name> ! <type key="false" notnull="false" state="persistent">DATETIME</type> ! </db> ! </field> ! </fieldlist> </builder> |
From: Nico K. <nkl...@us...> - 2006-10-17 10:03:00
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2911/remotepublishing/src/org/mmbase/remotepublishing Modified Files: CloudManager.java PublishManager.java Added Files: PublishListener.java Removed Files: CloudFactory.java Log Message: Upgrade to mmbase 1.8 --- NEW FILE: PublishListener.java --- package org.mmbase.remotepublishing; import org.mmbase.bridge.Node; /** * @author Jeoffrey Bakker, Finalist IT Group * @version $Revision: 1.1 $, $Date: 2006/10/17 10:02:54 $ */ public interface PublishListener { void published(Node publishedNode); void publishedFailed(Node publishedNode); } Index: CloudManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/CloudManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CloudManager.java 18 Jul 2004 14:59:22 -0000 1.1 --- CloudManager.java 17 Oct 2006 10:02:54 -0000 1.2 *************** *** 14,19 **** package org.mmbase.remotepublishing; ! import java.util.HashMap; ! import java.util.Map; import org.mmbase.bridge.BridgeException; --- 14,18 ---- package org.mmbase.remotepublishing; ! import java.util.*; import org.mmbase.bridge.BridgeException; *************** *** 22,27 **** import org.mmbase.bridge.ContextProvider; import org.mmbase.bridge.Node; ! import org.mmbase.bridge.NodeList; ! import org.mmbase.bridge.NodeManager; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; --- 21,25 ---- import org.mmbase.bridge.ContextProvider; import org.mmbase.bridge.Node; ! import org.mmbase.bridge.util.SearchUtil; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; *************** *** 32,35 **** --- 30,35 ---- public final class CloudManager { + private static final String CLOUD = "cloud"; + static Logger log = Logging.getLoggerInstance(CloudManager.class.getName()); *************** *** 37,78 **** //Utility class } ! /** * @param nameServerCloud the cloud containing the cloud nodes to use * @param name the name of the cloud ( in the cloud list) * @throws BridgeException if the cloud was not found */ ! public static Cloud getCloud(Cloud nameServerCloud, String name) throws BridgeException { ! NodeManager cloudManager = nameServerCloud.getNodeManager("cloud"); ! NodeList nl = cloudManager.getList("[name]='" + name + "'", null, null); ! if (nl.size() != 1) { throw new BridgeException("can not find cloud with name(" + name + ") in nameServerCloud"); } ! return getCloudFromNode(nl.getNode(0)); } /** * @param nameServerCloud the cloud containing the cloud nodes to use * @param name the name of the cloud ( in the cloud list) * @throws BridgeException if the cloud was not found */ ! public static int getCloudNumber(Cloud nameServerCloud, String name) throws BridgeException { ! NodeManager cloudManager = nameServerCloud.getNodeManager("cloud"); ! NodeList nl = cloudManager.getList("[name]='" + name + "'", null, null); ! ! if (nl.size() != 1) { throw new BridgeException("can not find cloud with name(" + name + ") in nameServerCloud"); } ! return nl.getNode(0).getNumber(); } ! /** * @param nameServerCloud name cloud containing the cloud nodes to use * @param alias node number of alias of the cloud node * @throws BridgeException if the node does not exist */ --- 37,107 ---- //Utility class } ! /** + * Get a cloud number based on the node name + * * @param nameServerCloud the cloud containing the cloud nodes to use * @param name the name of the cloud ( in the cloud list) + * @return cloud node number * @throws BridgeException if the cloud was not found */ ! public static int getCloudNumber(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloud = SearchUtil.findNode(nameServerCloud, CLOUD, "name", name); ! if (cloud == null) { throw new BridgeException("can not find cloud with name(" + name + ") in nameServerCloud"); } ! return cloud.getNumber(); } + /** + * gets the node-number of the remote cloud in the list in the cloud-builder this routine + * depends on unique and consistent names for clouds in the cloud builder + * + * see also applications/Publisher/builders/cloud.xml + * + * @param nameServerCloud Cloud where the number shoud be found + * @param cloud Cloud to determine the number from + * @return Number of the remoteCloud as used in localCloud + */ + public static int getCloudNumber(Cloud nameServerCloud, Cloud cloud) { + //get the name of the cloud + String cloudName = cloud.getNodeByAlias("cloud.default").getStringValue("name"); + + Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, "name", cloudName); + if (cloudNode == null) { + throw new BridgeException("remote cloud's number could not be established"); + } + return cloudNode.getNumber(); + } + + + /** + * Get a cloud object based on the node name + * * @param nameServerCloud the cloud containing the cloud nodes to use * @param name the name of the cloud ( in the cloud list) + * @return cloud instance * @throws BridgeException if the cloud was not found */ ! public static Cloud getCloud(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloud = SearchUtil.findNode(nameServerCloud, CLOUD, "name", name); ! if (cloud == null) { throw new BridgeException("can not find cloud with name(" + name + ") in nameServerCloud"); } ! return getCloudFromNode(cloud); } ! /** + * Get a cloud object based on the node alias + * * @param nameServerCloud name cloud containing the cloud nodes to use * @param alias node number of alias of the cloud node + * @return cloud instance * @throws BridgeException if the node does not exist */ *************** *** 89,123 **** /** * @param nameServerCloud name cloud containing the cloud nodes to use * @param number the node number of the cloud in the nameServerCloud */ public static Cloud getCloud(Cloud nameServerCloud, int number) throws BridgeException { Node node = nameServerCloud.getNode(number); ! return getCloudFromNode(node); ! } ! ! /** ! * gets the node-number of the remote cloud in the list in the cloud-builder this routine ! * depends on unique and consistent names for clouds in the cloud builder ! * ! * see also applications/Publisher/builders/cloud.xml ! * ! * @param nameServerCloud Cloud where the number shoud be found ! * @param cloud Cloud to determine the number from ! * @return Number of the remoteCloud as used in localCloud ! */ ! public static int getCloudNumber(Cloud nameServerCloud, Cloud cloud) { ! //get the name of the cloud ! String cloudName = cloud.getNodeByAlias("cloud.default").getStringValue("name"); ! ! //find the matching node in the name server cloud ! NodeManager lnm = nameServerCloud.getNodeManager("cloud"); ! ! NodeList nl = lnm.getList("[name]='" + cloudName + "'", null, null); ! ! if (nl.size() != 1) { ! throw new BridgeException("remote cloud's number could not be established"); } ! return nl.getNode(0).getNumber(); } --- 118,136 ---- /** + * Get a cloud object based on the node number + * * @param nameServerCloud name cloud containing the cloud nodes to use * @param number the node number of the cloud in the nameServerCloud + * @return cloud instance + * @throws BridgeException if the node does not exist */ public static Cloud getCloud(Cloud nameServerCloud, int number) throws BridgeException { Node node = nameServerCloud.getNode(number); ! if (node == null) { ! throw new BridgeException("Can not find cloud with number(" ! + number ! + ") in the nameServerCloud"); } ! return getCloudFromNode(node); } *************** *** 127,134 **** * * @param cloudNode node with cloud information stored ! * @return */ private static Cloud getCloudFromNode(Node cloudNode) { ! if (!cloudNode.getNodeManager().getName().equals("cloud")) { throw new BridgeException("does not point to a cloud node"); } --- 140,147 ---- * * @param cloudNode node with cloud information stored ! * @return cloud instance */ private static Cloud getCloudFromNode(Node cloudNode) { ! if (!cloudNode.getNodeManager().getName().equals(CLOUD)) { throw new BridgeException("does not point to a cloud node"); } --- CloudFactory.java DELETED --- Index: PublishManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PublishManager.java 18 Apr 2006 09:28:15 -0000 1.2 --- PublishManager.java 17 Oct 2006 10:02:54 -0000 1.3 *************** *** 14,17 **** --- 14,20 ---- package org.mmbase.remotepublishing; + import java.util.Collection; + import java.util.HashSet; + import org.mmbase.bridge.Cloud; import org.mmbase.bridge.Field; *************** *** 61,65 **** public final class PublishManager { ! /** MMbase logging system */ private static Logger log = Logging.getLoggerInstance(PublishManager.class.getName()); private static String MMBASE_PUBLISH_MANAGER = "remotenodes"; --- 64,72 ---- public final class PublishManager { ! private static final String SOURCE_CLOUD = "sourcecloud"; ! private static final String SOURCE_NUMBER = "sourcenumber"; ! private static final String DESTINATION_NUMBER = "destinationnumber"; ! private static final String DESTINATION_CLOUD = "destinationcloud"; ! /** MMbase logging system */ private static Logger log = Logging.getLoggerInstance(PublishManager.class.getName()); private static String MMBASE_PUBLISH_MANAGER = "remotenodes"; *************** *** 70,74 **** // Utility class } ! /** * quick test to see if node is a relation by testing fieldnames --- 77,81 ---- // Utility class } ! /** * quick test to see if node is a relation by testing fieldnames *************** *** 93,97 **** return false; } ! /** * Publish a node to a different cloud, keeping records This will also publish --- 100,104 ---- return false; } ! /** * Publish a node to a different cloud, keeping records This will also publish *************** *** 101,104 **** --- 108,112 ---- * @param remoteCloud the external cloud * @return the published copy of inNode + * @throws PublishException - when publication fails */ public static Node publishNode(Node localNode, Cloud remoteCloud) *************** *** 126,131 **** } ! // relations should only be published when both the source and the destination node are either ! // 1) published to the other cloud // 2) imported from the othercloud Node source = localCloud.getNode(localNode.getStringValue("snumber")); --- 134,139 ---- } ! // relations should only be published when both the source and the destination node are either ! // 1) published to the other cloud // 2) imported from the othercloud Node source = localCloud.getNode(localNode.getStringValue("snumber")); *************** *** 192,196 **** } } ! /** * cloneNodeField copies node fields from one node to an other --- 200,204 ---- } } ! /** * cloneNodeField copies node fields from one node to an other *************** *** 202,246 **** Field field) { String fieldName = field.getName(); int fieldType = field.getType(); ! ! switch (fieldType) { ! case Field.TYPE_BYTE: ! destinationNode.setByteValue(fieldName, ! sourceNode.getByteValue(fieldName)); ! ! break; ! ! case Field.TYPE_DOUBLE: ! destinationNode.setDoubleValue(fieldName, ! sourceNode.getDoubleValue(fieldName)); ! ! break; ! ! case Field.TYPE_FLOAT: ! destinationNode.setFloatValue(fieldName, ! sourceNode.getFloatValue(fieldName)); ! ! break; ! ! case Field.TYPE_INTEGER: ! destinationNode.setIntValue(fieldName, ! sourceNode.getIntValue(fieldName)); ! ! break; ! ! case Field.TYPE_LONG: ! destinationNode.setLongValue(fieldName, ! sourceNode.getIntValue(fieldName)); ! ! break; ! ! case Field.TYPE_STRING: ! destinationNode.setStringValue(fieldName, ! sourceNode.getStringValue(fieldName)); ! ! break; ! ! default: ! destinationNode.setValue(fieldName, sourceNode.getValue(fieldName)); } } --- 210,232 ---- Field field) { String fieldName = field.getName(); + int fieldType = field.getType(); ! if (fieldType == Field.TYPE_NODE) { ! Node nodeValue = sourceNode.getNodeValue(fieldName); ! Cloud remoteCloud = destinationNode.getCloud(); ! if (isPublished(nodeValue, remoteCloud)) { ! Node remoteNodeValue = getPublishedNode(nodeValue, remoteCloud); ! destinationNode.setNodeValue(fieldName, remoteNodeValue); ! } ! else { ! String message = "Could not fill node field (" + fieldName + "), because the referred node " + ! "(" + nodeValue.getNumber() + ") doesn't exist yet at the remotecloud. Perhaps there are some " + ! "contentelements which are not live and don't have a workflow. "; ! log.warn(message); ! } ! } ! else { ! destinationNode.setValueWithoutProcess(fieldName, ! sourceNode.getValueWithoutProcess(fieldName)); } } *************** *** 252,257 **** Node remoteSourceNode = getPublishedNode(localRelation.getNodeValue("snumber"), remoteCloud); Node remoteDestinationNode = getPublishedNode(localRelation.getNodeValue("dnumber"), remoteCloud); ! ! RelationManager remoteRelationManager = remoteCloud.getRelationManager(remoteSourceNode.getNodeManager().getName(), remoteDestinationNode.getNodeManager().getName(), --- 238,243 ---- Node remoteSourceNode = getPublishedNode(localRelation.getNodeValue("snumber"), remoteCloud); Node remoteDestinationNode = getPublishedNode(localRelation.getNodeValue("dnumber"), remoteCloud); ! ! RelationManager remoteRelationManager = remoteCloud.getRelationManager(remoteSourceNode.getNodeManager().getName(), remoteDestinationNode.getNodeManager().getName(), *************** *** 262,271 **** } Relation remoteRelation = remoteRelationManager.createRelation(remoteSourceNode, remoteDestinationNode); ! FieldIterator fields = localRelation.getNodeManager().getFields().fieldIterator(); while (fields.hasNext()) { Field field = fields.nextField(); String fieldName = field.getName(); ! if (!(fieldName.equals("owner") || fieldName.equals("number") || fieldName.equals("otype") || --- 248,257 ---- } Relation remoteRelation = remoteRelationManager.createRelation(remoteSourceNode, remoteDestinationNode); ! FieldIterator fields = localRelation.getNodeManager().getFields().fieldIterator(); while (fields.hasNext()) { Field field = fields.nextField(); String fieldName = field.getName(); ! if (!(fieldName.equals("owner") || fieldName.equals("number") || fieldName.equals("otype") || *************** *** 278,282 **** } remoteRelation.commit(); ! cloneAliasses(localRelation, remoteRelation); return remoteRelation; --- 264,268 ---- } remoteRelation.commit(); ! cloneAliasses(localRelation, remoteRelation); return remoteRelation; *************** *** 292,296 **** private static void cloneRelations(Node localNode, Cloud remoteCloud) throws PublishException { ! RelationIterator ri = localNode.getRelations().relationIterator(); if (ri.hasNext()) { log.debug("the local node has relations"); --- 278,289 ---- private static void cloneRelations(Node localNode, Cloud remoteCloud) throws PublishException { ! Cloud cloud = localNode.getCloud(); ! RelationList result = cloud.getCloudContext().createRelationList(); ! // Just add the result of both methods together ! NodeManager nodeManager = cloud.getNodeManager("object"); ! result.addAll(localNode.getRelations(null, nodeManager, "source")); ! result.addAll(localNode.getRelations(null, nodeManager, "destination")); ! ! RelationIterator ri = result.relationIterator(); if (ri.hasNext()) { log.debug("the local node has relations"); *************** *** 299,303 **** Relation rel = ri.nextRelation(); Node relatedNode = null; ! if (rel.getSource().getNumber() == localNode.getNumber()) { relatedNode = rel.getDestination(); --- 292,296 ---- Relation rel = ri.nextRelation(); Node relatedNode = null; ! if (rel.getSource().getNumber() == localNode.getNumber()) { relatedNode = rel.getDestination(); *************** *** 341,364 **** Cloud remoteCloud, Node remoteNode) { ! int localNumber = localNode.getNumber(); int remoteNumber = remoteNode.getNumber(); ! // create administatrive info ( which node has been published etc.) // in the source cloud Node admin = localCloud.getNodeManager(MMBASE_PUBLISH_MANAGER).createNode(); ! admin.setIntValue("sourcecloud",CloudManager.getCloudNumber(localCloud, localCloud)); ! admin.setIntValue("sourcenumber", localNumber); ! admin.setIntValue("destinationcloud", CloudManager.getCloudNumber(localCloud, remoteCloud)); ! admin.setIntValue("destinationnumber", remoteNumber); admin.setIntValue("timestamp", (int) (System.currentTimeMillis() / 1000)); admin.commit(); ! // now create administatrive info in the destination cloud admin = remoteCloud.getNodeManager(MMBASE_PUBLISH_MANAGER).createNode(); ! admin.setIntValue("sourcecloud", CloudManager.getCloudNumber(remoteCloud, localCloud)); ! admin.setIntValue("sourcenumber", localNumber); ! admin.setIntValue("destinationcloud", CloudManager.getCloudNumber(remoteCloud, remoteCloud)); ! admin.setIntValue("destinationnumber", remoteNumber); admin.setIntValue("timestamp", (int) (System.currentTimeMillis() / 1000)); admin.commit(); --- 334,357 ---- Cloud remoteCloud, Node remoteNode) { ! int localNumber = localNode.getNumber(); int remoteNumber = remoteNode.getNumber(); ! // create administatrive info ( which node has been published etc.) // in the source cloud Node admin = localCloud.getNodeManager(MMBASE_PUBLISH_MANAGER).createNode(); ! admin.setIntValue(SOURCE_CLOUD,CloudManager.getCloudNumber(localCloud, localCloud)); ! admin.setIntValue(SOURCE_NUMBER, localNumber); ! admin.setIntValue(DESTINATION_CLOUD, CloudManager.getCloudNumber(localCloud, remoteCloud)); ! admin.setIntValue(DESTINATION_NUMBER, remoteNumber); admin.setIntValue("timestamp", (int) (System.currentTimeMillis() / 1000)); admin.commit(); ! // now create administatrive info in the destination cloud admin = remoteCloud.getNodeManager(MMBASE_PUBLISH_MANAGER).createNode(); ! admin.setIntValue(SOURCE_CLOUD, CloudManager.getCloudNumber(remoteCloud, localCloud)); ! admin.setIntValue(SOURCE_NUMBER, localNumber); ! admin.setIntValue(DESTINATION_CLOUD, CloudManager.getCloudNumber(remoteCloud, remoteCloud)); ! admin.setIntValue(DESTINATION_NUMBER, remoteNumber); admin.setIntValue("timestamp", (int) (System.currentTimeMillis() / 1000)); admin.commit(); *************** *** 446,450 **** return false; } ! else { if (nl.size() > 1) { log.error("isPublished detected multiple remote nodes for node number{" + --- 439,443 ---- return false; } ! else { if (nl.size() > 1) { log.error("isPublished detected multiple remote nodes for node number{" + *************** *** 567,571 **** NodeManager sourcenm = sourceCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); NodeList sourcenl = sourcenm.getList("destinationnumber=" + destinationNumber + ! " AND sourcecloud=" + CloudManager.getCloudNumber(sourceCloud, sourceCloud) + " AND destinationcloud=" + CloudManager.getCloudNumber(sourceCloud, destinationCloud), null, null); --- 560,564 ---- NodeManager sourcenm = sourceCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); NodeList sourcenl = sourcenm.getList("destinationnumber=" + destinationNumber + ! " AND sourcecloud=" + CloudManager.getCloudNumber(sourceCloud, sourceCloud) + " AND destinationcloud=" + CloudManager.getCloudNumber(sourceCloud, destinationCloud), null, null); *************** *** 578,582 **** NodeManager destnm = destinationCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); NodeList destnl = destnm.getList("destinationnumber=" + destinationNumber + ! " AND sourcecloud=" + CloudManager.getCloudNumber(destinationCloud, sourceCloud) + " AND destinationcloud=" + CloudManager.getCloudNumber(destinationCloud, destinationCloud), null, null); --- 571,575 ---- NodeManager destnm = destinationCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); NodeList destnl = destnm.getList("destinationnumber=" + destinationNumber + ! " AND sourcecloud=" + CloudManager.getCloudNumber(destinationCloud, sourceCloud) + " AND destinationcloud=" + CloudManager.getCloudNumber(destinationCloud, destinationCloud), null, null); *************** *** 602,606 **** boolean isPublished = isPublished(localNode); ! NodeList nl = null; if (isPublished) { --- 595,599 ---- boolean isPublished = isPublished(localNode); ! NodeList nl = null; if (isPublished) { *************** *** 617,621 **** null, null); } ! if (nl.size() == 0) { log.debug("search for node in live environment returned an empty list"); --- 610,614 ---- null, null); } ! if (nl.size() == 0) { log.debug("search for node in live environment returned an empty list"); *************** *** 628,634 **** } if (isPublished) { ! return remoteCloud.getNode(nl.getNode(0).getIntValue("destinationnumber")); } ! return remoteCloud.getNode(nl.getNode(0).getIntValue("sourcenumber")); } --- 621,627 ---- } if (isPublished) { ! return remoteCloud.getNode(nl.getNode(0).getIntValue(DESTINATION_NUMBER)); } ! return remoteCloud.getNode(nl.getNode(0).getIntValue(SOURCE_NUMBER)); } *************** *** 657,662 **** while (ni.hasNext()) { Node admin = ni.nextNode(); ! Cloud remoteCloud = CloudManager.getCloud(localCloud, admin.getIntValue("destinationcloud")); ! output.add(remoteCloud.getNode(admin.getIntValue("destinationnumber"))); } --- 650,655 ---- while (ni.hasNext()) { Node admin = ni.nextNode(); ! Cloud remoteCloud = CloudManager.getCloud(localCloud, admin.getIntValue(DESTINATION_CLOUD)); ! output.add(remoteCloud.getNode(admin.getIntValue(DESTINATION_NUMBER))); } *************** *** 664,667 **** --- 657,676 ---- } + public static Collection<Integer> getPublishedClouds(Node localNode) { + return getPublishedClouds(localNode.getCloud(), localNode.getNumber()); + } + + public static Collection<Integer> getPublishedClouds(Cloud localCloud, int localNumber) { + NodeIterator ni = getPublishInfoNodes(localCloud, localNumber).nodeIterator(); + Collection<Integer> clouds = new HashSet<Integer>(); + + while (ni.hasNext()) { + Node admin = ni.nextNode(); + clouds.add(admin.getIntValue(DESTINATION_CLOUD)); + } + return clouds; + } + + /** * Get the source node of this localNode if this localNode is imported *************** *** 679,686 **** } ! Cloud sourceCloud = CloudManager.getCloud(localNode.getCloud(), adminNode.getIntValue("sourcecloud")); Node sourceNode = null; try { ! sourceNode = sourceCloud.getNode(adminNode.getIntValue("sourcenumber")); } catch (NotFoundException nfe) { log.debug(Logging.stackTrace(nfe)); --- 688,695 ---- } ! Cloud sourceCloud = CloudManager.getCloud(localNode.getCloud(), adminNode.getIntValue(SOURCE_CLOUD)); Node sourceNode = null; try { ! sourceNode = sourceCloud.getNode(adminNode.getIntValue(SOURCE_NUMBER)); } catch (NotFoundException nfe) { log.debug(Logging.stackTrace(nfe)); *************** *** 703,728 **** } ! return CloudManager.getCloud(destinationNode.getCloud(), adminNode.getIntValue("sourcecloud")); } ! ! ! /** ! * @param localCloud ! * @param localNumber ! * @return ! */ public static NodeList getPublishInfoNodes(Cloud localCloud, int localNumber) { synchronized (publishLock) { NodeManager nm = localCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); ! return nm.getList("sourcenumber = " + localNumber + " AND sourcecloud=" + CloudManager.getCloudNumber(localCloud, localCloud), null, null); } } ! public static int getDestinationNumber(Cloud localCloud, int destinationCloudNumber, int localNumber) { synchronized (publishLock) { NodeManager nm = localCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); ! NodeList nl = nm.getList("sourcenumber = " + localNumber + " AND sourcecloud=" + CloudManager.getCloudNumber(localCloud, localCloud) + " AND destinationcloud=" + destinationCloudNumber, --- 712,732 ---- } ! return CloudManager.getCloud(destinationNode.getCloud(), adminNode.getIntValue(SOURCE_CLOUD)); } ! ! public static NodeList getPublishInfoNodes(Cloud localCloud, int localNumber) { synchronized (publishLock) { NodeManager nm = localCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); ! return nm.getList("sourcenumber = " + localNumber + " AND sourcecloud=" + CloudManager.getCloudNumber(localCloud, localCloud), null, null); } } ! public static int getDestinationNumber(Cloud localCloud, int destinationCloudNumber, int localNumber) { synchronized (publishLock) { NodeManager nm = localCloud.getNodeManager(MMBASE_PUBLISH_MANAGER); ! NodeList nl = nm.getList("sourcenumber = " + localNumber + " AND sourcecloud=" + CloudManager.getCloudNumber(localCloud, localCloud) + " AND destinationcloud=" + destinationCloudNumber, *************** *** 731,738 **** return -1; } ! return nl.getNode(0).getIntValue("destinationnumber"); } } ! /** * --- 735,742 ---- return -1; } ! return nl.getNode(0).getIntValue(DESTINATION_NUMBER); } } ! /** * *************** *** 756,760 **** if (nl.size() > 1) { log.error( ! "Detected multiple instances of a publish-info node, but it should only be one " + "in all xases (published from or imported to the local cloud). " + "still returning the first node"); } --- 760,765 ---- if (nl.size() > 1) { log.error( ! "Detected multiple instances of a publish-info node, but it should only be one " + ! "in all xases (published from or imported to the local cloud). " + "still returning the first node"); } *************** *** 768,776 **** * * @param localNode the source node ! * ! * NOTE for WEB-IN-A-BOX developers: ! * Use of this method is <b>NOT RECOMMENDED</b> as it encourages inplace modifications ! * to nodes and that allows editing of published information ! * ** use an editNode() saveNode() combination if workflow content ** **/ public static void updatePublishedNodes(Node localNode) throws PublishException { --- 773,777 ---- * * @param localNode the source node ! * @throws PublishException - when publication fails **/ public static void updatePublishedNodes(Node localNode) throws PublishException { *************** *** 797,803 **** return; } ! Node remoteNode = getPublishedNode(localNode, remoteCloud); ! if (remoteNode != null) { syncFields(localNode, remoteNode); syncAliasses(localNode, remoteNode); --- 798,804 ---- return; } ! Node remoteNode = getPublishedNode(localNode, remoteCloud); ! if (remoteNode != null) { syncFields(localNode, remoteNode); syncAliasses(localNode, remoteNode); *************** *** 811,819 **** NodeManager nm = localNode.getNodeManager(); FieldIterator fi = nm.getFields().fieldIterator(); ! while (fi.hasNext()) { Field field = fi.nextField(); String fieldName = field.getName(); ! if (!(fieldName.equals("owner") || fieldName.equals("number") || --- 812,820 ---- NodeManager nm = localNode.getNodeManager(); FieldIterator fi = nm.getFields().fieldIterator(); ! while (fi.hasNext()) { Field field = fi.nextField(); String fieldName = field.getName(); ! if (!(fieldName.equals("owner") || fieldName.equals("number") || *************** *** 832,836 **** StringList list = localNode.getAliases(); StringList outList = remoteNode.getAliases(); ! for (int x = 0; x < outList.size(); x++) { String remoateAlias = outList.getString(x); --- 833,837 ---- StringList list = localNode.getAliases(); StringList outList = remoteNode.getAliases(); ! for (int x = 0; x < outList.size(); x++) { String remoateAlias = outList.getString(x); *************** *** 839,843 **** } } ! for (int x = 0; x < list.size(); x++) { String localAlias = list.getString(x); --- 840,844 ---- } } ! for (int x = 0; x < list.size(); x++) { String localAlias = list.getString(x); *************** *** 851,868 **** Cloud localCloud = localNode.getCloud(); Cloud remoteCloud = remoteNode.getCloud(); ! RelationList remoteList = remoteNode.getRelations(); for (int x = 0; x < remoteList.size(); x++) { Relation remoteRelation = remoteList.getRelation(x); ! Node adminNode = getPublishInfoNode(localCloud, remoteRelation.getNumber(), remoteRelation.getCloud()); if (adminNode != null) { boolean deleted = false; try { ! Node sourceNode = localCloud.getNode(adminNode.getIntValue("sourcenumber")); if (sourceNode == null) { deleted = true; } ! } catch(NotFoundException nfe) { deleted = true; --- 852,869 ---- Cloud localCloud = localNode.getCloud(); Cloud remoteCloud = remoteNode.getCloud(); ! RelationList remoteList = remoteNode.getRelations(); for (int x = 0; x < remoteList.size(); x++) { Relation remoteRelation = remoteList.getRelation(x); ! Node adminNode = getPublishInfoNode(localCloud, remoteRelation.getNumber(), remoteRelation.getCloud()); if (adminNode != null) { boolean deleted = false; try { ! Node sourceNode = localCloud.getNode(adminNode.getIntValue(SOURCE_NUMBER)); if (sourceNode == null) { deleted = true; } ! } catch(NotFoundException nfe) { deleted = true; *************** *** 878,882 **** } } ! cloneRelations(localNode, remoteCloud); } --- 879,883 ---- } } ! cloneRelations(localNode, remoteCloud); } *************** *** 924,935 **** //since the local node may not be present any more RelationIterator ri = remoteNode.getRelations().relationIterator(); ! if (!ri.hasNext()) { log.debug("the published node has no relations"); } ! while (ri.hasNext()) { Relation remoteRelation = ri.nextRelation(); ! // here we search for publish-info which was added by the local cloud // when publishing the node. When node is imported then no publish-info is returned --- 925,936 ---- //since the local node may not be present any more RelationIterator ri = remoteNode.getRelations().relationIterator(); ! if (!ri.hasNext()) { log.debug("the published node has no relations"); } ! while (ri.hasNext()) { Relation remoteRelation = ri.nextRelation(); ! // here we search for publish-info which was added by the local cloud // when publishing the node. When node is imported then no publish-info is returned *************** *** 950,956 **** remoteRelation.delete(); } ! unLinkNode(localCloud, remoteNode.getCloud(), remoteNode.getNumber()); remoteNode.delete(); } } --- 951,958 ---- remoteRelation.delete(); } ! unLinkNode(localCloud, remoteNode.getCloud(), remoteNode.getNumber()); remoteNode.delete(); } + } |