org.openanzo.server.repository.update
Class ServerWriter

java.lang.Object
  extended by org.openanzo.server.repository.update.ServerWriter
All Implemented Interfaces:
IRepositoryHandler

public class ServerWriter
extends java.lang.Object
implements IRepositoryHandler

Implementation of IBocaHandler that handles writing updates from the server into an OutputStream that is sent to the client

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
ServerWriter(RepositoryConnection repositoryConnection, java.io.OutputStream out)
          Create a new ServerWriter
ServerWriter(RepositoryConnection repositoryConnection, java.io.OutputStream out, java.util.HashMap<java.lang.Long,org.openrdf.model.Value> visitedUris)
          Create a new ServerWriter
 
Method Summary
 org.openrdf.model.Value getNode(java.lang.Long id)
          Get the URI for a given ID
 boolean handleAci(boolean addition, java.lang.Long namedGraph, java.lang.Long acl, java.lang.Long role, java.lang.Boolean canRead, java.lang.Boolean canAdd, java.lang.Boolean canRemove, java.lang.Boolean canInsertNamedGraph, java.lang.Boolean canRemoveNamedGraph, java.lang.Boolean canChangeAcl)
          Handle ACI message
 boolean handleAci(boolean addition, org.openrdf.model.URI namedGraph, org.openrdf.model.URI acl, org.openrdf.model.URI role, java.lang.Boolean canRead, java.lang.Boolean canAdd, java.lang.Boolean canRemove, java.lang.Boolean canInsertNamedGraph, java.lang.Boolean canRemoveNamedGraph, java.lang.Boolean canChangeAcl)
          Handle ACI message
 boolean handleAcl(boolean addition, java.lang.Long acl, boolean isTemplate)
          Handle ACL message
 boolean handleAcl(boolean addition, org.openrdf.model.URI acl, boolean isTemplate)
          Handle ACL message
 boolean handleCommandEnd()
          Handle end of command message
 boolean handleCommandStart(java.lang.Long commandId, java.lang.String commandType, java.lang.String commadPreReq)
          Handle start of command message
 boolean handleEndDocument()
          Handle end of document message
 boolean handleError(int errorNumber, int errorSubNumber, java.lang.String... errorMessageArgs)
          Handle an error message
 boolean handleNamedGraph(boolean addition, java.lang.Long graph, java.lang.Long metaGraph, java.lang.Long revision, java.lang.Long aclTemplate, java.lang.Long createdBy, java.lang.Long modified, java.lang.Long lastModifiedBy)
          Handle NamedGraph message
 boolean handleNamedGraph(boolean addition, org.openrdf.model.URI graph, org.openrdf.model.URI metaGraph, java.lang.Long revision, org.openrdf.model.URI aclTemplate, org.openrdf.model.URI createdBy, java.lang.Long modified, org.openrdf.model.URI lastModifiedBy)
          Handle NamedGraph message
 boolean handleNode(java.lang.Long id, org.openrdf.model.Value node)
          Handle Node message
 boolean handleReset()
          Handle reset message
 boolean handleRole(boolean addition, java.lang.Long role)
          Handle role message
 boolean handleRole(boolean addition, org.openrdf.model.URI role)
          Handle role message
 boolean handleStartDocument()
          Handle start of document message
 boolean handleStatement(boolean addition, IRdbTerm graphId, IRdbTerm subj, IRdbTerm prop, IRdbTerm obj)
          Handle statement message
 boolean handleStatement(boolean addition, java.lang.Long graphId, java.lang.Long subj, java.lang.Long prop, java.lang.Long obj, java.util.Map<java.lang.Long,org.openrdf.model.Value> nodes)
          Handle statement message
 boolean handleStatement(boolean addition, org.openrdf.model.URI graphId, org.openrdf.model.Resource subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj)
          Handle statement message
 boolean handleSubRoleOf(boolean addition, java.lang.Long role, java.lang.Long parentRole)
          Handle Role subrole of another role message
 boolean handleSubRoleOf(boolean addition, org.openrdf.model.URI role, org.openrdf.model.URI parentRole)
          Handle Role subrole of another role message
 boolean handleTransactionEnd()
          Handle end of transaction message
 boolean handleTransactionStart(java.lang.Long transactionId, java.lang.Long commited)
          Handle start of transaction message
 boolean handleUser(boolean addition, java.lang.Long user, java.lang.Long defaultRole, java.lang.Long defaultAcl, java.lang.String userId, java.lang.String password)
          Handle user message
 boolean handleUser(boolean addition, org.openrdf.model.URI user, org.openrdf.model.URI defaultRole, org.openrdf.model.URI defaultAcl, java.lang.String userId, java.lang.String password)
          Handle user message
 boolean handleUserInRole(boolean addition, java.lang.Long user, java.lang.Long role)
          Handle User in Role message
 boolean handleUserInRole(boolean addition, org.openrdf.model.URI user, org.openrdf.model.URI role)
          Handle User in Role message
 void writeNode(java.lang.Long id, java.util.Map<java.lang.Long,org.openrdf.model.Value> cache)
          Write Node with ID to outputstream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerWriter

public ServerWriter(RepositoryConnection repositoryConnection,
                    java.io.OutputStream out,
                    java.util.HashMap<java.lang.Long,org.openrdf.model.Value> visitedUris)
Create a new ServerWriter

Parameters:
repositoryConnection - RepositoryConnection to run queries against
out - OutputStream to which results are written
visitedUris - Mapping of IDs to URIs that have already been seen and written

ServerWriter

public ServerWriter(RepositoryConnection repositoryConnection,
                    java.io.OutputStream out)
Create a new ServerWriter

Parameters:
repositoryConnection - RepositoryConnection to run queries against
out - OutputStream to which results are written
Method Detail

getNode

public org.openrdf.model.Value getNode(java.lang.Long id)
Get the URI for a given ID

Parameters:
id - ID for URI
Returns:
URI for ID

writeNode

public void writeNode(java.lang.Long id,
                      java.util.Map<java.lang.Long,org.openrdf.model.Value> cache)
               throws AnzoException
Write Node with ID to outputstream

Parameters:
id - ID of Node
cache - cache of IDs to Values
Throws:
AnzoException

handleAci

public boolean handleAci(boolean addition,
                         java.lang.Long namedGraph,
                         java.lang.Long acl,
                         java.lang.Long role,
                         java.lang.Boolean canRead,
                         java.lang.Boolean canAdd,
                         java.lang.Boolean canRemove,
                         java.lang.Boolean canInsertNamedGraph,
                         java.lang.Boolean canRemoveNamedGraph,
                         java.lang.Boolean canChangeAcl)
                  throws AnzoException
Handle ACI message

Parameters:
addition - Is this message an addition or deletion
namedGraph - ID for URI of NamedGraph that this ACI belongs
acl - URI of ACL
role - Role that this ACI affects
canRead - Can this role read the graph
canAdd - Can this role add to the graph
canRemove - Can this role remove from the graph
canInsertNamedGraph - Can this role insert a new NamedGraph
canRemoveNamedGraph - Can this role remove a NamedGraph
canChangeAcl - Can this role change the ACL properties
Returns:
Message handled successfully
Throws:
AnzoException

handleAci

public boolean handleAci(boolean addition,
                         org.openrdf.model.URI namedGraph,
                         org.openrdf.model.URI acl,
                         org.openrdf.model.URI role,
                         java.lang.Boolean canRead,
                         java.lang.Boolean canAdd,
                         java.lang.Boolean canRemove,
                         java.lang.Boolean canInsertNamedGraph,
                         java.lang.Boolean canRemoveNamedGraph,
                         java.lang.Boolean canChangeAcl)
                  throws AnzoException
Description copied from interface: IRepositoryHandler
Handle ACI message

Specified by:
handleAci in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
namedGraph - URI of NamedGraph that this ACI belongs
acl - URI of ACL
role - Role that this ACI affects
canRead - Can this role read the graph
canAdd - Can this role add to the graph
canRemove - Can this role remove from the graph
canInsertNamedGraph - Can this role insert a new NamedGraph
canRemoveNamedGraph - Can this role remove a NamedGraph
canChangeAcl - Can this role change the ACL properties
Returns:
Message handled successfully
Throws:
AnzoException

handleAcl

public boolean handleAcl(boolean addition,
                         org.openrdf.model.URI acl,
                         boolean isTemplate)
                  throws AnzoException
Description copied from interface: IRepositoryHandler
Handle ACL message

Specified by:
handleAcl in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
acl - URI of ACL
isTemplate - Is this acl a template
Returns:
Message handled successfully
Throws:
AnzoException

handleAcl

public boolean handleAcl(boolean addition,
                         java.lang.Long acl,
                         boolean isTemplate)
                  throws AnzoException
Handle ACL message

Parameters:
addition - Is this message an addition or deletion
acl - ID for URI of ACL
isTemplate - Is this acl a template
Returns:
Message handled successfully
Throws:
AnzoException

handleCommandStart

public boolean handleCommandStart(java.lang.Long commandId,
                                  java.lang.String commandType,
                                  java.lang.String commadPreReq)
                           throws AnzoException
Description copied from interface: IRepositoryHandler
Handle start of command message

Specified by:
handleCommandStart in interface IRepositoryHandler
Parameters:
commandId - Id of command
commandType - Type of command
commadPreReq - Serialized graph representation of precondition for command
Returns:
Message handled successfully
Throws:
AnzoException

handleCommandEnd

public boolean handleCommandEnd()
                         throws AnzoException
Description copied from interface: IRepositoryHandler
Handle end of command message

Specified by:
handleCommandEnd in interface IRepositoryHandler
Returns:
Message handled successfully
Throws:
AnzoException

handleEndDocument

public boolean handleEndDocument()
                          throws AnzoException
Description copied from interface: IRepositoryHandler
Handle end of document message

Specified by:
handleEndDocument in interface IRepositoryHandler
Returns:
Message handled successfully
Throws:
AnzoException

handleNamedGraph

public boolean handleNamedGraph(boolean addition,
                                org.openrdf.model.URI graph,
                                org.openrdf.model.URI metaGraph,
                                java.lang.Long revision,
                                org.openrdf.model.URI aclTemplate,
                                org.openrdf.model.URI createdBy,
                                java.lang.Long modified,
                                org.openrdf.model.URI lastModifiedBy)
                         throws AnzoException
Description copied from interface: IRepositoryHandler
Handle NamedGraph message

Specified by:
handleNamedGraph in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
graph - URI of NamedGraph
metaGraph - URI of NamedGraph's metadata graph
revision - Revision value of NamedGraph
aclTemplate - URI of ACL that this NamedGraph uses
createdBy - User that created the NamedGraph
modified - When graph was last modified
lastModifiedBy - Who last modified graph
Returns:
Message handled successfully
Throws:
AnzoException

handleNamedGraph

public boolean handleNamedGraph(boolean addition,
                                java.lang.Long graph,
                                java.lang.Long metaGraph,
                                java.lang.Long revision,
                                java.lang.Long aclTemplate,
                                java.lang.Long createdBy,
                                java.lang.Long modified,
                                java.lang.Long lastModifiedBy)
                         throws AnzoException
Handle NamedGraph message

Parameters:
addition - Is this message an addition or deletion
graph - ID of URI of NamedGraph
metaGraph - URI of NamedGraph's metadata graph
revision - Revision value of NamedGraph
aclTemplate - URI of ACL that this NamedGraph uses
createdBy - User that created the NamedGraph
modified - When graph was last modified
lastModifiedBy - Who last modified graph
Returns:
Message handled successfully
Throws:
AnzoException

handleNode

public boolean handleNode(java.lang.Long id,
                          org.openrdf.model.Value node)
                   throws AnzoException
Description copied from interface: IRepositoryHandler
Handle Node message

Specified by:
handleNode in interface IRepositoryHandler
Parameters:
id - ID of node
node - Value of node
Returns:
Message handled successfully
Throws:
AnzoException

handleRole

public boolean handleRole(boolean addition,
                          org.openrdf.model.URI role)
                   throws AnzoException
Description copied from interface: IRepositoryHandler
Handle role message

Specified by:
handleRole in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
role - Role added or deleted
Returns:
Message handled successfully
Throws:
AnzoException

handleRole

public boolean handleRole(boolean addition,
                          java.lang.Long role)
                   throws AnzoException
Handle role message

Parameters:
addition - Is this message an addition or deletion
role - ID of Role added or deleted
Returns:
Message handled successfully
Throws:
AnzoException

handleStartDocument

public boolean handleStartDocument()
                            throws AnzoException
Description copied from interface: IRepositoryHandler
Handle start of document message

Specified by:
handleStartDocument in interface IRepositoryHandler
Returns:
Message handled successfully
Throws:
AnzoException

handleStatement

public boolean handleStatement(boolean addition,
                               org.openrdf.model.URI graphId,
                               org.openrdf.model.Resource subj,
                               org.openrdf.model.URI prop,
                               org.openrdf.model.Value obj)
                        throws AnzoException
Description copied from interface: IRepositoryHandler
Handle statement message

Specified by:
handleStatement in interface IRepositoryHandler
Parameters:
addition - Is this a statement addition or deletion
graphId - URI of NamedGraph that statement belongs to
subj - Subject value
prop - Predicate value
obj - Object value
Returns:
Message handled successfully
Throws:
AnzoException

handleStatement

public boolean handleStatement(boolean addition,
                               IRdbTerm graphId,
                               IRdbTerm subj,
                               IRdbTerm prop,
                               IRdbTerm obj)
                        throws AnzoException
Handle statement message

Parameters:
addition - Is this a statement addition or deletion
graphId - URI of NamedGraph that statement belongs to
subj - Subject value
prop - Predicate value
obj - Object value
Returns:
Message handled successfully
Throws:
AnzoException

handleStatement

public boolean handleStatement(boolean addition,
                               java.lang.Long graphId,
                               java.lang.Long subj,
                               java.lang.Long prop,
                               java.lang.Long obj,
                               java.util.Map<java.lang.Long,org.openrdf.model.Value> nodes)
                        throws AnzoException
Handle statement message

Parameters:
addition - Is this a statement addition or deletion
graphId - URI of NamedGraph that statement belongs to
subj - Subject value
prop - Predicate value
obj - Object value
nodes - map of ids to their values
Returns:
Message handled successfully
Throws:
AnzoException

handleSubRoleOf

public boolean handleSubRoleOf(boolean addition,
                               org.openrdf.model.URI role,
                               org.openrdf.model.URI parentRole)
                        throws AnzoException
Description copied from interface: IRepositoryHandler
Handle Role subrole of another role message

Specified by:
handleSubRoleOf in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
role - Role value
parentRole - Parent role to which role is a subrole
Returns:
Message handled successfully
Throws:
AnzoException

handleSubRoleOf

public boolean handleSubRoleOf(boolean addition,
                               java.lang.Long role,
                               java.lang.Long parentRole)
                        throws AnzoException
Handle Role subrole of another role message

Parameters:
addition - Is this message an addition or deletion
role - id of Role value
parentRole - id of Parent role to which role is a subrole
Returns:
Message handled successfully
Throws:
AnzoException

handleTransactionStart

public boolean handleTransactionStart(java.lang.Long transactionId,
                                      java.lang.Long commited)
                               throws AnzoException
Description copied from interface: IRepositoryHandler
Handle start of transaction message

Specified by:
handleTransactionStart in interface IRepositoryHandler
Parameters:
transactionId - Id of transaction
commited - timestamp when transaction was committed
Returns:
Message handled successfully
Throws:
AnzoException

handleTransactionEnd

public boolean handleTransactionEnd()
                             throws AnzoException
Description copied from interface: IRepositoryHandler
Handle end of transaction message

Specified by:
handleTransactionEnd in interface IRepositoryHandler
Returns:
Message handled successfully
Throws:
AnzoException

handleUser

public boolean handleUser(boolean addition,
                          org.openrdf.model.URI user,
                          org.openrdf.model.URI defaultRole,
                          org.openrdf.model.URI defaultAcl,
                          java.lang.String userId,
                          java.lang.String password)
                   throws AnzoException
Description copied from interface: IRepositoryHandler
Handle user message

Specified by:
handleUser in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
user - User value
defaultRole - Default role for this user
defaultAcl - URI for the default ACL template for this user
userId - UserId for this user
password - Password for this user
Returns:
Message handled successfully
Throws:
AnzoException

handleUser

public boolean handleUser(boolean addition,
                          java.lang.Long user,
                          java.lang.Long defaultRole,
                          java.lang.Long defaultAcl,
                          java.lang.String userId,
                          java.lang.String password)
                   throws AnzoException
Handle user message

Parameters:
addition - Is this message an addition or deletion
user - User value
defaultRole - Default role for this user
defaultAcl - id of URI for the default ACL template for this user
userId - UserId for this user
password - Password for this user
Returns:
Message handled successfully
Throws:
AnzoException

handleUserInRole

public boolean handleUserInRole(boolean addition,
                                org.openrdf.model.URI user,
                                org.openrdf.model.URI role)
                         throws AnzoException
Description copied from interface: IRepositoryHandler
Handle User in Role message

Specified by:
handleUserInRole in interface IRepositoryHandler
Parameters:
addition - Is this message an addition or deletion
user - User value
role - Role user is being added to or deleted from
Returns:
Message handled successfully
Throws:
AnzoException

handleUserInRole

public boolean handleUserInRole(boolean addition,
                                java.lang.Long user,
                                java.lang.Long role)
                         throws AnzoException
Handle User in Role message

Parameters:
addition - Is this message an addition or deletion
user - id of User value
role - id of Role user is being added to or deleted from
Returns:
Message handled successfully
Throws:
AnzoException

handleError

public boolean handleError(int errorNumber,
                           int errorSubNumber,
                           java.lang.String... errorMessageArgs)
                    throws AnzoException
Description copied from interface: IRepositoryHandler
Handle an error message

Specified by:
handleError in interface IRepositoryHandler
Parameters:
errorNumber - Major error code
errorSubNumber - Minor error code
errorMessageArgs - Arguments to error message
Returns:
Message handled successfully
Throws:
AnzoException

handleReset

public boolean handleReset()
                    throws AnzoException
Description copied from interface: IRepositoryHandler
Handle reset message

Specified by:
handleReset in interface IRepositoryHandler
Returns:
Message handled successfully
Throws:
AnzoException


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.