org.mmbase.bridge.implementation
Class BasicCloud

java.lang.Object
  extended by org.mmbase.bridge.implementation.BasicCloud
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Cloud>, Cloud, SizeMeasurable
Direct Known Subclasses:
BasicTransaction

public class BasicCloud
extends Object
implements Cloud, Cloneable, Comparable<Cloud>, SizeMeasurable, Serializable

Basic implementation of Cloud. It wraps a.o. the core's ClusterBuilder and Typedef functionalities.

Version:
$Id: BasicCloud.java 40798 2010-02-02 14:03:58Z michiel $
Author:
Rob Vermeulen, Pierre van Rooden, Michiel Meeuwissen
See Also:
Serialized Form

Nested Class Summary
(package private)  class BasicCloud.BasicCloudStarter
           
 
Field Summary
protected  String account
           
protected  long count
           
protected  String description
           
(package private)  Locale locale
           
protected  String name
           
protected  Map<String,BasicNodeManager> nodeManagerCache
           
(package private)  HashMap<Object,Object> properties
           
protected  Map<String,BasicTransaction> transactions
           
protected  UserContext userContext
           
 
Fields inherited from interface org.mmbase.bridge.Cloud
PROP_IGNOREVALIDATION, PROP_REQUEST, PROP_RESPONSE, PROP_SESSIONNAME, PROP_XMLMODE
 
Constructor Summary
BasicCloud(String cloudName, BasicCloud cloud)
          basic constructor for descendant clouds (i.e.
BasicCloud(String name, UserContext user, BasicCloudContext cloudContext)
           
 
Method Summary
protected  void _readObject(ObjectInputStream in)
           
protected  void _writeObject(ObjectOutputStream out)
           
(package private)  int add(BasicNode node)
          Marks the given node as 'being edited'.
(package private)  void add(String currentObjectContext)
          Ignored by basic cloud.
protected  void afterCommit(BasicNode n)
          This method is called after a of a certain node.
(package private)  boolean check(Operation operation, int nodeID)
          Checks access rights.
(package private)  boolean check(Operation operation, int nodeID, int srcNodeID, int dstNodeID)
          Checks access rights.
protected  void checkAlias(String aliasName)
          Throws exception if node alias already exists
(package private)  List<MMObjectNode> checkNodes(List<MMObjectNode> in, Query query)
           
 int compareTo(Cloud o)
          Compares this cloud to the passed object.
(package private)  boolean contains(MMObjectNode node)
          Checks wether the current transaction contains the given node.
 Query createAggregatedQuery()
           
(package private)  void createAlias(BasicNode node, String aliasName)
           
 NodeList createNodeList()
          Returns a new, empty node list for this cloud
 NodeManagerList createNodeManagerList()
          Returns a new, empty node manager list for this cloud
 NodeQuery createNodeQuery()
          Create an empty NodeQuery, which can be filled, and used in NodeManager.getList(NodeQuery) or Cloud.getList(Query) (but then no 'real' node are returned).
 Query createQuery()
          Create an empty Query, which can be filled, and used in Cloud.getList(Query).
 RelationList createRelationList()
          Returns a new, empty relation list for this cloud
 RelationManagerList createRelationManagerList()
          Returns a new, empty relation manager list for this cloud
 Transaction createTransaction()
          Creates a transaction on this cloud.
 Transaction createTransaction(String name)
          Creates a transaction on this cloud with a specified name.
 BasicTransaction createTransaction(String name, boolean overwrite)
          Creates a transaction on this cloud with a specified name.
(package private)  void deleteNewNode(int temporaryNodeId, MMObjectNode node)
           
(package private)  void deleteNode(int temporaryNodeId, MMObjectNode node)
          Ignored by basic cloud.
 boolean equals(Object o)
          Compares this cloud to the passed object, and returns true if they are equal.
(package private)  String getAccount()
          The owner to use for the temporary node manager.
(package private)  BasicNodeManager getBasicNodeManager(MMObjectBuilder bul)
           
(package private)  BasicNodeManager getBasicNodeManager(String nodeManagerName)
           
 int getByteSize()
          Determines the byte-size of this object
 int getByteSize(SizeOf sizeof)
          Determines the byte-size of this object using the given SizeOf instance.
 CloudContext getCloudContext()
          Returns the context to which this cloud belongs.
protected  List<MMObjectNode> getClusterNodes(Query query)
          Result with all Cluster - MMObjectNodes, with cache.
 String getDescription()
          This may return Cloud.getName(), but in principable it could have been localized using the value also returned by Cloud.getLocale().
 Function<?> getFunction(String setName, String functionName)
          Returns a Function object from a function set.
 Collection<Function<?>> getFunctions(String setName)
          Returns all Function objects from a function set.
protected  NodeList getLastStepList(Query query)
          Based on multi-level query.
 NodeList getList(Query query)
          Executes a query and returns the result as a Cluster Node List (also if the query is a NodeQuery).
 NodeList getList(String startNodes, String nodePath, String fields, String constraints, String orderby, String directions, String searchDir, boolean distinct)
          Returns a list of virtual nodes that are composed by fields of other nodes.
 Locale getLocale()
          Gets the locale assocatied with this Cloud instance.
 String getName()
          Returns the name of this cloud.
 Node getNode(int nodeNumber)
          Returns the node with the specified number from this cloud.
 Node getNode(String nodeNumber)
          Returns the node with the specified number from this cloud.
 Node getNodeByAlias(String aliasname)
          Returns the node with the specified alias from this cloud.
 NodeManager getNodeManager(int nodeManagerId)
          Retrieves a node manager
 NodeManager getNodeManager(String nodeManagerName)
          Returns the specified node manager.
 NodeManagerList getNodeManagers()
          Returns all node managers available in this cloud.
 Cloud getNonTransactionalCloud()
          Returns a cloud which is not a Transaction.
 StringList getPossibleContexts()
          Contacts the security implementation to find out to which possible contexts are available to the current user.
 Map<Object,Object> getProperties()
          Retrieves all properties previously set for this cloud.
 Object getProperty(Object key)
          Retrieves a property previously set for this cloud.
 Relation getRelation(int nodeNumber)
          Returns the relation with the specified number from this cloud.
 Relation getRelation(String nodeNumber)
          Returns the relation with the specified number from this cloud.
 RelationManager getRelationManager(int number)
          Returns the specified relation manager.
(package private)  RelationManager getRelationManager(int sourceManagerId, int destinationManagerId, int roleId)
          Retrieves a RelationManager.
 RelationManager getRelationManager(NodeManager source, NodeManager destination, String roleName)
          Returns the specified relation manager.
 RelationManager getRelationManager(String roleName)
          Returns the specified relation manager.
 RelationManager getRelationManager(String sourceManagerName, String destinationManagerName, String roleName)
          Returns the specified relation manager.
 RelationManagerList getRelationManagers()
          Returns all relation managers available in this cloud.
 RelationManagerList getRelationManagers(NodeManager sourceManager, NodeManager destinationManager, String roleName)
          Returns all relation managers available in this cloud that follow the specified filter.
 RelationManagerList getRelationManagers(String sourceManagerName, String destinationManagerName, String roleName)
          Returns all relation managers available in this cloud that follow the specified filter.
protected  NodeList getResultNodeList(Query query)
          Aggregating query result.
protected  NodeList getSecureList(Query query)
          Result with Cluster Nodes (checked security)
 Transaction getTransaction(String name)
          Returnes the transaction with the specified name.
 UserContext getUser()
          Who is using this cloud.
 boolean hasNode(int nodeNumber)
          Determines whether a node with the specified number exists in this cloud.
 boolean hasNode(String nodeNumber)
          Determines whether a node with the specified number is available from this cloud.
 boolean hasNodeManager(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(String nodeNumber)
          Determines whether a relation with the specified number is available from this cloud.
 boolean hasRelationManager(NodeManager source, NodeManager destination, String roleName)
          Returns whether the specified relation manager exists.
 boolean hasRelationManager(String roleName)
          Returns whether the specified relation manager exists.
 boolean hasRelationManager(String sourceManagerName, String destinationManagerName, String roleName)
          Returns whether the specified relation manager exists.
 boolean hasRole(String roleName)
          Returns whether the specified role exists.
(package private) static boolean isTemporaryId(int id)
          Test if a node id is a temporay id.
(package private)  BasicNode makeNode(MMObjectNode node, String nodeNumber)
           
 boolean may(Action action, Parameters parameters)
          Check whether an action is allowed
 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(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.
protected  void processCommitProcessors(Node n)
          Calls the commit processor for every field.
protected  void processDeleteProcessors(Node n)
          Calls the delete processor for every field.
(package private)  void remove(MMObjectNode node)
          Instructs core to reomve the Node
 void setLocale(Locale l)
          Sets a locale for this Cloud instance.
 void setProperty(Object key, Object value)
          Sets a property for this cloud object.
(package private)  boolean setSecurityConstraint(Constraint c)
           
(package private)  boolean setSecurityConstraint(Query query)
           
protected  void setValue(BasicNode node, String fieldName, Object value)
           
 void shutdown()
          Shutdown MMBase, if you are allowed to do so.
protected  BasicQuery toBasicQuery(Query query)
           
 String toString()
           
(package private) static int uniqueId()
          Create unique temporary node number.
(package private)  void verify(Operation operation, int nodeID)
          Asserts access rights.
(package private)  void verify(Operation operation, int nodeID, int srcNodeID, int dstNodeID)
          Asserts access rights.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

account

protected String account

description

protected String description

transactions

protected Map<String,BasicTransaction> transactions

nodeManagerCache

protected Map<String,BasicNodeManager> nodeManagerCache

userContext

protected UserContext userContext

properties

HashMap<Object,Object> properties

locale

Locale locale

count

protected final long count
Constructor Detail

BasicCloud

BasicCloud(String cloudName,
           BasicCloud cloud)
basic constructor for descendant clouds (i.e. Transaction)

Parameters:
cloudName - name of cloud
cloud - parent cloud

BasicCloud

BasicCloud(String name,
           UserContext user,
           BasicCloudContext cloudContext)
Parameters:
name - name of cloud
authenticationType - authentication type
loginInfo - Map with login credentials
cloudContext - cloudContext of cloud
Throws:
NotFoundException - If MMBase not yet started, or shutting down.
BridgeException - No security could be obtained.
SecurityException - Could not perform login
Method Detail

getByteSize

public int getByteSize()
Description copied from interface: SizeMeasurable
Determines the byte-size of this object

Specified by:
getByteSize in interface SizeMeasurable

getByteSize

public int getByteSize(SizeOf sizeof)
Description copied from interface: SizeMeasurable
Determines 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

makeNode

BasicNode makeNode(MMObjectNode node,
                   String nodeNumber)

getNode

public Node getNode(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
Parameters:
nodeNumber - 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 final 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
Parameters:
nodeNumber - the number of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found

getNodeByAlias

public final Node getNodeByAlias(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
Parameters:
aliasname - the alias of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found

getRelation

public final 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
Parameters:
nodeNumber - the number of the requested node
Returns:
the requested node
Throws:
NotFoundException - if the specified node could not be found

getRelation

public final Relation getRelation(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
Parameters:
nodeNumber - 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

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 determine whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.

Specified by:
hasNode in interface Cloud
Parameters:
nodeNumber - the number of the node
Returns:
true if the node exists

hasNode

public boolean hasNode(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 determine whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.

Specified by:
hasNode in interface Cloud
Parameters:
nodeNumber - 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 determine whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.

Specified by:
hasRelation in interface Cloud
Parameters:
nodeNumber - the number of the node
Returns:
true if the relation exists

hasRelation

public boolean hasRelation(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 determine whether you may actually access (read) this node, use Cloud.mayRead(int) to determine this.

Specified by:
hasRelation in interface Cloud
Parameters:
nodeNumber - 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
Returns:
a NodeManagerList containing all node managers available in this cloud.

getBasicNodeManager

BasicNodeManager getBasicNodeManager(MMObjectBuilder bul)
                               throws NotFoundException
Throws:
NotFoundException
Since:
MMBase-1.8

getBasicNodeManager

BasicNodeManager getBasicNodeManager(String nodeManagerName)
                               throws NotFoundException
Throws:
NotFoundException

getNodeManager

public final NodeManager getNodeManager(String nodeManagerName)
                                 throws NotFoundException
Description copied from interface: Cloud
Returns the specified node manager.

Specified by:
getNodeManager in interface Cloud
Parameters:
nodeManagerName - 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(String nodeManagerName)
Description copied from interface: Cloud
Returns whether the specified node manager exists.

Specified by:
hasNodeManager in interface Cloud
Parameters:
nodeManagerName - 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
Throws:
NotFoundException - node manager not found

getRelationManager

RelationManager getRelationManager(int sourceManagerId,
                                   int destinationManagerId,
                                   int roleId)
Retrieves a RelationManager. Note that you can retrieve a manager with source and destination reversed.

Parameters:
sourceManagerId - number of the NodeManager of the source node
destinationManagerId - number of the NodeManager of the destination node
roleId - number of the role
Returns:
the requested RelationManager

getRelationManager

public RelationManager getRelationManager(int number)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.

Specified by:
getRelationManager in interface Cloud
Parameters:
number - Unique ID of the RelationManager to retrieve
Returns:
the requested relation manager
Throws:
NotFoundException - if the specified relation manager could not be found

getRelationManager

public RelationManager getRelationManager(String roleName)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.

Specified by:
getRelationManager in interface 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()
Description copied from interface: Cloud
Returns all relation managers available in this cloud.

Specified by:
getRelationManagers in interface Cloud
Returns:
a RelationManagerList containing all relation managers available in this cloud

getRelationManager

public RelationManager getRelationManager(String sourceManagerName,
                                          String destinationManagerName,
                                          String roleName)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.

Specified by:
getRelationManager in interface 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

getRelationManager

public RelationManager getRelationManager(NodeManager source,
                                          NodeManager destination,
                                          String roleName)
                                   throws NotFoundException
Description copied from interface: Cloud
Returns the specified relation manager.

Specified by:
getRelationManager in interface Cloud
Parameters:
source - the node manager of the source node
destination - 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(String sourceManagerName,
                                  String destinationManagerName,
                                  String roleName)
Description copied from interface: Cloud
Returns whether the specified relation manager exists.

Specified by:
hasRelationManager in interface 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 be found

hasRole

public boolean hasRole(String roleName)
Description copied from interface: Cloud
Returns whether the specified role exists.

Specified by:
hasRole in interface Cloud
Parameters:
roleName - name of the role
Returns:
true if the specified role could be found

hasRelationManager

public boolean hasRelationManager(NodeManager source,
                                  NodeManager destination,
                                  String roleName)
Description copied from interface: Cloud
Returns whether the specified relation manager exists.

Specified by:
hasRelationManager in interface Cloud
Parameters:
source - name of the node manager of the source node
destination - name of the node manager of the destination node
roleName - name of the role
Returns:
true if the specified relation manager could be found

getRelationManagers

public RelationManagerList getRelationManagers(String sourceManagerName,
                                               String destinationManagerName,
                                               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
Parameters:
sourceManagerName - the name of the manager for the source of the relation
destinationManagerName - the name of the manager for the destination of the relation
roleName - the rolename
Returns:
a RelationManagerList containing all relation managers that follow this 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,
                                               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
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(String roleName)
Description copied from interface: Cloud
Returns whether the specified relation manager exists.

Specified by:
hasRelationManager in interface Cloud
Parameters:
roleName - name of the role
Returns:
true if the specified relation manager exists

uniqueId

static int uniqueId()
Create unique temporary node number. The Id starts at - 2 and is decremented each time a new id is asked until Integer.MINVALUE is reached (after which counting starts again at -2).

Returns:
the temporary id as an integer
To Do:
This may be a temporary solution. It may be desirable to immediately reserve a number at the database layer, so resolving (by the transaction) will not be needed. However, this needs some changes in the TemporaryNodeManager and the classes that make use of this.

isTemporaryId

static boolean isTemporaryId(int id)
Test if a node id is a temporay id.

Parameters:
id - the id (node numebr) to test
Returns:
true if the id is a temporary id
Since:
MMBase-1.5

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
Returns:
a Transaction on this cloud

createTransaction

public Transaction createTransaction(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
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 BasicTransaction createTransaction(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
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(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
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
Returns:
a CloudContext to which this cloud belongs

getName

public String getName()
Description copied from interface: Cloud
Returns the name of this cloud. The name of the cloud is the string "mmbase" unless this Cloud is a Transaction.

Specified by:
getName in interface Cloud
Returns:
the name of this cloud

getDescription

public String getDescription()
Description copied from interface: Cloud
This may return Cloud.getName(), but in principable it could have been localized using the value also returned by Cloud.getLocale().

Specified by:
getDescription in interface Cloud
Returns:
the description of this cloud

getUser

public UserContext getUser()
Description copied from interface: Cloud
Who is using this cloud.

Specified by:
getUser in interface Cloud
Returns:
the User object describing who is using this cloud now.

getAccount

String getAccount()
The owner to use for the temporary node manager.

Returns:
the account name

check

boolean check(Operation operation,
              int nodeID)
Checks access rights.

Parameters:
operation - the operation to check (READ, WRITE, CREATE, OWN)
nodeID - the node on which to check the operation
Returns:
true if access is granted, false otherwise

verify

void verify(Operation operation,
            int nodeID)
Asserts access rights. throws an exception if an operation is not allowed.

Parameters:
operation - the operation to check (READ, WRITE, CREATE, OWN)
nodeID - the node on which to check the operation

check

boolean check(Operation operation,
              int nodeID,
              int srcNodeID,
              int dstNodeID)
Checks access rights.

Parameters:
operation - the operation to check (CREATE, CHANGE_RELATION)
nodeID - the node on which to check the operation
srcNodeID - the source node for this relation
dstNodeID - the destination node for this relation
Returns:
true if access is granted, false otherwise

verify

void verify(Operation operation,
            int nodeID,
            int srcNodeID,
            int dstNodeID)
Asserts access rights. throws an exception if an operation is not allowed.

Parameters:
operation - the operation to check (CREATE, CHANGE_RELATION)
nodeID - the node on which to check the operation
srcNodeID - the source node for this relation
dstNodeID - the destination node for this relation

getList

public NodeList getList(Query query)
Description copied from interface: Cloud
Executes a query and returns the result as a Cluster Node List (also if the query is a NodeQuery).

Specified by:
getList in interface Cloud
Parameters:
query - Query to execute
Returns:
Cluster Node List
See Also:
SearchQuery

getResultNodeList

protected NodeList getResultNodeList(Query query)
Aggregating query result.

Parameters:
query - query to execute
Returns:
list of nodes
Since:
MMBase-1.7

getClusterNodes

protected List<MMObjectNode> getClusterNodes(Query query)
Result with all Cluster - MMObjectNodes, with cache. Security is not considered here (the query is executed thoughtlessly). The security check is done in getSecureNodes, which calls this one.

Parameters:
query - query to execute
Returns:
list of cluster nodes
Since:
MMBase-1.7

setSecurityConstraint

boolean setSecurityConstraint(Constraint c)
Since:
MMBase-1.9.1

toBasicQuery

protected BasicQuery toBasicQuery(Query query)
Since:
MMBase-1.9.2

setSecurityConstraint

boolean setSecurityConstraint(Query query)
Parameters:
query - add security constaint to this query
Returns:
is query secure
Since:
MMBase-1.7

getPossibleContexts

public StringList getPossibleContexts()
Description copied from interface: Cloud
Contacts the security implementation to find out to which possible contexts are available to the current user.

Specified by:
getPossibleContexts in interface Cloud
Returns:
A StringList containing the contexts which can be used by teh suer

checkNodes

List<MMObjectNode> checkNodes(List<MMObjectNode> in,
                              Query query)

getSecureList

protected NodeList getSecureList(Query query)
Result with Cluster Nodes (checked security)

Parameters:
query - query to execute
Returns:
lisr of cluster nodes
Since:
MMBase-1.7

getList

public NodeList getList(String startNodes,
                        String nodePath,
                        String fields,
                        String constraints,
                        String orderby,
                        String directions,
                        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
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 separated 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 - Constraints to prevent nodes from being included in the resulting list which would normally by included or null if no constraints 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(Locale l)
Description copied from interface: Cloud
Sets a locale for this Cloud instance.

Specified by:
setLocale in interface Cloud
Parameters:
l - To which locale it must be set. It can be null, in which case it will be reset to a default.

getLocale

public Locale getLocale()
Description copied from interface: Cloud
Gets the locale assocatied with this Cloud instance.

Specified by:
getLocale in interface Cloud
Returns:
Locale of this Cloud instance

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
Parameters:
nodeNumber - the number of the requested node
Returns:
true if the node is accessible

mayRead

public boolean mayRead(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
Parameters:
nodeNumber - a string containing the number or alias of the requested node
Returns:
true if the node is accessible

may

public boolean may(Action action,
                   Parameters parameters)
Description copied from interface: Cloud
Check whether an action is allowed

Specified by:
may in interface Cloud
Parameters:
action - Action to perform
parameters - parameters passed into this action
Returns:
true when allowed

createQuery

public Query createQuery()
Description copied from interface: Cloud
Create an empty Query, which can be filled, and used in Cloud.getList(Query).

Specified by:
createQuery in interface Cloud
Returns:
empty Query

createNodeQuery

public NodeQuery createNodeQuery()
Description copied from interface: Cloud
Create an empty NodeQuery, which can be filled, and used in NodeManager.getList(NodeQuery) or Cloud.getList(Query) (but then no 'real' node are returned). The query can be used on NodeManager only when at least one step is added, and NodeQuery.setNodeStep(org.mmbase.storage.search.Step) is called.

Specified by:
createNodeQuery in interface Cloud
Returns:
empty NodeQuery

createAggregatedQuery

public Query createAggregatedQuery()
Specified by:
createAggregatedQuery in interface Cloud

getLastStepList

protected NodeList getLastStepList(Query query)
Based on multi-level query. Returns however 'normal' nodes based on the last step. This is a protected function, which is used in the implemetnedion of getRelatedNodes, getRelations of NodeManager Before it executes the query, the fields of the query are checked. All and only fields of the 'last' NodeManager and the relation should be queried. If fields are present already, but not like this, an exception is thrown. If not fields are present, the rights fields are added first (if the query is still unused, otherwise trhows Exception).

Parameters:
query - query to execute
Returns:
list of normal nodes
Throws:
BridgeException - If wrong fields in query or could not be added.
Since:
MMBase-1.7

compareTo

public int compareTo(Cloud o)
Compares this cloud to the passed object.

Specified by:
compareTo in interface Comparable<Cloud>
Parameters:
o - the object to compare it with

equals

public boolean equals(Object o)
Compares this cloud to the passed object, and returns true if they are equal. Two clouds are equal, if the have the same cloud context, and the same user.

Overrides:
equals in class Object
Parameters:
o - the object to compare it with
Returns:
is equal

getProperty

public Object getProperty(Object key)
Description copied from interface: Cloud
Retrieves a property previously set for this cloud. If this Cloud has a 'parent' cloud (ie. this Cloud is a Transaction), then this will also mirror properties in this parent cloud.

Specified by:
getProperty in interface Cloud
Parameters:
key - the key of the property
Returns:
the property value
See Also:
Cloud.setProperty(Object, Object)

setProperty

public void setProperty(Object key,
                        Object value)
Description copied from interface: Cloud
Sets a property for this cloud object. This can be used as a kind of 'environment' variables.

Specified by:
setProperty in interface Cloud
Parameters:
key - the key of the property
value - the property value

getProperties

public Map<Object,Object> getProperties()
Description copied from interface: Cloud
Retrieves all properties previously set for this cloud.

Specified by:
getProperties in interface Cloud
Returns:
all properties

getFunctions

public Collection<Function<?>> getFunctions(String setName)
Description copied from interface: Cloud
Returns all Function objects from a function set. Function sets group functions by name, and are configured in the functionset.xml configuration file. In each entry in the returned map, the key is the function name, and the value is a Function object.

Specified by:
getFunctions in interface Cloud
Parameters:
setName - name of the function set
Returns:
a Set of Function objects.

getFunction

public Function<?> getFunction(String setName,
                               String functionName)
Description copied from interface: Cloud
Returns a Function object from a function set. Function sets group functions by name, and are configured in the functionset.xml configuration file. The object returned is a Function object.

Specified by:
getFunction in interface Cloud
Parameters:
setName - name of the function set
functionName - name of the function
Returns:
a Function object.

createNodeList

public NodeList createNodeList()
Description copied from interface: Cloud
Returns a new, empty node list for this cloud

Specified by:
createNodeList in interface Cloud
Returns:
The empty list

createRelationList

public RelationList createRelationList()
Description copied from interface: Cloud
Returns a new, empty relation list for this cloud

Specified by:
createRelationList in interface Cloud
Returns:
The empty list

createNodeManagerList

public NodeManagerList createNodeManagerList()
Description copied from interface: Cloud
Returns a new, empty node manager list for this cloud

Specified by:
createNodeManagerList in interface Cloud
Returns:
The empty list

createRelationManagerList

public RelationManagerList createRelationManagerList()
Description copied from interface: Cloud
Returns a new, empty relation manager list for this cloud

Specified by:
createRelationManagerList in interface Cloud
Returns:
The empty list

contains

boolean contains(MMObjectNode node)
Checks wether the current transaction contains the given node.


add

void add(String currentObjectContext)
Ignored by basic cloud. See BasicTransaction.add(String).


add

int add(BasicNode node)
Marks the given node as 'being edited'. This means that a copy must be made which is going to contain the changes until the node (or the transaction) is committed.


checkAlias

protected void checkAlias(String aliasName)
Throws exception if node alias already exists

Since:
MMBase-1.8.4

createAlias

void createAlias(BasicNode node,
                 String aliasName)

remove

final void remove(MMObjectNode node)
Instructs core to reomve the Node


deleteNewNode

void deleteNewNode(int temporaryNodeId,
                   MMObjectNode node)

deleteNode

void deleteNode(int temporaryNodeId,
                MMObjectNode node)
Ignored by basic cloud. See BasicTransaction.delete(String).


_readObject

protected void _readObject(ObjectInputStream in)
                    throws IOException,
                           ClassNotFoundException
Throws:
IOException
ClassNotFoundException

_writeObject

protected void _writeObject(ObjectOutputStream out)
                     throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getNonTransactionalCloud

public Cloud getNonTransactionalCloud()
Description copied from interface: Cloud
Returns a cloud which is not a Transaction.

Specified by:
getNonTransactionalCloud in interface Cloud
Returns:
This cloud or a parent cloud if this cloud is a Transaction

shutdown

public void shutdown()
Description copied from interface: Cloud
Shutdown MMBase, if you are allowed to do so.

Specified by:
shutdown in interface Cloud

processDeleteProcessors

protected void processDeleteProcessors(Node n)
Calls the delete processor for every field.

Since:
MMBase-1.9.1

processCommitProcessors

protected void processCommitProcessors(Node n)
Calls the commit processor for every field.

Since:
MMBase-1.9.1

setValue

protected void setValue(BasicNode node,
                        String fieldName,
                        Object value)

afterCommit

protected void afterCommit(BasicNode n)
This method is called after a of a certain node. If we are not in a transaction this performing the actual commit procedure (using the temporary object manager), and calls Object.notifyAll(). This last thing makes it easy to wait for a node to really exist (finished committing)
                synchronized(ntCloud) {
                    while (! ntCloud.hasNode(node)) {
                        ntCloud.wait();
                    }
                }
     
Committing in a transaction goes a bit different, because the actual committing only happens in the , this method will be mostly empty for BasicTransaction.

Since:
MMBase-1.9.2


MMBase 2.0-SNAPSHOT - null