org.mmbase.bridge.implementation
Class BasicCloud

java.lang.Object
  |
  +--org.mmbase.bridge.implementation.BasicCloud
All Implemented Interfaces:
java.lang.Cloneable, Cloud, java.lang.Comparable, SizeMeasurable
Direct Known Subclasses:
BasicTransaction

public class BasicCloud
extends java.lang.Object
implements Cloud, java.lang.Cloneable, java.lang.Comparable, SizeMeasurable

Version:
$Id: BasicCloud.java,v 1.76.2.10 2003/07/11 13:06:29 pierre Exp $
Author:
Rob Vermeulen, Pierre van Rooden

Field Summary
protected  java.lang.String account
           
protected  java.lang.String description
           
protected  java.lang.String name
           
protected  java.util.Map nodeManagerCache
           
protected  BasicCloud parentCloud
           
protected  java.util.Map transactions
           
protected  BasicUser userContext
           
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this cloud to the passed object.
 Transaction createTransaction()
          Creates a transaction on this cloud.
 Transaction createTransaction(java.lang.String name)
          Creates a transaction on this cloud with a specified name.
 Transaction createTransaction(java.lang.String name, boolean overwrite)
          Creates a transaction on this cloud with a specified name.
 boolean equals(java.lang.Object o)
          Compares this cloud to the passed object, and returns true if they are equal.
 int getByteSize()
          Determins the byte-size of this object
 int getByteSize(SizeOf sizeof)
          Determins the byte-size of this object using the given SizeOf instance.
 CloudContext getCloudContext()
          Returns the context to which this cloud belongs.
 java.lang.String getDescription()
          Returns the description of the cloud.
 NodeList getList(java.lang.String startNodes, java.lang.String nodePath, java.lang.String fields, java.lang.String constraints, java.lang.String orderby, java.lang.String directions, java.lang.String searchDir, boolean distinct)
          Returns a list of virtual nodes that are composed by fields of other nodes.
 java.util.Locale getLocale()
          Gets the Locale assocatied with this Cloud instance.
 java.lang.String getName()
          Returns the name of this cloud.
 Node getNode(int nodenumber)
          Returns the node with the specified number from this cloud.
 Node getNode(java.lang.String nodenumber)
          Returns the node with the specified number from this cloud.
 Node getNodeByAlias(java.lang.String aliasname)
          Returns the node with the specified alias from this cloud.
 NodeManager getNodeManager(int nodeManagerId)
          Retrieves a node manager
 NodeManager getNodeManager(java.lang.String nodeManagerName)
          Returns the specified node manager.
 NodeManagerList getNodeManagers()
          Returns all node managers available in this cloud.
 Relation getRelation(int nodenumber)
          Returns the relation with the specified number from this cloud.
 Relation getRelation(java.lang.String nodenumber)
          Returns the relation with the specified number from this cloud.
 RelationManager getRelationManager(int number)
          Returns the specified relation manager.
 RelationManager getRelationManager(java.lang.String roleName)
          Returns the specified relation manager.
 RelationManager getRelationManager(java.lang.String sourceManagerName, java.lang.String destinationManagerName, java.lang.String roleName)
          Returns the specified relation manager.
 RelationManagerList getRelationManagers()
          Returns all relation managers available in this cloud.
 RelationManagerList getRelationManagers(NodeManager sourceManager, NodeManager destinationManager, java.lang.String roleName)
          Returns all relation managers available in this cloud that follow the specified filter.
 RelationManagerList getRelationManagers(java.lang.String sourceManagerName, java.lang.String destinationManagerName, java.lang.String roleName)
          Returns all relation managers available in this cloud that follow the specified filter.
 Transaction getTransaction(java.lang.String name)
          Returnes the transaction with the specified name.
 User getUser()
          Who is using this cloud.
 boolean hasNode(int nodenumber)
          Determines whether a node with the specified number exists in this cloud.
 boolean hasNode(java.lang.String nodenumber)
          Determines whether a node with the specified number is available from this cloud.
 boolean hasNodeManager(java.lang.String nodeManagerName)
          Returns whether the specified node manager exists.
 boolean hasRelation(int nodenumber)
          Determines whether a relation with the specified number exists in this cloud.
 boolean hasRelation(java.lang.String nodenumber)
          Determines whether a relation with the specified number is available from this cloud.
 boolean hasRelationManager(java.lang.String roleName)
          Returns whether the specified relation manager exists.
 boolean hasRelationManager(java.lang.String sourceManagerName, java.lang.String destinationManagerName, java.lang.String roleName)
          Returns whether the specified relation manager exists.
 boolean mayRead(int nodenumber)
          Determines whether a node with the specified number is accessible for the user - that is, the user has sufficient rights to read the node.
 boolean mayRead(java.lang.String nodenumber)
          Determines whether a node with the specified number is accessible for the user - that is, the user has sufficient rights to read the node.
 void setLocale(java.util.Locale l)
          Sets a locale for this Cloud instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

account

protected java.lang.String account

description

protected java.lang.String description

transactions

protected java.util.Map transactions

nodeManagerCache

protected java.util.Map nodeManagerCache

parentCloud

protected BasicCloud parentCloud

userContext

protected BasicUser userContext
Method Detail

getByteSize

public int getByteSize()
Description copied from interface: SizeMeasurable
Determins the byte-size of this object
Specified by:
getByteSize in interface SizeMeasurable

getByteSize

public int getByteSize(SizeOf sizeof)
Description copied from interface: SizeMeasurable
Determins the byte-size of this object using the given SizeOf instance. A SizeOf instance stores a Set already counted objects. So this method is typically called by SizeOf itself (recursion).
Specified by:
getByteSize in interface SizeMeasurable

getNode

public Node getNode(java.lang.String nodenumber)
             throws NotFoundException
Description copied from interface: Cloud
Returns the node with the specified number from this cloud. If the string passed is not a number, the string is assumed to be an alias. The returned node is a new instance of Node with a reference to this instance of Cloud.
Specified by:
getNode in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - a string containing the number or alias of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found

getNode

public Node getNode(int nodenumber)
             throws NotFoundException
Description copied from interface: Cloud
Returns the node with the specified number from this cloud. The returned node is a new instance of Node with a reference to this instance of Cloud.
Specified by:
getNode in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - the number of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found

getNodeByAlias

public Node getNodeByAlias(java.lang.String aliasname)
                    throws NotFoundException
Description copied from interface: Cloud
Returns the node with the specified alias from this cloud. The returned node is a new instance of Node with a reference to this instance of Cloud.
Specified by:
getNodeByAlias in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
alias - the alias of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found

getRelation

public Relation getRelation(int nodenumber)
                     throws NotFoundException
Description copied from interface: Cloud
Returns the relation with the specified number from this cloud. The returned node is a new instance of Relation with a reference to this instance of Cloud.
Specified by:
getRelation in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - the number of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found
java.lang.ClassCastException - if the specified node is not a relation

getRelation

public Relation getRelation(java.lang.String nodenumber)
                     throws NotFoundException
Description copied from interface: Cloud
Returns the relation with the specified number from this cloud. If the string passed is not a number, the string is assumed to be an alias. The returned node is a new instance of Relation with a reference to this instance of Cloud.
Specified by:
getRelation in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - a string containing the number or alias of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found
java.lang.ClassCastException - if the specified node is not a relation

hasNode

public boolean hasNode(int nodenumber)
Description copied from interface: Cloud
Determines whether a node with the specified number exists in this cloud. Note that this method does not determien whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.
Specified by:
hasNode in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - the number of the node
Returns:
true if the node exists

hasNode

public boolean hasNode(java.lang.String nodenumber)
Description copied from interface: Cloud
Determines whether a node with the specified number is available from this cloud. If the string passed is not a number, the string is assumed to be an alias. Note that this method does not determien whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.
Specified by:
hasNode in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - a string containing the number or alias of the requested node
Returns:
true if the node exists

hasRelation

public boolean hasRelation(int nodenumber)
Description copied from interface: Cloud
Determines whether a relation with the specified number exists in this cloud. The node returns true if a Node exists and is a relation. Note that this method does not determien whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.
Specified by:
hasRelation in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - the number of the node
Returns:
true if the relation exists

hasRelation

public boolean hasRelation(java.lang.String nodenumber)
Description copied from interface: Cloud
Determines whether a relation with the specified number is available from this cloud. If the string passed is not a number, the string is assumed to be an alias. The node returns true if a Node exists and is a relation. Note that this method does not determien whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.
Specified by:
hasRelation in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - a string containing the number or alias of the requested node
Returns:
true if the relation exists

getNodeManagers

public NodeManagerList getNodeManagers()
Description copied from interface: Cloud
Returns all node managers available in this cloud.
Specified by:
getNodeManagers in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
a NodeManagerList containing all node managers available in this cloud.

getNodeManager

public NodeManager getNodeManager(java.lang.String nodeManagerName)
                           throws NotFoundException
Description copied from interface: Cloud
Returns the specified node manager.
Specified by:
getNodeManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
name - the name of the requested node manager
Returns:
the requested node manager
Throws:
NotFoundException - if the specified node manager could not be found

hasNodeManager

public boolean hasNodeManager(java.lang.String nodeManagerName)
Description copied from interface: Cloud
Returns whether the specified node manager exists.
Specified by:
hasNodeManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
name - the name of the requested node manager
Returns:
true if the specified node manager exists

getNodeManager

public NodeManager getNodeManager(int nodeManagerId)
                           throws NotFoundException
Retrieves a node manager
Specified by:
getNodeManager in interface Cloud
Parameters:
nodeManagerId - ID of the NodeManager to retrieve
Returns:
the requested NodeManager if the manager exists, null otherwise

getRelationManager

public RelationManager getRelationManager(int number)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.
Specified by:
getRelationManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
nodeManagerId - Unique ID of the RelationManager to retrieve
Returns:
the requested relation manager
Throws:
NotFoundException - if the specified relation manager could not be found

getRelationManagers

public RelationManagerList getRelationManagers()
Description copied from interface: Cloud
Returns all relation managers available in this cloud.
Specified by:
getRelationManagers in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
a RelationManagerList containing all relation managers available in this cloud

getRelationManager

public RelationManager getRelationManager(java.lang.String sourceManagerName,
                                          java.lang.String destinationManagerName,
                                          java.lang.String roleName)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.
Specified by:
getRelationManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
sourceManagerName - name of the node manager of the source node
destinationManagerName - name of the node manager of the destination node
roleName - name of the role
Returns:
the requested relation manager
Throws:
NotFoundException - if the specified relation manager could not be found

hasRelationManager

public boolean hasRelationManager(java.lang.String sourceManagerName,
                                  java.lang.String destinationManagerName,
                                  java.lang.String roleName)
Description copied from interface: Cloud
Returns whether the specified relation manager exists.
Specified by:
hasRelationManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
sourceManagerName - name of the node manager of the source node
destinationManagerName - name of the node manager of the destination node
roleName - name of the role
Returns:
true if the specified relation manager could not be found

getRelationManager

public RelationManager getRelationManager(java.lang.String roleName)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.
Specified by:
getRelationManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
roleName - name of the role
Returns:
the requested relation manager
Throws:
NotFoundException - if the specified relation manager could not be found

getRelationManagers

public RelationManagerList getRelationManagers(java.lang.String sourceManagerName,
                                               java.lang.String destinationManagerName,
                                               java.lang.String roleName)
                                        throws NotFoundException
Description copied from interface: Cloud
Returns all relation managers available in this cloud that follow the specified filter.
Specified by:
getRelationManagers in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
sourceManagerName - the name of the manager for the source of the relation
destinationManagerMame - the name of the manager for the destination of the relation
roleName - the rolename
Returns:
a RelationManagerList containing all relation managers that follwo thsi filter
Throws:
NotFoundException - if one of the specified relation managers or the rolename could not be found

getRelationManagers

public RelationManagerList getRelationManagers(NodeManager sourceManager,
                                               NodeManager destinationManager,
                                               java.lang.String roleName)
                                        throws NotFoundException
Description copied from interface: Cloud
Returns all relation managers available in this cloud that follow the specified filter.
Specified by:
getRelationManagers in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
sourceManager - the manager for the source of the relation
destinationManager - the manager for the destination of the relation
roleName - the rolename
Returns:
a RelationManagerList containing all relation managers that follwo thsi filter
Throws:
NotFoundException - if one of the specified relation managers or the rolename could not be found

hasRelationManager

public boolean hasRelationManager(java.lang.String roleName)
Description copied from interface: Cloud
Returns whether the specified relation manager exists.
Specified by:
hasRelationManager in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
roleName - name of the role
Returns:
true if the specified relation manager exists

createTransaction

public Transaction createTransaction()
Description copied from interface: Cloud
Creates a transaction on this cloud. The returned Transaction will have a generic ID.
Specified by:
createTransaction in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
a Transaction on this cloud

createTransaction

public Transaction createTransaction(java.lang.String name)
                              throws AlreadyExistsException
Description copied from interface: Cloud
Creates a transaction on this cloud with a specified name.
Specified by:
createTransaction in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
name - an unique name to use for the transaction
Returns:
a Transaction on this cloud
Throws:
AlreadyExistsException - if a transaction with the specified name allready exists

createTransaction

public Transaction createTransaction(java.lang.String name,
                                     boolean overwrite)
                              throws AlreadyExistsException
Description copied from interface: Cloud
Creates a transaction on this cloud with a specified name.
Specified by:
createTransaction in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
name - an unique name to use for the transaction
overwrite - if true, cancels and replaces any existing transaction of this name for the current user
Returns:
a Transaction on this cloud
Throws:
AlreadyExistsException - if a transaction with the specified name allready exists and overwrite is false

getTransaction

public Transaction getTransaction(java.lang.String name)
Description copied from interface: Cloud
Returnes the transaction with the specified name. If no active transaction exists, a new transaction is created.
Specified by:
getTransaction in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
name - the name of the requested transaction
Returns:
the requested transaction

getCloudContext

public CloudContext getCloudContext()
Description copied from interface: Cloud
Returns the context to which this cloud belongs.
Specified by:
getCloudContext in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
a CloudContext to which this cloud belongs

getName

public java.lang.String getName()
Description copied from interface: Cloud
Returns the name of this cloud.
Specified by:
getName in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
the name of this cloud

getDescription

public java.lang.String getDescription()
Description copied from interface: Cloud
Returns the description of the cloud.
Specified by:
getDescription in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
the description of this cloud

getUser

public User getUser()
Description copied from interface: Cloud
Who is using this cloud.
Specified by:
getUser in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Returns:
the User object describing who is using this cloud now.

getList

public NodeList getList(java.lang.String startNodes,
                        java.lang.String nodePath,
                        java.lang.String fields,
                        java.lang.String constraints,
                        java.lang.String orderby,
                        java.lang.String directions,
                        java.lang.String searchDir,
                        boolean distinct)
Description copied from interface: Cloud
Returns a list of virtual nodes that are composed by fields of other nodes. Starting at one or more specified nodes traversals are made according to a specified path. One traversal makes up one virtual node. All possible traversals that can be made starting at one or more nodes of the same type and following a specified path are stored in the returned list. Suppose we have defined the following:
 - A node manager recordcompany containing a field name.
 - A node manager artist containing a field name.
 - A node manager url containing a field description and url.
 - A relation type related between recordcompany and artist.
 - A relation type related between artist and url.
 - A relation type homepagerel between artist and url.
 
If node 100 has a node manager called recordcompany we can do the following to get a list of the record company's artists and all urls belonging to these artist (including nodes found through the related relation and the homepagerel relation):
 getList("100", "recordcompany,artist,url",
         "artist.name,description,url", null, null, null, null, true);
 
This call returns a list of virtual nodes with the fields artist.name, description and url for every valid traversal.

If we only want to list homepage urls of the artists we do:

 getList("100", "recordcompany,artist,url",
         "artist.name,description,homepagerel,url", null, null, null,
         null, true);
 

If we want to list all url's except the the homepage urls we do:

 getList("100", "recordcompany,artist,url",
         "artist.name,description,related,url", null, null, null, null, true);
 

If node 200 also has a node manager with name recordcompany we can get the info from their artist together with the info of the artist from the first company by also putting number 200 in the first parameter:

 getList("100,200", "recordcompany,artist,url",
         "artist.name,description,related,url", null, null, null, null, true);
 
For more information about the constraints parameter consult NodeManager.getList(String constraints, String orderby, String directions).
Specified by:
getList in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
startNodes - A comma separated list of node numbers that should be used as a starting point for all traversals or null if all nodes of the first node manager in nodePath should be used.
nodePath - A comma seperated list of node manager names which specifies the path that should be followed. It is possible to explicitly specify a relation manager that should be used to go from one node to an other. If no relation manager is specified between two nodes, all possible relation managers that can be used to go to the next specified node in the path are followed.
fields - A comma separated list of field names that will make up the returned virtual nodes. A fieldname can be prefixed with the original node manager name of the field and a dot in cases where more than one node manager in the path has a field with the same name.
constraints - Contraints to prevent nodes from being included in the resulting list which would normally by included or null if no contraints should be applied.
orderby - A comma separated list of field names on which the returned list should be sorted or null if the order of the returned virtual nodes doesn't matter.
directions - A comma separated list of values indicating wether to sort up (ascending) or down (descending) on the corresponding field in the orderby parameter or null if sorting on all fields should be up. The value DOWN (case insensitive) indicates that sorting on the corresponding field should be down, all other values (including the empty value) indicate that sorting on the corresponding field should be up. If the number of values found in this parameter are less than the number of fields in the orderby parameter, all fields that don't have a corresponding direction value are sorted according to the last specified direction value.
searchDir - Determines how directionality affects the search. This is a string with the following possible values:
"both", which is the default, searches for all valid relations through a path, checking full directionality of relations where appropriate. "destination" searches for only those relations in a path where valid relations exist from source to destination, in the order of the nodemanagers given in the nodePath. "source" searches for only those relations in a path where valid relations exist from destination to source, in the order of the nodemanagers given in the nodePath. "all" searches all existing relations, and does not check on directionality. A value of null or any other values than those listed above are ignored. In that case, search is treated as if the default ("both") was specified.
distinct - true if nodes who allready exist in the list should not be added to the list. false if all nodes should be added to the list even if a node with exactly the same field values is allready present.
Returns:
a list of virtual nodes

setLocale

public void setLocale(java.util.Locale l)
Description copied from interface: Cloud
Sets a locale for this Cloud instance.
Specified by:
setLocale in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
locale - To which locale it must be set. It can be null, in which case it will be reset to a default.

getLocale

public java.util.Locale getLocale()
Description copied from interface: Cloud
Gets the Locale assocatied with this Cloud instance.
Specified by:
getLocale in interface Cloud

mayRead

public boolean mayRead(int nodenumber)
Description copied from interface: Cloud
Determines whether a node with the specified number is accessible for the user - that is, the user has sufficient rights to read the node. The node must exist - the method throws an exception if it doesn't.
Specified by:
mayRead in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - the number of the requested node
Returns:
true if the node is accessible
Throws:
NotFoundException - if the specified node could not be found

mayRead

public boolean mayRead(java.lang.String nodenumber)
Description copied from interface: Cloud
Determines whether a node with the specified number is accessible for the user - that is, the user has sufficient rights to read the node. If the string passed is not a number, the string is assumed to be an alias. The node must exist - the method throws an exception if it doesn't.
Specified by:
mayRead in interface Cloud
Following copied from interface: org.mmbase.bridge.Cloud
Parameters:
number - a string containing the number or alias of the requested node
Returns:
true if the node is accessible
Throws:
NotFoundException - if the specified node could not be found

compareTo

public int compareTo(java.lang.Object o)
Compares this cloud to the passed object. Returns 0 if they are equal, -1 if the object passed is a Cloud and larger than this cloud, and +1 if the object passed is a Cloud and smaller than this cloud.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object to compare it with

equals

public boolean equals(java.lang.Object o)
Compares this cloud to the passed object, and returns true if they are equal.
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare it with


MMBase build 1.6.5.20030923