atg.adapter.integrations
Class IntegrationRepositoryTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.adapter.integrations.IntegrationRepositoryTools
All Implemented Interfaces:
MessageSource, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.io.Serializable, java.util.EventListener

public class IntegrationRepositoryTools
extends GenericService
implements MessageSource, java.io.Serializable

This class implements a few common functions. This should be extended if any of these methods are inadequate. This is used to translate between Command inputs (or outputs) and repository items. Created: Wed Aug 28 09:29:24 2002

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
IntegrationRepositoryTools()
           
 
Method Summary
protected  void copyRemoteProperties(MutableRepositoryItem pTargetItem, java.lang.Object pSourceObject, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pTargetDescriptor, Command pRemoteCommand)
          Copy all of the properties in the source object to the target repository item
 java.lang.Object createGetCommandInput(java.lang.String pId, java.lang.String pExternalIdPropertyName, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor, Command pGetCommand)
          Create the input for the get command.
 java.lang.Object createRemoveCommandInput(java.lang.String pId, java.lang.String pExternalIdPropertyName, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor, Command pGetCommand)
          Create the input for the remove command.
 RepositoryItem createRepositoryItem(java.lang.Object pCommandResult, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor, MutableRepositoryItem pLocalItem, Command pRemoteCommand)
          Given a object, create a repository item out of it.
 RepositoryItem[] createRepositoryItems(java.lang.Object pCommandResult, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor, MutableRepositoryItem pLocalItem, Command pRemoteCommand)
          Given a object, create a repository item out of it.
protected  java.lang.Object createRepositoryValue(RepositoryPropertyDescriptor pPropertyDescriptor, java.lang.String pRemoteValue)
          Create an appropriate property value from the given remote value.
 void externalIdWasUpdated(atg.adapter.integrations.IntegrationRepository pRepository, RepositoryItem pItem, java.lang.String pOldValue, java.lang.String pNewValue)
          Send a scenario message of type IntegrationExternalIdChange when the external id is set for the first time.
 java.lang.Object getCommandResultObject(CommandResult pResult)
          Get result from the CommandResult.
 java.lang.String getExternalIdFromResult(java.lang.Object pResult, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor)
          Get the id for the external data.
 java.lang.String getMessagePort()
          The port that the scenario messages will be sent on
 MessageSourceContext getMessageSourceContext()
          Return the message source context for this source.
protected  boolean handleValue(MutableRepositoryItem pItem, RepositoryPropertyDescriptor pPropDescriptor, java.lang.Object pExternalValue, java.lang.Object pResult, java.lang.Object pParent, Command pRemoteCommand)
          copy the value into the correct property
 boolean isAllowMessageSending()
          This class cannot send messages if this is false.
 void sendMessage(atg.adapter.integrations.IntegrationRepository pRepository, atg.adapter.integrations.IntegrationRepositoryMessage pMessage)
          Sends an object message out on messagePort
 void setAllowMessageSending(boolean pAllowMessageSending)
           
 void setMessagePort(java.lang.String pMessagePort)
           
 void setMessageSourceContext(MessageSourceContext pMessageSourceContext)
          Set the message source context for this source.
 void startMessageSource()
          This is called to tell the MessageSource that it may begin sending messages.
 void stopMessageSource()
          This is called to tell the MessageSource that it should stop sending messages.
 MutableRepositoryItem updateExternalId(atg.adapter.integrations.IntegrationRepository pRepository, MutableRepositoryItem pItem, atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor, java.lang.String pExternalId, boolean pAllowNewItem)
          Update the given repository item with the given external id.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

IntegrationRepositoryTools

public IntegrationRepositoryTools()
Method Detail

setMessagePort

public void setMessagePort(java.lang.String pMessagePort)

getMessagePort

public java.lang.String getMessagePort()
The port that the scenario messages will be sent on


getCommandResultObject

public java.lang.Object getCommandResultObject(CommandResult pResult)
Get result from the CommandResult. If the CommandResults results property is multi-valued, the first element is returned, otherwise the entire pResult.result is returned

Parameters:
pResult - The result of a command.

updateExternalId

public MutableRepositoryItem updateExternalId(atg.adapter.integrations.IntegrationRepository pRepository,
                                              MutableRepositoryItem pItem,
                                              atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor,
                                              java.lang.String pExternalId,
                                              boolean pAllowNewItem)
                                       throws RepositoryException
Update the given repository item with the given external id. If the item uses the external id as the local repository id then it's possible a new item will be created and returned. To prevent this, set pAllowNewItem to false. If pAllowNewItem is false, then this method is guaranteed to return pItem.

Parameters:
pItem - The item being updated
pItemDescriptor - The IntegrationRepositoryItemDescriptor for pItem
pExternalId - The new external id
pAllowNewItem - If true, then it is possible that a new item will be created if the item uses external id as the id, and it is not correct.
Throws:
RepositoryException

externalIdWasUpdated

public void externalIdWasUpdated(atg.adapter.integrations.IntegrationRepository pRepository,
                                 RepositoryItem pItem,
                                 java.lang.String pOldValue,
                                 java.lang.String pNewValue)
                          throws RepositoryException
Send a scenario message of type IntegrationExternalIdChange when the external id is set for the first time. If and only if the repository's sendScenarioEvents is true.

Parameters:
pRepository - The integration repository containing the updated item
pItem - The item whose external id changed
pOldValue - The old value for the external id
pNewValue - The new value for the external id
Throws:
RepositoryException

getExternalIdFromResult

public java.lang.String getExternalIdFromResult(java.lang.Object pResult,
                                                atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor)
                                         throws RepositoryException
Get the id for the external data. This will return the value of the result property whose name matches the item's external ID property.

Throws:
RepositoryException

createRepositoryItem

public RepositoryItem createRepositoryItem(java.lang.Object pCommandResult,
                                           atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor,
                                           MutableRepositoryItem pLocalItem,
                                           Command pRemoteCommand)
                                    throws RepositoryException
Given a object, create a repository item out of it. If the id of the new item matches pLocalItem, just copy the values into pLocalItem.

Parameters:
pCommandResult - This is the result of the command to retrieve data from the remote system
pItemDescriptor - This is the item descriptor of the item being created
pLocalItem - This is only relevant during a "getItem". We don't need to get the local item twice
pRemoteCommand - This is the command that retrieved pCommandResult
Returns:
A RepositoryItem
Throws:
RepositoryException

createRepositoryItems

public RepositoryItem[] createRepositoryItems(java.lang.Object pCommandResult,
                                              atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor,
                                              MutableRepositoryItem pLocalItem,
                                              Command pRemoteCommand)
                                       throws RepositoryException
Given a object, create a repository item out of it. If the id of the new item matches pLocalItem, just copy the values into pLocalItem.

Parameters:
pCommandResult - This is the result of the command to retrieve data from the remote system
pItemDescriptor - This is the item descriptor of the item being created
pLocalItem - This is only relevant during a "getItem". We don't need to get the local item twice
pRemoteCommand - This is the command that retrieved pCommandResult
Returns:
An array RepositoryItems
Throws:
RepositoryException

createGetCommandInput

public java.lang.Object createGetCommandInput(java.lang.String pId,
                                              java.lang.String pExternalIdPropertyName,
                                              atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor,
                                              Command pGetCommand)
Create the input for the get command. This will return a map with a single entry: pExternalIdProperty -> pId


createRemoveCommandInput

public java.lang.Object createRemoveCommandInput(java.lang.String pId,
                                                 java.lang.String pExternalIdPropertyName,
                                                 atg.adapter.integrations.IntegrationRepositoryItemDescriptor pItemDescriptor,
                                                 Command pGetCommand)
Create the input for the remove command. This will return a map with a single entry: pExternalIdProperty -> pId


copyRemoteProperties

protected void copyRemoteProperties(MutableRepositoryItem pTargetItem,
                                    java.lang.Object pSourceObject,
                                    atg.adapter.integrations.IntegrationRepositoryItemDescriptor pTargetDescriptor,
                                    Command pRemoteCommand)
                             throws RepositoryException
Copy all of the properties in the source object to the target repository item

Throws:
RepositoryException

handleValue

protected boolean handleValue(MutableRepositoryItem pItem,
                              RepositoryPropertyDescriptor pPropDescriptor,
                              java.lang.Object pExternalValue,
                              java.lang.Object pResult,
                              java.lang.Object pParent,
                              Command pRemoteCommand)
                       throws RepositoryException
copy the value into the correct property

Parameters:
pItem - The item whose property will be updated.
pPropDescriptor - The property that will be updated
pExternalValue - The new value for the property
pResult - The object that contained the value.
pParent - the parent of pItem if applicable, usually null
Returns:
true if the property was successfully updated
Throws:
RepositoryException

createRepositoryValue

protected java.lang.Object createRepositoryValue(RepositoryPropertyDescriptor pPropertyDescriptor,
                                                 java.lang.String pRemoteValue)
Create an appropriate property value from the given remote value. Usually this means converting a String to a number, boolean, or date.

Parameters:
pPropertyDescriptor - The property that will be set
pRemoteValue - The value of the remote data
Returns:
The value to set in the repository item

setMessageSourceContext

public void setMessageSourceContext(MessageSourceContext pMessageSourceContext)
Set the message source context for this source.

Specified by:
setMessageSourceContext in interface MessageSource
See Also:
MessageSource

getMessageSourceContext

public MessageSourceContext getMessageSourceContext()
Return the message source context for this source.


setAllowMessageSending

public void setAllowMessageSending(boolean pAllowMessageSending)

isAllowMessageSending

public boolean isAllowMessageSending()
This class cannot send messages if this is false. Usually set during parsing of the configuration file.


startMessageSource

public void startMessageSource()
This is called to tell the MessageSource that it may begin sending messages.

Specified by:
startMessageSource in interface MessageSource

stopMessageSource

public void stopMessageSource()
This is called to tell the MessageSource that it should stop sending messages.

Specified by:
stopMessageSource in interface MessageSource

sendMessage

public void sendMessage(atg.adapter.integrations.IntegrationRepository pRepository,
                        atg.adapter.integrations.IntegrationRepositoryMessage pMessage)
                 throws javax.jms.JMSException
Sends an object message out on messagePort

Parameters:
pObjectMessage - the object to be placed in the object message.
Throws:
javax.jms.JMSException - is thrown when a failure to send the message occurs. This is generally a configuration issue.