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 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 String ACTION
           
static String ACTIVATE
           
static String ACTIVATION_ATTRIBUTE_MESSAGE
           
static String ACTIVATION_ATTRIBUTE_STATUS
           
static String ACTIVATION_ATTRIBUTE_VERSION
           
static String ACTIVATION_FAILED
           
static String ACTIVATION_SUCCESSFUL
           
static String AUTH_CREDENTIALS
           
static String AUTH_USER
           
static String AUTHORIZATION
           
protected  String basicCredentials
           
static String COMMIT
           
static String CONTENT_FILTER_RULE
           
protected  Content.ContentFilter contentFilter
           
protected  Rule contentFilterRule
           
static String DEACTIVATE
           
static String DEFAULT_HANDLER
          URI used for activation.
static String MAPPED_PARENT_PATH
           
static String NODE_UUID
           
protected  String parent
           
static String PARENT_PATH
           
static String PATH
          Path to be activated or deactivated.
static String REPOSITORY_NAME
           
protected  String repositoryName
           
static String RESOURCE_MAPPING_FILE
          Name of the resource containing reading sequence for importing the data in activation target.
static String RESOURCE_MAPPING_FILE_ELEMENT
           
static String RESOURCE_MAPPING_ID_ATTRIBUTE
           
static String RESOURCE_MAPPING_NAME_ATTRIBUTE
           
static String RESOURCE_MAPPING_ROOT_ELEMENT
           
static String RESOURCE_MAPPING_UUID_ATTRIBUTE
           
static String ROLLBACK
           
static String SIBLING_UUID
           
static String SIBLINGS_ELEMENT
           
static String SIBLINGS_ROOT_ELEMENT
          Name of the element in the resource file describing siblings of activated node.
protected  User user
           
static String UTF8_STATUS
           
static String VERSION_NAME
           
static String WORKSPACE_NAME
           
protected  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, String nodePath)
           
 void activate(String parent, Content content)
          This will activate specifies page (sub pages) to all configured subscribers.
 void activate(String parent, Content content, List<String> orderBefore)
          This will activate specified node to all configured subscribers.
 String activate(Subscriber subscriber, ActivationContent activationContent, String nodePath)
          Send request of activation of activationContent to the subscriber.
 void activate(Subscriber subscriber, String parent, Content content)
          This will activate specifies page (sub pages) to the specified subscriber.
 void activate(Subscriber subscriber, String parent, Content content, List<String> orderBefore)
          This will activate specifies node to the specified subscriber.
protected  void addActivationHeaders(URLConnection connection, ActivationContent activationContent)
          Adds headers fields describing activation request.
protected  void addDeactivationHeaders(URLConnection connection, String nodeUUID)
          Adds header fields describing deactivation request.
protected  void addOrderingInfo(org.jdom.Element root, List<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, List<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(String path)
           
 void deactivate(Subscriber subscriber, Content node)
           
abstract  void doDeactivate(String nodeUUID, String nodePath)
           
abstract  String doDeactivate(Subscriber subscriber, String nodeUUID, String nodePath)
          Deactivate content from specified subscriber.
protected static void executeInPool(Runnable job)
          Runs a given job in the thread pool.
protected  void exportAndParse(javax.jcr.Session session, Content content, XMLReader elementfilter, OutputStream os, boolean noRecurse)
           
protected  String getActivationURL(Subscriber subscriberInfo)
          Retrieves URL subscriber is listening on for (de)activation requests.
protected  String getDeactivationURL(Subscriber subscriberInfo)
          Return URI set for deactivation.
protected  String getMappedPath(String path, Subscription subscription)
          Gets target path to which the current path is mapped in given subscription.
 void init(User user, String repositoryName, String workspaceName, Rule rule)
          Sets up the syndicator.
protected  URLConnection prepareConnection(Subscriber subscriber, String urlString)
           
protected  void updateActivationDetails(String path)
          Updates current content activation meta data with the time stamp and user details of the activation.
protected  void updateDeactivationDetails(String nodeUUID)
          Updates current content activation meta data with the timestamp and user details of the deactivation.
protected  void updateMetaData(Content node, 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 String DEFAULT_HANDLER
URI used for activation.

See Also:
Constant Field Values

PARENT_PATH

public static final String PARENT_PATH
See Also:
Constant Field Values

MAPPED_PARENT_PATH

public static final String MAPPED_PARENT_PATH
See Also:
Constant Field Values

PATH

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

See Also:
Constant Field Values

NODE_UUID

public static final String NODE_UUID
See Also:
Constant Field Values

REPOSITORY_NAME

public static final String REPOSITORY_NAME
See Also:
Constant Field Values

WORKSPACE_NAME

public static final String WORKSPACE_NAME
See Also:
Constant Field Values

VERSION_NAME

public static final String VERSION_NAME
See Also:
Constant Field Values

RESOURCE_MAPPING_FILE

public static final 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 String UTF8_STATUS
See Also:
Constant Field Values

SIBLINGS_ROOT_ELEMENT

public static final 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 String SIBLINGS_ELEMENT
See Also:
Constant Field Values

SIBLING_UUID

public static final String SIBLING_UUID
See Also:
Constant Field Values

RESOURCE_MAPPING_FILE_ELEMENT

public static final String RESOURCE_MAPPING_FILE_ELEMENT
See Also:
Constant Field Values

RESOURCE_MAPPING_NAME_ATTRIBUTE

public static final String RESOURCE_MAPPING_NAME_ATTRIBUTE
See Also:
Constant Field Values

RESOURCE_MAPPING_UUID_ATTRIBUTE

public static final String RESOURCE_MAPPING_UUID_ATTRIBUTE
See Also:
Constant Field Values

RESOURCE_MAPPING_ID_ATTRIBUTE

public static final String RESOURCE_MAPPING_ID_ATTRIBUTE
See Also:
Constant Field Values

RESOURCE_MAPPING_ROOT_ELEMENT

public static final String RESOURCE_MAPPING_ROOT_ELEMENT
See Also:
Constant Field Values

ACTION

public static final String ACTION
See Also:
Constant Field Values

ACTIVATE

public static final String ACTIVATE
See Also:
Constant Field Values

DEACTIVATE

public static final String DEACTIVATE
See Also:
Constant Field Values

COMMIT

public static final String COMMIT
See Also:
Constant Field Values

ROLLBACK

public static final String ROLLBACK
See Also:
Constant Field Values

AUTHORIZATION

public static final String AUTHORIZATION
See Also:
Constant Field Values

AUTH_CREDENTIALS

public static final String AUTH_CREDENTIALS
See Also:
Constant Field Values

AUTH_USER

public static final String AUTH_USER
See Also:
Constant Field Values

CONTENT_FILTER_RULE

public static final String CONTENT_FILTER_RULE
See Also:
Constant Field Values

ACTIVATION_SUCCESSFUL

public static final String ACTIVATION_SUCCESSFUL
See Also:
Constant Field Values

ACTIVATION_FAILED

public static final String ACTIVATION_FAILED
See Also:
Constant Field Values

ACTIVATION_ATTRIBUTE_STATUS

public static final String ACTIVATION_ATTRIBUTE_STATUS
See Also:
Constant Field Values

ACTIVATION_ATTRIBUTE_MESSAGE

public static final String ACTIVATION_ATTRIBUTE_MESSAGE
See Also:
Constant Field Values

ACTIVATION_ATTRIBUTE_VERSION

public static final String ACTIVATION_ATTRIBUTE_VERSION
See Also:
Constant Field Values

repositoryName

protected String repositoryName

workspaceName

protected String workspaceName

parent

protected String parent

contentFilter

protected Content.ContentFilter contentFilter

contentFilterRule

protected Rule contentFilterRule

user

protected User user

basicCredentials

protected String basicCredentials
Constructor Detail

BaseSyndicatorImpl

public BaseSyndicatorImpl()
Method Detail

executeInPool

protected static void executeInPool(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,
                 String repositoryName,
                 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(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(String parent,
                     Content content,
                     List<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,
                     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,
                     String parent,
                     Content content,
                     List<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,
                              String nodePath)
                       throws ExchangeException
Throws:
ExchangeException

activate

public String activate(Subscriber subscriber,
                       ActivationContent activationContent,
                       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

cleanTemporaryStore

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


deactivate

public void deactivate(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(String nodeUUID,
                                  String nodePath)
                           throws ExchangeException
Throws:
ExchangeException

doDeactivate

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

Parameters:
subscriber -
Throws:
ExchangeException

getDeactivationURL

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

Parameters:
subscriberInfo -

addDeactivationHeaders

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

Parameters:
connection -

getActivationURL

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


addActivationHeaders

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


updateActivationDetails

protected void updateActivationDetails(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(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,
                              String type)
                       throws AccessDeniedException
Parameters:
node -
type - (activate / deactivate)
Throws:
AccessDeniedException

collect

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

Throws:
Exception

addOrderingInfo

protected void addOrderingInfo(org.jdom.Element root,
                               List<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 IOException,
                            javax.jcr.RepositoryException,
                            SAXException,
                            Exception
Throws:
IOException
javax.jcr.RepositoryException
SAXException
Exception

exportAndParse

protected void exportAndParse(javax.jcr.Session session,
                              Content content,
                              XMLReader elementfilter,
                              OutputStream os,
                              boolean noRecurse)
                       throws Exception
Throws:
Exception

getMappedPath

protected String getMappedPath(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 URLConnection prepareConnection(Subscriber subscriber,
                                          String urlString)
                                   throws ExchangeException
Throws:
ExchangeException


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