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_AUTH
           
static String ACTIVATION_AUTH_KEY
           
static String ACTIVATION_FAILED
           
static String ACTIVATION_HANDSHAKE
           
static String ACTIVATION_SUCCESSFUL
           
protected  ActivationMonitor activationMonitor
           
static String COMMIT
           
static String CONTENT_FILTER_RULE
           
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
          Deprecated. since 4.5 - use logical workspace instead.
protected  String repositoryName
          Deprecated. since 4.5 - should no longer be needed when operating with logical workspace names
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_MD_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()
           
BaseSyndicatorImpl(ActivationMonitor activationMonitor)
           
 
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, String handshakeKey)
          Adds headers fields describing activation request.
protected  void addDeactivationHeaders(URLConnection connection, String nodeUUID, String handshakeKey)
          Adds header fields describing deactivation request.
protected  void addHandshakeInfo(URLConnection connection, String handshakeKey)
           
protected  void cleanTemporaryStore(ActivationContent activationContent)
          Cleans up temporary file store after activation.
 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  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 releaseConnection(URLConnection urlConnection)
           
 void setResouceCollector(ResourceCollector resourceCollector)
           
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

@Deprecated
public static final String REPOSITORY_NAME
Deprecated. since 4.5 - use logical workspace instead.
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_MD_ATTRIBUTE

public static final String RESOURCE_MAPPING_MD_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

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_HANDSHAKE

public static final String ACTIVATION_HANDSHAKE
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

ACTIVATION_AUTH

public static final String ACTIVATION_AUTH
See Also:
Constant Field Values

ACTIVATION_AUTH_KEY

public static final String ACTIVATION_AUTH_KEY
See Also:
Constant Field Values

activationMonitor

protected ActivationMonitor activationMonitor

repositoryName

@Deprecated
protected String repositoryName
Deprecated. since 4.5 - should no longer be needed when operating with logical workspace names

workspaceName

protected String workspaceName

parent

protected String parent

contentFilterRule

protected Rule contentFilterRule

user

protected User user
Constructor Detail

BaseSyndicatorImpl

public BaseSyndicatorImpl()

BaseSyndicatorImpl

@Inject
public BaseSyndicatorImpl(ActivationMonitor activationMonitor)
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

releaseConnection

protected void releaseConnection(URLConnection urlConnection)

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,
                                      String handshakeKey)
Adds header fields describing deactivation request.

Parameters:
connection -
handshakeKey - optional key to encrypt public key before sending it over

addHandshakeInfo

protected void addHandshakeInfo(URLConnection connection,
                                String handshakeKey)

getActivationURL

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


addActivationHeaders

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

Parameters:
handshakeKey - Optional key previously received from subscriber, used to encrypt activation public key for delivery to said subscriber. Or null when such key is not known or present.

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

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

setResouceCollector

@Inject
public void setResouceCollector(ResourceCollector resourceCollector)


Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.