org.mmbase.remotepublishing
Class PublishManager

java.lang.Object
  extended byorg.mmbase.remotepublishing.PublishManager

public final class PublishManager
extends java.lang.Object

The primary functionality of the Publishmanager is to publish nodes to the live / staging cloud which depends on the context in which this class is being used. The problem with publishing is that nodes in different contexts have different numbers. The mapping between node numbers in different cloud contexts is maintained in the table remotenodes. This table contains 4 important fields: sourcecloud, sourcenumber, destinationcloud and destinationnumber. The source fields always keep track of where a node was first produced. The destination indicates to what cloud the node was published. The cloud fields keep a reference to one of the clouds stored in the cloud table. The number fields are a reference to a node in one of the clouds.

Example: if a node is published from the staging to the live context the sourcecloud and sourcenumber in both contexts refer to the sourcenode in the staging context. The sourcecloud field will contain different numbers for the records in the table will have different id's in both clouds. The sourcenumber field will be exact the same in both contexts. The same goes for the destination fields with this difference that the destinationnumber field in both clouds will refer to the number of the node in the live cloud.

The PublishManager distinguishes two different processes which are a) publishing - which is the process of copying a node from cloud X to cloud Y and b) importing - which is the process of copying a node from cloud Y to cloud X

Version:
$Revision: 1.1 $
Author:
Finalist IT

Method Summary
protected static org.mmbase.bridge.Node cloneNode(org.mmbase.bridge.Node localNode, org.mmbase.bridge.Cloud remoteCloud)
          Clone a node to a cloud, including any fields without keeping administrative information
protected static void cloneNodeField(org.mmbase.bridge.Node sourceNode, org.mmbase.bridge.Node destinationNode, org.mmbase.bridge.Field field)
          cloneNodeField copies node fields from one node to an other
static void deletePublishedNode(org.mmbase.bridge.Cloud localCloud, int localNumber)
          delete the remote instances of a node(with relations and relation information)
static void deletePublishedNode(org.mmbase.bridge.Node localNode)
          delete the remote instances of a node(with relations and relation information)
static org.mmbase.bridge.Node getPublishedNode(org.mmbase.bridge.Node localNode, org.mmbase.bridge.Cloud remoteCloud)
          Get the published nodes from a remote cloud.
static org.mmbase.bridge.NodeList getPublishedNodes(org.mmbase.bridge.Cloud localCloud, int localNumber)
          Get the published nodes from all remote clouds
static org.mmbase.bridge.NodeList getPublishedNodes(org.mmbase.bridge.Node localNode)
          Get the published nodes from all remote clouds
static org.mmbase.bridge.Node getPublishInfoNode(org.mmbase.bridge.Cloud localCloud, int destinationNumber, org.mmbase.bridge.Cloud destinationCloud)
           
static org.mmbase.bridge.Node getSourceNode(org.mmbase.bridge.Node localNode)
          Get the source node of this localNode if this localNode is imported
static boolean isImported(int localNumber, org.mmbase.bridge.Cloud localCloud)
          From the perspective of one cloud a node is said to be imported when the node number is available in the destinationnumber of the remotenodes table and the destinationcloud equals the cloud context (so if the context is staging the destinationcloud should refer the staging record in the cloud table)
static boolean isImported(int localNumber, org.mmbase.bridge.Cloud localCloud, org.mmbase.bridge.Cloud remoteCloud)
          Tests whether the node has been published from another cloud to this cloud
static boolean isImported(org.mmbase.bridge.Node localNode)
          From the perspective of one cloud a node is said to be imported when the node number is available in the destinationnumber of the remotenodes table and the destinationcloud equals the cloud context (so if the context is staging the destinationcloud should refer the staging record in the cloud table)
static boolean isImported(org.mmbase.bridge.Node localNode, org.mmbase.bridge.Cloud remoteCloud)
          Tests whether the node has been published from another cloud to this cloud
static boolean isPublished(int localNumber, org.mmbase.bridge.Cloud localCloud)
          Test whether a node is published to one or more other clouds.
static boolean isPublished(int localNumber, org.mmbase.bridge.Cloud localCloud, org.mmbase.bridge.Cloud remoteCloud)
          Test whether a node is published to another cloud.
static boolean isPublished(org.mmbase.bridge.Node localNode)
          Test whether a node is published to one or more other clouds.
static boolean isPublished(org.mmbase.bridge.Node localNode, org.mmbase.bridge.Cloud remoteCloud)
          Test whether a node is published to another cloud.
protected static boolean isRelation(org.mmbase.bridge.Node node)
          quick test to see if node is a relation by testing fieldnames
static org.mmbase.bridge.Node publishNode(org.mmbase.bridge.Node localNode, org.mmbase.bridge.Cloud remoteCloud)
          Publish a node to a different cloud, keeping records This will also publish all relations inNode has with other published nodes
static void unLinkNode(org.mmbase.bridge.Cloud sourceCloud, org.mmbase.bridge.Cloud destinationCloud, int sourceNumber, int destinationNumber)
          Remove the publish-info between a source node and a published version
static void unLinkNode(org.mmbase.bridge.Node localNode)
          Unlink node from all other nodes (means you can then edit/delete them) This method can also be used to republish the node from the remoteCloud to this localCloud if the localNode is deleted too.
static void unLinkNode(org.mmbase.bridge.Node sourceNode, org.mmbase.bridge.Node destinationNode)
          Remove the publish-info between a source node and a published version
static void updatePublishedNodes(org.mmbase.bridge.Node localNode)
          syncronize all nodes that are published from this one
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isRelation

protected static boolean isRelation(org.mmbase.bridge.Node node)
quick test to see if node is a relation by testing fieldnames


publishNode

public static org.mmbase.bridge.Node publishNode(org.mmbase.bridge.Node localNode,
                                                 org.mmbase.bridge.Cloud remoteCloud)
                                          throws PublishException
Publish a node to a different cloud, keeping records This will also publish all relations inNode has with other published nodes

Parameters:
localNode - the node to be published
remoteCloud - the external cloud
Returns:
the published copy of inNode
Throws:
PublishException

cloneNode

protected static org.mmbase.bridge.Node cloneNode(org.mmbase.bridge.Node localNode,
                                                  org.mmbase.bridge.Cloud remoteCloud)
Clone a node to a cloud, including any fields without keeping administrative information

Parameters:
localNode - the node to clone
remoteCloud - the cloud to clone the node to
Returns:
the newly created node in the other cloud

cloneNodeField

protected static void cloneNodeField(org.mmbase.bridge.Node sourceNode,
                                     org.mmbase.bridge.Node destinationNode,
                                     org.mmbase.bridge.Field field)
cloneNodeField copies node fields from one node to an other

Parameters:
sourceNode - the source node
destinationNode - destination node
field - the field to clone

isPublished

public static boolean isPublished(org.mmbase.bridge.Node localNode)
Test whether a node is published to one or more other clouds. From the perspective of one cloud a node is said to be published when the node number is available in the sourcenumber of the remotenodes table and the sourcecloud equals the cloud context (so if the context is staging the sourcecloud should refer the staging record in the cloud table)

Parameters:
localNode - The node to be checked
Returns:
true if the node has been published to the other cloud

isPublished

public static boolean isPublished(int localNumber,
                                  org.mmbase.bridge.Cloud localCloud)
Test whether a node is published to one or more other clouds. From the perspective of one cloud a node is said to be published when the node number is available in the sourcenumber of the remotenodes table and the sourcecloud equals the cloud context (so if the context is staging the sourcecloud should refer the staging record in the cloud table)

Parameters:
localNumber - the number of the node
localCloud - the cloud from which the node has been published
Returns:
true if the node has been published to the other cloud

isPublished

public static boolean isPublished(org.mmbase.bridge.Node localNode,
                                  org.mmbase.bridge.Cloud remoteCloud)
Test whether a node is published to another cloud. From the perspective of one cloud a node is said to be published when the node number is available in the sourcenumber of the remotenodes table and the sourcecloud equals the cloud context (so if the context is staging the sourcecloud should refer the staging record in the cloud table)

Parameters:
localNode - the node to test
remoteCloud - the cloud to which the node is published
Returns:
true if node has been published to cloud

isPublished

public static boolean isPublished(int localNumber,
                                  org.mmbase.bridge.Cloud localCloud,
                                  org.mmbase.bridge.Cloud remoteCloud)
Test whether a node is published to another cloud. From the perspective of one cloud a node is said to be published when the node number is available in the sourcenumber of the remotenodes table and the sourcecloud equals the cloud context (so if the context is staging the sourcecloud should refer the staging record in the cloud table)

Parameters:
localNumber - the node number
localCloud - the cloud from which the node was published
remoteCloud - the cloud to which the node is published
Returns:
true if node has been published to cloud

isImported

public static boolean isImported(org.mmbase.bridge.Node localNode)
From the perspective of one cloud a node is said to be imported when the node number is available in the destinationnumber of the remotenodes table and the destinationcloud equals the cloud context (so if the context is staging the destinationcloud should refer the staging record in the cloud table)

Parameters:
localNode - Node to test
Returns:
true if node was imported, false otherwise

isImported

public static boolean isImported(int localNumber,
                                 org.mmbase.bridge.Cloud localCloud)
From the perspective of one cloud a node is said to be imported when the node number is available in the destinationnumber of the remotenodes table and the destinationcloud equals the cloud context (so if the context is staging the destinationcloud should refer the staging record in the cloud table)

Parameters:
localNumber - Node to test
localCloud - the Cloud to which the node might be published
Returns:
true if node was imported, false otherwise

isImported

public static boolean isImported(org.mmbase.bridge.Node localNode,
                                 org.mmbase.bridge.Cloud remoteCloud)
Tests whether the node has been published from another cloud to this cloud

Parameters:
localNode - the node to test
remoteCloud - the Cloud from which the node might be published
Returns:
true if node was imported from cloud

isImported

public static boolean isImported(int localNumber,
                                 org.mmbase.bridge.Cloud localCloud,
                                 org.mmbase.bridge.Cloud remoteCloud)
Tests whether the node has been published from another cloud to this cloud

Parameters:
localNumber - the node to test
localCloud - the Cloud to which the node might be published
remoteCloud - the Cloud from which the node might be published
Returns:
true if node was imported from cloud

unLinkNode

public static void unLinkNode(org.mmbase.bridge.Node localNode)
Unlink node from all other nodes (means you can then edit/delete them) This method can also be used to republish the node from the remoteCloud to this localCloud if the localNode is deleted too.

Parameters:
localNode - Node from which to remove the publish info

unLinkNode

public static void unLinkNode(org.mmbase.bridge.Node sourceNode,
                              org.mmbase.bridge.Node destinationNode)
Remove the publish-info between a source node and a published version

Parameters:
sourceNode - the original node
destinationNode - the published copy

unLinkNode

public static void unLinkNode(org.mmbase.bridge.Cloud sourceCloud,
                              org.mmbase.bridge.Cloud destinationCloud,
                              int sourceNumber,
                              int destinationNumber)
Remove the publish-info between a source node and a published version

Parameters:
sourceCloud -
destinationCloud -
sourceNumber -
destinationNumber -

getPublishedNode

public static org.mmbase.bridge.Node getPublishedNode(org.mmbase.bridge.Node localNode,
                                                      org.mmbase.bridge.Cloud remoteCloud)
Get the published nodes from a remote cloud. What should be kept in mind is that a node could also have been imported from the remote cloud. The query for retrieving the 'published' node is dependent of this.

Parameters:
localNode - the node that has been published
remoteCloud - the remote cloud
Returns:
the remote node or null if not published

getPublishedNodes

public static org.mmbase.bridge.NodeList getPublishedNodes(org.mmbase.bridge.Node localNode)
Get the published nodes from all remote clouds

Parameters:
localNode - The node thas has been published
Returns:
List of all remote nodes

getPublishedNodes

public static org.mmbase.bridge.NodeList getPublishedNodes(org.mmbase.bridge.Cloud localCloud,
                                                           int localNumber)
Get the published nodes from all remote clouds

Parameters:
localCloud - The source cloud
localNumber - The node number that has been published
Returns:
List of all remote nodes

getSourceNode

public static org.mmbase.bridge.Node getSourceNode(org.mmbase.bridge.Node localNode)
Get the source node of this localNode if this localNode is imported

Parameters:
localNode - a published node
Returns:
the remoteNode from which the localNode was published or null if node was not imported

getPublishInfoNode

public static org.mmbase.bridge.Node getPublishInfoNode(org.mmbase.bridge.Cloud localCloud,
                                                        int destinationNumber,
                                                        org.mmbase.bridge.Cloud destinationCloud)
Parameters:
localCloud -
destinationNumber -
destinationCloud -
Returns:
node with published information

updatePublishedNodes

public static void updatePublishedNodes(org.mmbase.bridge.Node localNode)
                                 throws PublishException
syncronize all nodes that are published from this one

Parameters:
localNode - the source node NOTE for WEB-IN-A-BOX developers: Use of this method is NOT RECOMMENDED as it encourages inplace modifications to nodes and that allows editing of published information ** use an editNode() saveNode() combination if workflow content **
Throws:
PublishException

deletePublishedNode

public static void deletePublishedNode(org.mmbase.bridge.Node localNode)
delete the remote instances of a node(with relations and relation information)

Parameters:
localNode - the local node to remove

deletePublishedNode

public static void deletePublishedNode(org.mmbase.bridge.Cloud localCloud,
                                       int localNumber)
delete the remote instances of a node(with relations and relation information)

Parameters:
localCloud -
localNumber -


Copyright © 2003-2004 mmapps. All Rights Reserved.