info.magnolia.module.exchangesimple
Class BaseSyndicatorImpl

java.lang.Object
  extended by info.magnolia.module.exchangesimple.BaseSyndicatorImpl
All Implemented Interfaces:
Syndicator
Direct Known Subclasses:
SimpleSyndicator

public abstract class BaseSyndicatorImpl
extends java.lang.Object
implements Syndicator

Default implementation of Syndicator. Activates all the content to a subscriber configured on the server.

Author:
Sameer Charles $Id: $

Field Summary
static java.lang.String ACTION
           
static java.lang.String ACTIVATE
           
static java.lang.String ACTIVATION_ATTRIBUTE_MESSAGE
           
static java.lang.String ACTIVATION_ATTRIBUTE_STATUS
           
static java.lang.String ACTIVATION_ATTRIBUTE_VERSION
           
static java.lang.String ACTIVATION_FAILED
           
static java.lang.String ACTIVATION_SUCCESSFUL
           
static java.lang.String AUTH_CREDENTIALS
           
static java.lang.String AUTH_USER
           
static java.lang.String AUTHORIZATION
           
protected  java.lang.String basicCredentials
           
static java.lang.String COMMIT
           
static java.lang.String CONTENT_FILTER_RULE
           
protected  Content.ContentFilter contentFilter
           
protected  Rule contentFilterRule
           
static java.lang.String DEACTIVATE
           
static java.lang.String DEFAULT_HANDLER
          URI used for activation.
static java.lang.String MAPPED_PARENT_PATH
           
static java.lang.String NODE_UUID
           
protected  java.lang.String parent
           
static java.lang.String PARENT_PATH
           
static java.lang.String PATH
          Path to be activated or deactivated.
static java.lang.String REPOSITORY_NAME
           
protected  java.lang.String repositoryName
           
static java.lang.String RESOURCE_MAPPING_FILE
          Name of the resource containing reading sequence for importing the data in activation target.
static java.lang.String RESOURCE_MAPPING_FILE_ELEMENT
           
static java.lang.String RESOURCE_MAPPING_ID_ATTRIBUTE
           
static java.lang.String RESOURCE_MAPPING_NAME_ATTRIBUTE
           
static java.lang.String RESOURCE_MAPPING_ROOT_ELEMENT
           
static java.lang.String RESOURCE_MAPPING_UUID_ATTRIBUTE
           
static java.lang.String ROLLBACK
           
static java.lang.String SIBLING_UUID
           
static java.lang.String SIBLINGS_ELEMENT
           
static java.lang.String SIBLINGS_ROOT_ELEMENT
          Name of the element in the resource file describing siblings of activated node.
protected  User user
           
static java.lang.String UTF8_STATUS
           
static java.lang.String VERSION_NAME
           
static java.lang.String WORKSPACE_NAME
           
protected  java.lang.String workspaceName
           
 
Constructor Summary
BaseSyndicatorImpl()
           
 
Method Summary
protected static void acquireIgnoringInterruption(EDU.oswego.cs.dl.util.concurrent.Sync latch)
          Acquires a Sync ignoring any interruptions.
abstract  void activate(ActivationContent activationContent, java.lang.String nodePath)
           
 void activate(java.lang.String parent, Content content)
          This will activate specifies page (sub pages) to all configured subscribers.
 void activate(java.lang.String parent, Content content, java.util.List<java.lang.String> orderBefore)
          This will activate specified node to all configured subscribers.
 java.lang.String activate(Subscriber subscriber, ActivationContent activationContent, java.lang.String nodePath)
          Send request of activation of activationContent to the subscriber.
 void activate(Subscriber subscriber, java.lang.String parent, Content content)
          This will activate specifies page (sub pages) to the specified subscriber.
 void activate(Subscriber subscriber, java.lang.String parent, Content content, java.util.List<java.lang.String> orderBefore)
          This will activate specifies node to the specified subscriber.
protected  void addActivationHeaders(java.net.URLConnection connection, ActivationContent activationContent)
          Adds headers fields describing activation request.
protected  void addDeactivationHeaders(java.net.URLConnection connection, java.lang.String nodeUUID)
          Adds header fields describing deactivation request.
protected  void addOrderingInfo(org.jdom.Element root, java.util.List<java.lang.String> orderBefore)
          Adds ordering information to the resource mapping file.
protected  void addResources(org.jdom.Element resourceElement, javax.jcr.Session session, Content content, Content.ContentFilter filter, ActivationContent activationContent)
           
protected  void cleanTemporaryStore(ActivationContent activationContent)
          Cleans up temporary file store after activation.
protected  ActivationContent collect(Content node, java.util.List<java.lang.String> orderBefore)
          Collects all information about activated content and its children (those that are set to be activated with the parent by filter rules).
 void deactivate(Content node)
           
 void deactivate(java.lang.String path)
           
 void deactivate(Subscriber subscriber, Content node)
           
abstract  void doDeactivate(java.lang.String nodeUUID, java.lang.String nodePath)
           
abstract  java.lang.String doDeactivate(Subscriber subscriber, java.lang.String nodeUUID, java.lang.String nodePath)
          Deactivate content from specified subscriber.
protected static void executeInPool(java.lang.Runnable job)
          Runs a given job in the thread pool.
protected  void exportAndParse(javax.jcr.Session session, Content content, org.xml.sax.XMLReader elementfilter, java.io.OutputStream os, boolean noRecurse)
           
protected  java.lang.String getActivationURL(Subscriber subscriberInfo)
          Retrieves URL subscriber is listening on for (de)activation requests.
protected  java.lang.String getDeactivationURL(Subscriber subscriberInfo)
          Return URI set for deactivation.
protected  java.lang.String getMappedPath(java.lang.String path, Subscription subscription)
          Gets target path to which the current path is mapped in given subscription.
 void init(User user, java.lang.String repositoryName, java.lang.String workspaceName, Rule rule)
          Sets up the syndicator.
protected  java.net.URLConnection prepareConnection(Subscriber subscriber, java.lang.String urlString)
           
protected static java.lang.String stripPasswordFromUrl(java.lang.String escapedUrl)
           
protected  void updateActivationDetails(java.lang.String path)
          Updates current content activation meta data with the time stamp and user details of the activation.
protected  void updateDeactivationDetails(java.lang.String nodeUUID)
          Updates current content activation meta data with the timestamp and user details of the deactivation.
protected  void updateMetaData(Content node, java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HANDLER

public static final java.lang.String DEFAULT_HANDLER
URI used for activation.

See Also:
Constant Field Values

PARENT_PATH

public static final java.lang.String PARENT_PATH
See Also:
Constant Field Values

MAPPED_PARENT_PATH

public static final java.lang.String MAPPED_PARENT_PATH
See Also:
Constant Field Values

PATH

public static final java.lang.String PATH
Path to be activated or deactivated.

See Also:
Constant Field Values

NODE_UUID

public static final java.lang.String NODE_UUID
See Also:
Constant Field Values

REPOSITORY_NAME

public static final java.lang.String REPOSITORY_NAME
See Also:
Constant Field Values

WORKSPACE_NAME

public static final java.lang.String WORKSPACE_NAME
See Also:
Constant Field Values

VERSION_NAME

public static final java.lang.String VERSION_NAME
See Also:
Constant Field Values

RESOURCE_MAPPING_FILE

public static final java.lang.String RESOURCE_MAPPING_FILE
Name of the resource containing reading sequence for importing the data in activation target.

See Also:
Constant Field Values

UTF8_STATUS

public static final java.lang.String UTF8_STATUS
See Also:
Constant Field Values

SIBLINGS_ROOT_ELEMENT

public static final java.lang.String SIBLINGS_ROOT_ELEMENT
Name of the element in the resource file describing siblings of activated node. Siblings element will contain all siblings of the same node type which are "before" this node.

See Also:
Constant Field Values

SIBLINGS_ELEMENT

public static final java.lang.String SIBLINGS_ELEMENT
See Also:
Constant Field Values

SIBLING_UUID

public static final java.lang.String SIBLING_UUID
See Also:
Constant Field Values

RESOURCE_MAPPING_FILE_ELEMENT

public static final java.lang.String RESOURCE_MAPPING_FILE_ELEMENT
See Also:
Constant Field Values

RESOURCE_MAPPING_NAME_ATTRIBUTE

public static final java.lang.String RESOURCE_MAPPING_NAME_ATTRIBUTE
See Also:
Constant Field Values

RESOURCE_MAPPING_UUID_ATTRIBUTE

public static final java.lang.String RESOURCE_MAPPING_UUID_ATTRIBUTE
See Also:
Constant Field Values

RESOURCE_MAPPING_ID_ATTRIBUTE

public static final java.lang.String RESOURCE_MAPPING_ID_ATTRIBUTE
See Also:
Constant Field Values

RESOURCE_MAPPING_ROOT_ELEMENT

public static final java.lang.String RESOURCE_MAPPING_ROOT_ELEMENT
See Also:
Constant Field Values

ACTION

public static final java.lang.String ACTION
See Also:
Constant Field Values

ACTIVATE

public static final java.lang.String ACTIVATE
See Also:
Constant Field Values

DEACTIVATE

public static final java.lang.String DEACTIVATE
See Also:
Constant Field Values

COMMIT

public static final java.lang.String COMMIT
See Also:
Constant Field Values

ROLLBACK

public static final java.lang.String ROLLBACK
See Also:
Constant Field Values

AUTHORIZATION

public static final java.lang.String AUTHORIZATION
See Also:
Constant Field Values

AUTH_CREDENTIALS

public static final java.lang.String AUTH_CREDENTIALS
See Also:
Constant Field Values

AUTH_USER

public static final java.lang.String AUTH_USER
See Also:
Constant Field Values

CONTENT_FILTER_RULE

public static final java.lang.String CONTENT_FILTER_RULE
See Also:
Constant Field Values

ACTIVATION_SUCCESSFUL

public static final java.lang.String ACTIVATION_SUCCESSFUL
See Also:
Constant Field Values

ACTIVATION_FAILED

public static final java.lang.String ACTIVATION_FAILED
See Also:
Constant Field Values

ACTIVATION_ATTRIBUTE_STATUS

public static final java.lang.String ACTIVATION_ATTRIBUTE_STATUS
See Also:
Constant Field Values

ACTIVATION_ATTRIBUTE_MESSAGE

public static final java.lang.String ACTIVATION_ATTRIBUTE_MESSAGE
See Also:
Constant Field Values

ACTIVATION_ATTRIBUTE_VERSION

public static final java.lang.String ACTIVATION_ATTRIBUTE_VERSION
See Also:
Constant Field Values

repositoryName

protected java.lang.String repositoryName

workspaceName

protected java.lang.String workspaceName

parent

protected java.lang.String parent

contentFilter

protected Content.ContentFilter contentFilter

contentFilterRule

protected Rule contentFilterRule

user

protected User user

basicCredentials

protected java.lang.String basicCredentials
Constructor Detail

BaseSyndicatorImpl

public BaseSyndicatorImpl()
Method Detail

executeInPool

protected static void executeInPool(java.lang.Runnable job)
                             throws ExchangeException
Runs a given job in the thread pool.

Parameters:
job - the job to run
Throws:
ExchangeException - if the job could not be put in the pool

acquireIgnoringInterruption

protected static void acquireIgnoringInterruption(EDU.oswego.cs.dl.util.concurrent.Sync latch)
Acquires a Sync ignoring any interruptions. Should any interruption occur the interruption status will be set. Might potentially block/wait forever.

Parameters:
latch - the latch on which to wait
See Also:
Sync.acquire()

init

public void init(User user,
                 java.lang.String repositoryName,
                 java.lang.String workspaceName,
                 Rule rule)
Description copied from interface: Syndicator
Sets up the syndicator.

Specified by:
init in interface Syndicator
Parameters:
user -
repositoryName - repository ID
workspaceName - workspace ID
rule - content filter rule
See Also:
Syndicator.init(info.magnolia.cms.security.User, String, String, info.magnolia.cms.util.Rule)

activate

public void activate(java.lang.String parent,
                     Content content)
              throws ExchangeException,
                     javax.jcr.RepositoryException
This will activate specifies page (sub pages) to all configured subscribers.

Specified by:
activate in interface Syndicator
Parameters:
parent - parent under which this page will be activated
content - to be activated
Throws:
javax.jcr.RepositoryException
ExchangeException

activate

public void activate(java.lang.String parent,
                     Content content,
                     java.util.List<java.lang.String> orderBefore)
              throws ExchangeException,
                     javax.jcr.RepositoryException
This will activate specified node to all configured subscribers.

Specified by:
activate in interface Syndicator
Parameters:
parent - parent under which this page will be activated
content - to be activated
orderBefore - List of UUID to be used by the implementation to order this node after activation
Throws:
javax.jcr.RepositoryException
ExchangeException

activate

public void activate(Subscriber subscriber,
                     java.lang.String parent,
                     Content content)
              throws ExchangeException,
                     javax.jcr.RepositoryException
This will activate specifies page (sub pages) to the specified subscriber.

Specified by:
activate in interface Syndicator
Parameters:
subscriber -
parent - parent under which this page will be activated
content - to be activated
Throws:
javax.jcr.RepositoryException
ExchangeException

activate

public void activate(Subscriber subscriber,
                     java.lang.String parent,
                     Content content,
                     java.util.List<java.lang.String> orderBefore)
              throws ExchangeException,
                     javax.jcr.RepositoryException
This will activate specifies node to the specified subscriber.

Specified by:
activate in interface Syndicator
Parameters:
subscriber -
parent - parent under which this page will be activated
content - to be activated
orderBefore - List of UUID to be used by the subscriber to order this node after activation
Throws:
javax.jcr.RepositoryException
ExchangeException

activate

public abstract void activate(ActivationContent activationContent,
                              java.lang.String nodePath)
                       throws ExchangeException
Throws:
ExchangeException

activate

public java.lang.String activate(Subscriber subscriber,
                                 ActivationContent activationContent,
                                 java.lang.String nodePath)
                          throws ExchangeException
Send request of activation of activationContent to the subscriber. Subscriber might choose not to react if it is not subscribed to the URI under which activationContent exists.

Throws:
ExchangeException

stripPasswordFromUrl

protected static java.lang.String stripPasswordFromUrl(java.lang.String escapedUrl)

cleanTemporaryStore

protected void cleanTemporaryStore(ActivationContent activationContent)
Cleans up temporary file store after activation.


deactivate

public void deactivate(java.lang.String path)
                throws ExchangeException,
                       javax.jcr.RepositoryException
Throws:
ExchangeException
javax.jcr.RepositoryException

deactivate

public void deactivate(Content node)
                throws ExchangeException,
                       javax.jcr.RepositoryException
Specified by:
deactivate in interface Syndicator
Parameters:
node - to deactivate
Throws:
javax.jcr.RepositoryException
ExchangeException

deactivate

public void deactivate(Subscriber subscriber,
                       Content node)
                throws ExchangeException,
                       javax.jcr.RepositoryException
Specified by:
deactivate in interface Syndicator
Parameters:
node - , to deactivate
subscriber -
Throws:
javax.jcr.RepositoryException
ExchangeException

doDeactivate

public abstract void doDeactivate(java.lang.String nodeUUID,
                                  java.lang.String nodePath)
                           throws ExchangeException
Throws:
ExchangeException

doDeactivate

public abstract java.lang.String doDeactivate(Subscriber subscriber,
                                              java.lang.String nodeUUID,
                                              java.lang.String nodePath)
                                       throws ExchangeException
Deactivate content from specified subscriber.

Parameters:
subscriber -
Throws:
ExchangeException

getDeactivationURL

protected java.lang.String getDeactivationURL(Subscriber subscriberInfo)
Return URI set for deactivation.

Parameters:
subscriberInfo -

addDeactivationHeaders

protected void addDeactivationHeaders(java.net.URLConnection connection,
                                      java.lang.String nodeUUID)
Adds header fields describing deactivation request.

Parameters:
connection -

getActivationURL

protected java.lang.String getActivationURL(Subscriber subscriberInfo)
Retrieves URL subscriber is listening on for (de)activation requests.


addActivationHeaders

protected void addActivationHeaders(java.net.URLConnection connection,
                                    ActivationContent activationContent)
Adds headers fields describing activation request.


updateActivationDetails

protected void updateActivationDetails(java.lang.String path)
                                throws javax.jcr.RepositoryException
Updates current content activation meta data with the time stamp and user details of the activation.

Throws:
javax.jcr.RepositoryException

updateDeactivationDetails

protected void updateDeactivationDetails(java.lang.String nodeUUID)
                                  throws javax.jcr.RepositoryException
Updates current content activation meta data with the timestamp and user details of the deactivation.

Throws:
javax.jcr.RepositoryException

updateMetaData

protected void updateMetaData(Content node,
                              java.lang.String type)
                       throws AccessDeniedException
Parameters:
node -
type - (activate / deactivate)
Throws:
AccessDeniedException

collect

protected ActivationContent collect(Content node,
                                    java.util.List<java.lang.String> orderBefore)
                             throws java.lang.Exception
Collects all information about activated content and its children (those that are set to be activated with the parent by filter rules).

Throws:
java.lang.Exception

addOrderingInfo

protected void addOrderingInfo(org.jdom.Element root,
                               java.util.List<java.lang.String> orderBefore)
Adds ordering information to the resource mapping file.

Parameters:
root - element of the resource file under which ordering info must be added
orderBefore -

addResources

protected void addResources(org.jdom.Element resourceElement,
                            javax.jcr.Session session,
                            Content content,
                            Content.ContentFilter filter,
                            ActivationContent activationContent)
                     throws java.io.IOException,
                            javax.jcr.RepositoryException,
                            org.xml.sax.SAXException,
                            java.lang.Exception
Throws:
java.io.IOException
javax.jcr.RepositoryException
org.xml.sax.SAXException
java.lang.Exception

exportAndParse

protected void exportAndParse(javax.jcr.Session session,
                              Content content,
                              org.xml.sax.XMLReader elementfilter,
                              java.io.OutputStream os,
                              boolean noRecurse)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getMappedPath

protected java.lang.String getMappedPath(java.lang.String path,
                                         Subscription subscription)
Gets target path to which the current path is mapped in given subscription. Provided path should be without trailing slash.


prepareConnection

protected java.net.URLConnection prepareConnection(Subscriber subscriber,
                                                   java.lang.String urlString)
                                            throws ExchangeException
Throws:
ExchangeException


Copyright © 2003-2011 Magnolia International Ltd.. All Rights Reserved.