com.waveset.adapter
Class ActiveSyncUtil

java.lang.Object
  extended bycom.waveset.adapter.ActiveSyncUtil
All Implemented Interfaces:
com.waveset.adapter.logging.IActiveSyncLogger

public class ActiveSyncUtil
extends java.lang.Object
implements com.waveset.adapter.logging.IActiveSyncLogger

ActiveSyncUtil is a class to assist in writing ActiveSync adapters. It has a mixture of logging and storage methods. As the ActiveSync environment matures, these methods will be updated to keep existing adapters compatible with new runtime environments. This class will be extended regularly to add new functionality so check the javadoc of the most current release for details


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
ActiveSyncUtil(ActiveSync source)
           
ActiveSyncUtil(Resource resource, ActiveSync source)
           
 
Method Summary
static boolean checkOption(ActiveSync source, java.lang.String attrName)
           
 java.lang.String getLogFileFullPath()
          Deprecated. Make sure the caller can handle null. This is here only to allow old adapters to compile.
 com.waveset.adapter.logging.IActiveSyncLogger getLogger()
           
 int getLogLevel()
           
static int getRepetitionCount(ActiveSync source)
          The repetition count is a scheduling parameter.
static TaskSchedule.RepetitionUnit getRepetitionUnit(ActiveSync source)
          The repetition unit is a scheduling parameter.
static java.util.Date getStartDate(ActiveSync source)
          Get the date when this adapter should start to be run
static java.util.Date getStartTime(ActiveSync source)
          Get the time when this adapter should run each time it is scheduled
 boolean isLogLevelEnabled(int level)
           
 boolean isStopRequested()
          Utility method for ActiveSync resource adapters to check if "stop synchronization" has been requested for the resource.
static void listToStringBuffer(java.util.List list, java.lang.StringBuffer sb)
          Append to the string buffer the list of objects.
 void logDebugMap(java.lang.String message, java.util.Map map)
           
 void logDebugString(java.lang.String update)
           
 void logErrorMap(java.lang.String message, java.util.Map map)
           
 void logErrorString(java.lang.String update)
           
 void logException(int level, java.lang.Throwable th)
           
 void logInfoMap(java.lang.String message, java.util.Map map)
           
 void logInfoString(java.lang.String update)
           
 void logMap(int level, java.lang.String message, java.util.Map map)
           
 void logResourceException(java.lang.String prefixLine, java.lang.Throwable th, ITrace trace, java.lang.String callingClass, java.lang.String callingMethod)
          Deprecated. as of IdM 7.0 (since ITrace already deprecated). Use logResourceException(String, Throwable, Trace, String, String) instead.
 void logResourceException(java.lang.String prefixLine, java.lang.Throwable th, Trace trace, java.lang.String callingMethod)
          Utility method to log an exception to the ActiveSync log, as well as an ITrace instance.
 void logResourceException(java.lang.String prefixLine, java.lang.Throwable th, Trace trace, java.lang.String callingClass, java.lang.String callingMethod)
          Utility method to log an exception to the ActiveSync log, as well as an ITrace instance.
 void logString(int level, java.lang.String update)
           
 void logString(int level, java.lang.String update, boolean addTimeStamp)
          The IActiveSyncLogger methods are delegated to the logger
 void logWarningMap(java.lang.String message, java.util.Map map)
           
 void logWarningString(java.lang.String update)
           
static void mapToStringBuffer(java.util.Map map, java.lang.StringBuffer sb)
          This takes a map and returns a string buffer, handy for logging.
static java.util.Map reconstituteEmptyStrings(java.util.Map map)
          Maps, when serialized with empty strings, turn them into nulls.
 boolean useLegacyEventGeneration()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

ActiveSyncUtil

public ActiveSyncUtil(Resource resource,
                      ActiveSync source)
               throws java.lang.Exception

ActiveSyncUtil

public ActiveSyncUtil(ActiveSync source)
               throws java.lang.Exception
Method Detail

mapToStringBuffer

public static void mapToStringBuffer(java.util.Map map,
                                     java.lang.StringBuffer sb)
This takes a map and returns a string buffer, handy for logging. The StringBuffer will have a series of lines of the format key : value \n. It handles null values.

Parameters:
map - - the map to translate. null or empty maps do not modify the stringBuffer
sb - - The string buffer to append to

listToStringBuffer

public static void listToStringBuffer(java.util.List list,
                                      java.lang.StringBuffer sb)
Append to the string buffer the list of objects. Each itemm in the list will be converted (via the toString() method) to a string and a newline will be appended. Null list items will be converted to the string "null".

Parameters:
list - - the list of objects to convert
sb - - the stringbuffer to append the items to

reconstituteEmptyStrings

public static java.util.Map reconstituteEmptyStrings(java.util.Map map)
Maps, when serialized with empty strings, turn them into nulls. This makes a new map with empty strings for the null values


getStartDate

public static java.util.Date getStartDate(ActiveSync source)
                                   throws java.text.ParseException,
                                          java.lang.Exception
Get the date when this adapter should start to be run

Returns:
date(now) if no ActiveSync, if the ActiveSync does not have a resource, or if there is no start date attribute. Return a Date if it is found.
Throws:
java.text.ParseException
java.lang.Exception

getStartTime

public static java.util.Date getStartTime(ActiveSync source)
Get the time when this adapter should run each time it is scheduled

Returns:
Date(now) if no ActiveSync, if the ActiveSync does not have a resource, or if there is no start time attribute. Return a Date if it is found.

getRepetitionUnit

public static TaskSchedule.RepetitionUnit getRepetitionUnit(ActiveSync source)
The repetition unit is a scheduling parameter. In conjunction with the repetition count (@see getRepetitionCount), it sets how often the adapter poll method is called. For example, if the repetition unit is hours and the count is three, the poll method will be called once every three hours.


getRepetitionCount

public static int getRepetitionCount(ActiveSync source)
The repetition count is a scheduling parameter. In conjunction with the repetition unit (@see getRepetitionUnit), it sets how often the adapter poll method is called. For example, if the repetition unit is hours and the count is three, the poll method will be called once every three hours.


checkOption

public static boolean checkOption(ActiveSync source,
                                  java.lang.String attrName)

getLogger

public com.waveset.adapter.logging.IActiveSyncLogger getLogger()
Returns:
the IActiveSyncLogger which is being delegated to

logString

public void logString(int level,
                      java.lang.String update,
                      boolean addTimeStamp)
The IActiveSyncLogger methods are delegated to the logger

Specified by:
logString in interface com.waveset.adapter.logging.IActiveSyncLogger

logString

public void logString(int level,
                      java.lang.String update)
Specified by:
logString in interface com.waveset.adapter.logging.IActiveSyncLogger

logErrorString

public void logErrorString(java.lang.String update)
Specified by:
logErrorString in interface com.waveset.adapter.logging.IActiveSyncLogger

logWarningString

public void logWarningString(java.lang.String update)
Specified by:
logWarningString in interface com.waveset.adapter.logging.IActiveSyncLogger

logInfoString

public void logInfoString(java.lang.String update)
Specified by:
logInfoString in interface com.waveset.adapter.logging.IActiveSyncLogger

logDebugString

public void logDebugString(java.lang.String update)
Specified by:
logDebugString in interface com.waveset.adapter.logging.IActiveSyncLogger

logException

public void logException(int level,
                         java.lang.Throwable th)
Specified by:
logException in interface com.waveset.adapter.logging.IActiveSyncLogger

logMap

public void logMap(int level,
                   java.lang.String message,
                   java.util.Map map)
Specified by:
logMap in interface com.waveset.adapter.logging.IActiveSyncLogger

logErrorMap

public void logErrorMap(java.lang.String message,
                        java.util.Map map)
Specified by:
logErrorMap in interface com.waveset.adapter.logging.IActiveSyncLogger

logWarningMap

public void logWarningMap(java.lang.String message,
                          java.util.Map map)
Specified by:
logWarningMap in interface com.waveset.adapter.logging.IActiveSyncLogger

logInfoMap

public void logInfoMap(java.lang.String message,
                       java.util.Map map)
Specified by:
logInfoMap in interface com.waveset.adapter.logging.IActiveSyncLogger

logDebugMap

public void logDebugMap(java.lang.String message,
                        java.util.Map map)
Specified by:
logDebugMap in interface com.waveset.adapter.logging.IActiveSyncLogger

getLogLevel

public int getLogLevel()
Specified by:
getLogLevel in interface com.waveset.adapter.logging.IActiveSyncLogger

isLogLevelEnabled

public boolean isLogLevelEnabled(int level)
Specified by:
isLogLevelEnabled in interface com.waveset.adapter.logging.IActiveSyncLogger

isStopRequested

public boolean isStopRequested()
Utility method for ActiveSync resource adapters to check if "stop synchronization" has been requested for the resource.

Returns:
true if "stop synchronization" has been requested for the resource, and not revoked.

logResourceException

public void logResourceException(java.lang.String prefixLine,
                                 java.lang.Throwable th,
                                 ITrace trace,
                                 java.lang.String callingClass,
                                 java.lang.String callingMethod)
Deprecated. as of IdM 7.0 (since ITrace already deprecated). Use logResourceException(String, Throwable, Trace, String, String) instead.

Utility method to log an exception to the ActiveSync log, as well as an ITrace instance.

Parameters:
prefixLine - (optional) Message to write before the error messages/stack trace.
th - Throwable being logged
trace - (optional) ITrace instance used to log the error messages/exception
callingClass - Classname string of the calling class.
callingMethod - Methodname string of the calling method.

logResourceException

public void logResourceException(java.lang.String prefixLine,
                                 java.lang.Throwable th,
                                 Trace trace,
                                 java.lang.String callingClass,
                                 java.lang.String callingMethod)
Utility method to log an exception to the ActiveSync log, as well as an ITrace instance.

Parameters:
prefixLine - (optional) Message to write before the error messages/stack trace.
th - Throwable being logged
trace - (optional) Trace instance used to log the error messages/exception
callingClass - Classname string of the calling class.
callingMethod - Methodname string of the calling method.

logResourceException

public void logResourceException(java.lang.String prefixLine,
                                 java.lang.Throwable th,
                                 Trace trace,
                                 java.lang.String callingMethod)
Utility method to log an exception to the ActiveSync log, as well as an ITrace instance.

Parameters:
prefixLine - (optional) Message to write before the error messages/stack trace.
th - Throwable being logged
trace - (optional) Trace instance used to log the error messages/exception
callingMethod - Methodname string of the calling method.

useLegacyEventGeneration

public boolean useLegacyEventGeneration()

getLogFileFullPath

public java.lang.String getLogFileFullPath()
Deprecated. Make sure the caller can handle null. This is here only to allow old adapters to compile.

Returns:
always returns null