info.magnolia.module.exchangesimple
Class BaseSyndicatorImpl

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

public abstract class BaseSyndicatorImpl
extends Object
implements info.magnolia.cms.exchange.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  info.magnolia.cms.core.Content.ContentFilter contentFilter
           
protected  info.magnolia.cms.util.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
          Mane 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  info.magnolia.cms.security.User user
           
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, info.magnolia.cms.core.Content content)
          This will activate specifies page (sub pages) to all configured subscribers.
 void activate(String parent, info.magnolia.cms.core.Content content, List<String> orderBefore)
          This will activate specified node to all configured subscribers.
abstract  String activate(info.magnolia.cms.exchange.Subscriber subscriber, ActivationContent activationContent, String nodePath)
          Send request of activation of activationContent to the subscriber.
 void activate(info.magnolia.cms.exchange.Subscriber subscriber, String parent, info.magnolia.cms.core.Content content)
          This will activate specifies page (sub pages) to the specified subscriber.
 void activate(info.magnolia.cms.exchange.Subscriber subscriber, String parent, info.magnolia.cms.core.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, info.magnolia.cms.core.Content content, info.magnolia.cms.core.Content.ContentFilter filter, ActivationContent activationContent)
           
protected  void cleanTemporaryStore(ActivationContent activationContent)
          Cleans up temporary file store after activation.
protected  ActivationContent collect(info.magnolia.cms.core.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(info.magnolia.cms.core.Content node)
           
 void deactivate(String path)
           
 void deactivate(info.magnolia.cms.exchange.Subscriber subscriber, info.magnolia.cms.core.Content node)
           
abstract  void doDeactivate(String nodeUUID, String nodePath)
           
abstract  String doDeactivate(info.magnolia.cms.exchange.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, info.magnolia.cms.core.Content content, XMLReader elementfilter, OutputStream os, boolean noRecurse)
           
protected  String getActivationURL(info.magnolia.cms.exchange.Subscriber subscriberInfo)
          Retrieves URL subscriber is listening on for (de)activation requests.
protected  String getDeactivationURL(info.magnolia.cms.exchange.Subscriber subscriberInfo)
          Return URI set for deactivation.
protected  String getMappedPath(String path, info.magnolia.cms.exchange.Subscription subscription)
          Gets target path to which the current path is mapped in given subscription.
 void init(info.magnolia.cms.security.User user, String repositoryName, String workspaceName, info.magnolia.cms.util.Rule rule)
           
protected  URLConnection prepareConnection(info.magnolia.cms.exchange.Subscriber subscriber)
           
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(info.magnolia.cms.core.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
Mane of the resource containing reading sequence for importing the data in activation target.

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 info.magnolia.cms.core.Content.ContentFilter contentFilter

contentFilterRule

protected info.magnolia.cms.util.Rule contentFilterRule

user

protected info.magnolia.cms.security.User user

basicCredentials

protected String basicCredentials
Constructor Detail

BaseSyndicatorImpl

public BaseSyndicatorImpl()
Method Detail

executeInPool

protected static void executeInPool(Runnable job)
                             throws info.magnolia.cms.exchange.ExchangeException
Runs a given job in the thread pool.

Parameters:
job - the job to run
Throws:
info.magnolia.cms.exchange.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(info.magnolia.cms.security.User user,
                 String repositoryName,
                 String workspaceName,
                 info.magnolia.cms.util.Rule rule)
Specified by:
init in interface info.magnolia.cms.exchange.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,
                     info.magnolia.cms.core.Content content)
              throws info.magnolia.cms.exchange.ExchangeException,
                     javax.jcr.RepositoryException
This will activate specifies page (sub pages) to all configured subscribers.

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

activate

public void activate(String parent,
                     info.magnolia.cms.core.Content content,
                     List<String> orderBefore)
              throws info.magnolia.cms.exchange.ExchangeException,
                     javax.jcr.RepositoryException
This will activate specified node to all configured subscribers.

Specified by:
activate in interface info.magnolia.cms.exchange.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
info.magnolia.cms.exchange.ExchangeException

activate

public void activate(info.magnolia.cms.exchange.Subscriber subscriber,
                     String parent,
                     info.magnolia.cms.core.Content content)
              throws info.magnolia.cms.exchange.ExchangeException,
                     javax.jcr.RepositoryException
This will activate specifies page (sub pages) to the specified subscriber.

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

activate

public void activate(info.magnolia.cms.exchange.Subscriber subscriber,
                     String parent,
                     info.magnolia.cms.core.Content content,
                     List<String> orderBefore)
              throws info.magnolia.cms.exchange.ExchangeException,
                     javax.jcr.RepositoryException
This will activate specifies node to the specified subscriber.

Specified by:
activate in interface info.magnolia.cms.exchange.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
info.magnolia.cms.exchange.ExchangeException

activate

public abstract void activate(ActivationContent activationContent,
                              String nodePath)
                       throws info.magnolia.cms.exchange.ExchangeException
Throws:
info.magnolia.cms.exchange.ExchangeException

activate

public abstract String activate(info.magnolia.cms.exchange.Subscriber subscriber,
                                ActivationContent activationContent,
                                String nodePath)
                         throws info.magnolia.cms.exchange.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:
info.magnolia.cms.exchange.ExchangeException

cleanTemporaryStore

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


deactivate

public void deactivate(String path)
                throws info.magnolia.cms.exchange.ExchangeException,
                       javax.jcr.RepositoryException
Throws:
info.magnolia.cms.exchange.ExchangeException
javax.jcr.RepositoryException

deactivate

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

deactivate

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

doDeactivate

public abstract void doDeactivate(String nodeUUID,
                                  String nodePath)
                           throws info.magnolia.cms.exchange.ExchangeException
Throws:
info.magnolia.cms.exchange.ExchangeException

doDeactivate

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

Parameters:
subscriber -
Throws:
info.magnolia.cms.exchange.ExchangeException

getDeactivationURL

protected String getDeactivationURL(info.magnolia.cms.exchange.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(info.magnolia.cms.exchange.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(info.magnolia.cms.core.Content node,
                              String type)
                       throws info.magnolia.cms.security.AccessDeniedException
Parameters:
node -
type - (activate / deactivate)
Throws:
info.magnolia.cms.security.AccessDeniedException

collect

protected ActivationContent collect(info.magnolia.cms.core.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,
                            info.magnolia.cms.core.Content content,
                            info.magnolia.cms.core.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,
                              info.magnolia.cms.core.Content content,
                              XMLReader elementfilter,
                              OutputStream os,
                              boolean noRecurse)
                       throws Exception
Throws:
Exception

getMappedPath

protected String getMappedPath(String path,
                               info.magnolia.cms.exchange.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(info.magnolia.cms.exchange.Subscriber subscriber)
                                   throws info.magnolia.cms.exchange.ExchangeException
Throws:
info.magnolia.cms.exchange.ExchangeException


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