com.funambol.email.util
Class Utility

java.lang.Object
  extended by com.funambol.email.util.Utility

public class Utility
extends java.lang.Object

Utility class


Field Summary
protected static com.funambol.framework.logging.FunambolLogger log
           
 
Constructor Summary
Utility()
           
 
Method Summary
static boolean booleanFromString(java.lang.String value)
          convert the db value 'y' in the boolean "true"
static java.lang.String booleanToString(boolean value)
          convert the db value 'y' in the boolean "true"
static java.lang.String convertNokiaToDefault(java.lang.String oldfolder, DefaultFolder df)
          converts the Nokia folder name in the defaul folder name
static java.lang.String convertOutboxIDToSentID(java.lang.String oldID)
          converts the id of an email in the outbox folder with an ID for and email in the sent folder
static java.lang.String convertSentIDToOutboxID(java.lang.String oldID)
          converts the id of an email in the sent folder with an ID for and email in the outbox folder
static java.lang.String createFolderGUID(java.lang.String FID, java.lang.String FMID)
          sets the FOLDER GUID = FID + Def.SEPARATOR + FMID
static java.lang.String createIMAPGUID(java.lang.String FID, java.lang.String FMID, java.lang.String UIDV)
          sets the EMAIL GUID = FID + Def.SEPARATOR + FMID + Def.SEPARATOR + UIDV
static java.lang.String createPOPGUID(java.lang.String FID, java.lang.String FMID)
          sets the EMAIL GUID = FID + Def.SEPARATOR + FMID
static boolean d1Afterd2(java.util.Date d1, java.util.Date d2)
          compare 2 date
static boolean d1Befored2(java.util.Date d1, java.util.Date d2)
          compare 2 date
static java.lang.String decode(java.lang.String text, java.lang.String encodeType)
          Decode the given text considering it encoded with the given encode type.
static boolean defaultFolderChecker(DefaultFolder df, java.lang.String fullPath)
          the method checks if the folder is a default folder On Exchange server the Default folder are: - /Inbox - /Outbox - /Sent - /Draft - /Trash It's depend of the language (see configuration panel)
static int getComparisonTerm(java.lang.String timeFilterClause)
           
static java.lang.String getContentFromSyncItem(com.funambol.framework.engine.SyncItem syncItem)
          get content from a SyncItem
static java.lang.String getDefaultFolderId(DefaultFolder df, java.lang.String fullPath)
          the method checks if the folder is a default folder On Exchange server the Default folder are: - /Inbox - /Outbox - /Sent - /Draft - /Trash It's depend of the language (see configuration panel)
static FlagProperties getFlags(Email email)
          returns an object with the flags: read, replied , flagged, forwarded.
static FlagProperties getFlags(javax.mail.Message msg)
          returns an object with the flags: read, replied , flagged, forwarded.
static java.lang.String getFolderCreationDate()
          set creation date of a folder
static java.lang.String getFolderNameFromFullpath(java.lang.String fullpath)
           
static java.lang.String getFolderRole(java.lang.String folderName, DefaultFolder df)
          set folder role using the name
static java.lang.String getHeaderCharset(javax.mail.Message message)
          Returns the charset in the ContentType It can be used when the standard method
ContentType ct = new ContentType(part.getContentType());
String specifiedCharset = ct.getParameter("charset");
doesn't work and return null
static java.lang.String getHeaderEncoding(javax.mail.Message message)
           
static java.lang.String getHeaderMessageID(javax.mail.Message message)
           
static java.lang.String getHeaderMessageID(java.lang.String msg)
          get the message id from the email that the client try to send format: Message-ID: O/AAAAAK8wAAACAAAAggAAAA==@192.168.55.101
static java.util.Date getHeaderReceived(javax.mail.Message message)
           
static java.lang.String getHeaderReceived(javax.mail.Message message, java.util.Locale loc)
          Date : Thu Oct 06 09:46:47 CEST 2005 Returns a received date in UTC format
static java.lang.String getHeaderSender(javax.mail.Message message)
           
static java.lang.String getHeaderSubject(javax.mail.Message message)
           
static java.lang.String getHeaderSyncLabel(javax.mail.Message message)
           
static java.lang.String getKeyPart(java.lang.String key, int position)
          get the ID after the specified position 1 it returns the FID 2 it returns the FMID 3 it returns the UIDV
static java.lang.String[] getKeyParts(com.funambol.framework.engine.SyncItem syncItem)
          the Funambol client send id in format: I/1234 the mobile phone can send the LUID not in the format : 1234
static long getLastCrc(javax.mail.Message msg, java.lang.String messageid, java.lang.String date)
          Compute CRC-32 checksum value for the specified Message
static long getLastCrc(java.lang.String read, java.lang.String messageid, java.lang.String date)
          Compute CRC-32 checksum value for the specified Message
static java.lang.String getMailServerIP(java.lang.String server)
          used for debug purpose in the MailServer connection
static javax.mail.Message[] getMessages(javax.mail.Folder folder, int maxNum)
          get the Messages from the Mail Server
static java.lang.String getParentFullpathFromFullpath(java.lang.String fullpath)
          gets the parent path of a folder using the full folder path
static java.lang.String getPassword(java.lang.String username, java.lang.String credentials)
          credantials format: "username:passowrd"
static boolean hasHeaderFrom(javax.mail.Message message)
          check if there is the Form field in the message
static int integerFromString(java.lang.String value)
          convert a String db value in the integer value
static ItemFolder[] mergeArray(ItemFolder[] i, ItemFolder[] o, ItemFolder[] d, ItemFolder[] s, ItemFolder[] t)
          merge arrays
static java.lang.String[] mergeArray(java.lang.String[] i, java.lang.String[] o, java.lang.String[] d, java.lang.String[] s, java.lang.String[] t)
          merge arrays
static SyncItemInfo[] mergeArray(SyncItemInfo[] i, SyncItemInfo[] o, SyncItemInfo[] d, SyncItemInfo[] s, SyncItemInfo[] t)
          merge arrays
static java.util.HashMap mergeHashMap(java.util.HashMap hmi, java.util.HashMap hmo, java.util.HashMap hms, java.util.HashMap hmd, java.util.HashMap hmt)
           
static boolean needsFlagOptimization(char status, java.lang.String FID, EmailFilter filter)
          Checks if it's possible to optimize the syncml message dimension.
static void printMessage(javax.mail.Message msg)
          for testing purpose
static void printMessageInFile(javax.mail.Message msg, java.lang.String fileName)
          for testing purpose default file name "D:\\development\\funambol_v6\\v6\\modules\\emailconnector\\src\\java\\com\\funambol\\email\\test\\A.txt";
static void printMessageInFile(java.lang.String s, java.lang.String fileName)
          for testing purpose
static java.lang.String readFile(java.lang.String filename)
          utility method for the test classes
static int setMinutes(int seconds)
          Used in the ConsoleDAO.
static int setSeconds(int minutes)
          Used in the ConsoleManager.
static java.lang.String StringFromMessage(javax.mail.Message msg, java.lang.String encodingType)
          convert Message in a String (RFC2822)
static javax.mail.Message StringToMessage(javax.mail.Session session, java.lang.String stream)
          convert a String (RFC2822) in the Message
static java.lang.String UtcFromDate(java.util.Date origDate)
           
static java.util.Date UtcToDate(java.lang.String utc)
          convert the UTC string in a Date
static java.sql.Timestamp UtcToTimestamp(java.lang.String utc)
          convert the UTC string in a Timestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static com.funambol.framework.logging.FunambolLogger log
Constructor Detail

Utility

public Utility()
Method Detail

getMessages

public static javax.mail.Message[] getMessages(javax.mail.Folder folder,
                                               int maxNum)
                                        throws javax.mail.MessagingException
get the Messages from the Mail Server

Parameters:
folder - The mail folder name.
maxNum - Maximum number of messages to retrieve.
Returns:
Array of messages.
Throws:
javax.mail.MessagingException

booleanFromString

public static boolean booleanFromString(java.lang.String value)
convert the db value 'y' in the boolean "true"


booleanToString

public static java.lang.String booleanToString(boolean value)
convert the db value 'y' in the boolean "true"


integerFromString

public static int integerFromString(java.lang.String value)
convert a String db value in the integer value


getPassword

public static java.lang.String getPassword(java.lang.String username,
                                           java.lang.String credentials)
credantials format: "username:passowrd"

Parameters:
username - String
credentials - String
Returns:
password String

convertNokiaToDefault

public static java.lang.String convertNokiaToDefault(java.lang.String oldfolder,
                                                     DefaultFolder df)
converts the Nokia folder name in the defaul folder name

Parameters:
oldfolder - folder name in the Server String
df - DefaultFolder
Returns:
newfolder folder name in the Nokia device String

convertSentIDToOutboxID

public static java.lang.String convertSentIDToOutboxID(java.lang.String oldID)
converts the id of an email in the sent folder with an ID for and email in the outbox folder

Parameters:
oldID - id that starts with S
Returns:
newID id that starts with O

convertOutboxIDToSentID

public static java.lang.String convertOutboxIDToSentID(java.lang.String oldID)
converts the id of an email in the outbox folder with an ID for and email in the sent folder

Parameters:
oldID - id that starts with O
Returns:
newID id that starts with S

getContentFromSyncItem

public static java.lang.String getContentFromSyncItem(com.funambol.framework.engine.SyncItem syncItem)
                                               throws EntityException
get content from a SyncItem

Parameters:
syncItem - SyncItem
Returns:
content of the SyncItem String
Throws:
EntityException

getHeaderMessageID

public static java.lang.String getHeaderMessageID(javax.mail.Message message)
Parameters:
message - Message
Returns:
String

getHeaderSubject

public static java.lang.String getHeaderSubject(javax.mail.Message message)
Parameters:
message - Message
Returns:
String

hasHeaderFrom

public static boolean hasHeaderFrom(javax.mail.Message message)
check if there is the Form field in the message

Parameters:
message - Message
Returns:
String

getHeaderSender

public static java.lang.String getHeaderSender(javax.mail.Message message)
Parameters:
message - Message
Returns:
String

getHeaderEncoding

public static java.lang.String getHeaderEncoding(javax.mail.Message message)
Parameters:
message - Message
Returns:
String

getHeaderMessageID

public static java.lang.String getHeaderMessageID(java.lang.String msg)
get the message id from the email that the client try to send format: Message-ID: O/AAAAAK8wAAACAAAAggAAAA==@192.168.55.101

Parameters:
msg - String
Returns:
String

getHeaderSyncLabel

public static java.lang.String getHeaderSyncLabel(javax.mail.Message message)
Parameters:
message - Message
Returns:
String

getHeaderCharset

public static java.lang.String getHeaderCharset(javax.mail.Message message)
                                         throws EntityException
Returns the charset in the ContentType It can be used when the standard method
ContentType ct = new ContentType(part.getContentType());
String specifiedCharset = ct.getParameter("charset");
doesn't work and return null

Parameters:
message - Message
Returns:
charset String
Throws:
EntityException

getHeaderReceived

public static java.lang.String getHeaderReceived(javax.mail.Message message,
                                                 java.util.Locale loc)
Date : Thu Oct 06 09:46:47 CEST 2005 Returns a received date in UTC format

Parameters:
message - Message
loc - Locale
Returns:
String

getHeaderReceived

public static java.util.Date getHeaderReceived(javax.mail.Message message)
Parameters:
message - Message
Returns:
String

defaultFolderChecker

public static boolean defaultFolderChecker(DefaultFolder df,
                                           java.lang.String fullPath)
                                    throws EntityException
the method checks if the folder is a default folder On Exchange server the Default folder are: - /Inbox - /Outbox - /Sent - /Draft - /Trash It's depend of the language (see configuration panel)

Parameters:
df - DefaultFolder
fullPath - String
Returns:
boolean
Throws:
EntityException

getDefaultFolderId

public static java.lang.String getDefaultFolderId(DefaultFolder df,
                                                  java.lang.String fullPath)
                                           throws EntityException
the method checks if the folder is a default folder On Exchange server the Default folder are: - /Inbox - /Outbox - /Sent - /Draft - /Trash It's depend of the language (see configuration panel)

Parameters:
df - DefaultFolder
fullPath - String
Returns:
folder id String
Throws:
EntityException

getFolderNameFromFullpath

public static java.lang.String getFolderNameFromFullpath(java.lang.String fullpath)
Parameters:
fullpath - String
Returns:
String

getFolderRole

public static java.lang.String getFolderRole(java.lang.String folderName,
                                             DefaultFolder df)
set folder role using the name

Parameters:
folderName - String
Returns:
folder role String

getFolderCreationDate

public static java.lang.String getFolderCreationDate()
set creation date of a folder

Returns:
UTC creation date String

getParentFullpathFromFullpath

public static java.lang.String getParentFullpathFromFullpath(java.lang.String fullpath)
gets the parent path of a folder using the full folder path

Parameters:
fullpath - String
Returns:
String

getKeyPart

public static java.lang.String getKeyPart(java.lang.String key,
                                          int position)
get the ID after the specified position 1 it returns the FID 2 it returns the FMID 3 it returns the UIDV

Parameters:
key - String
Returns:
id (it depends on the separator type)

UtcToTimestamp

public static java.sql.Timestamp UtcToTimestamp(java.lang.String utc)
convert the UTC string in a Timestamp

Parameters:
utc - String
Returns:
Timestamp

UtcToDate

public static java.util.Date UtcToDate(java.lang.String utc)
convert the UTC string in a Date

Parameters:
utc - String
Returns:
Date

StringFromMessage

public static java.lang.String StringFromMessage(javax.mail.Message msg,
                                                 java.lang.String encodingType)
                                          throws javax.mail.MessagingException
convert Message in a String (RFC2822)

Parameters:
msg - Message
Returns:
String
Throws:
javax.mail.MessagingException

StringToMessage

public static javax.mail.Message StringToMessage(javax.mail.Session session,
                                                 java.lang.String stream)
                                          throws javax.mail.MessagingException
convert a String (RFC2822) in the Message

Parameters:
session -
stream -
Returns:
Converted message
Throws:
javax.mail.MessagingException

mergeArray

public static java.lang.String[] mergeArray(java.lang.String[] i,
                                            java.lang.String[] o,
                                            java.lang.String[] d,
                                            java.lang.String[] s,
                                            java.lang.String[] t)
merge arrays

Parameters:
i - CrcSyncItemInfo[]
o - CrcSyncItemInfo[]
d - CrcSyncItemInfo[]
s - CrcSyncItemInfo[]
t - CrcSyncItemInfo[]
Returns:
CrcSyncItemInfo[]

mergeHashMap

public static java.util.HashMap mergeHashMap(java.util.HashMap hmi,
                                             java.util.HashMap hmo,
                                             java.util.HashMap hms,
                                             java.util.HashMap hmd,
                                             java.util.HashMap hmt)

mergeArray

public static SyncItemInfo[] mergeArray(SyncItemInfo[] i,
                                        SyncItemInfo[] o,
                                        SyncItemInfo[] d,
                                        SyncItemInfo[] s,
                                        SyncItemInfo[] t)
merge arrays

Parameters:
i - CrcSyncItemInfo[]
o - CrcSyncItemInfo[]
d - CrcSyncItemInfo[]
s - CrcSyncItemInfo[]
t - CrcSyncItemInfo[]
Returns:
CrcSyncItemInfo[]

mergeArray

public static ItemFolder[] mergeArray(ItemFolder[] i,
                                      ItemFolder[] o,
                                      ItemFolder[] d,
                                      ItemFolder[] s,
                                      ItemFolder[] t)
merge arrays

Parameters:
i - CrcSyncItemInfo[]
o - CrcSyncItemInfo[]
d - CrcSyncItemInfo[]
s - CrcSyncItemInfo[]
t - CrcSyncItemInfo[]
Returns:
CrcSyncItemInfo[]

getLastCrc

public static long getLastCrc(javax.mail.Message msg,
                              java.lang.String messageid,
                              java.lang.String date)
Compute CRC-32 checksum value for the specified Message

Parameters:
msg - Message
Returns:
long

getLastCrc

public static long getLastCrc(java.lang.String read,
                              java.lang.String messageid,
                              java.lang.String date)
Compute CRC-32 checksum value for the specified Message

Parameters:
msg - Message
Returns:
long

getKeyParts

public static java.lang.String[] getKeyParts(com.funambol.framework.engine.SyncItem syncItem)
the Funambol client send id in format: I/1234 the mobile phone can send the LUID not in the format : 1234

Parameters:
syncItem - SyncItem
Returns:
FID, FMID and UIDV in an array String[]

createIMAPGUID

public static java.lang.String createIMAPGUID(java.lang.String FID,
                                              java.lang.String FMID,
                                              java.lang.String UIDV)
sets the EMAIL GUID = FID + Def.SEPARATOR + FMID + Def.SEPARATOR + UIDV

Parameters:
FID - folder id String
FMID - mail id in the folder String
UIDV - folder validity String
Returns:
String

createPOPGUID

public static java.lang.String createPOPGUID(java.lang.String FID,
                                             java.lang.String FMID)
sets the EMAIL GUID = FID + Def.SEPARATOR + FMID

Parameters:
FID - folder id String
FMID - mail id in the folder String
Returns:
String

createFolderGUID

public static java.lang.String createFolderGUID(java.lang.String FID,
                                                java.lang.String FMID)
sets the FOLDER GUID = FID + Def.SEPARATOR + FMID

Parameters:
FID - folder id String
FMID - mail id in the folder String
Returns:
String

getComparisonTerm

public static int getComparisonTerm(java.lang.String timeFilterClause)
Parameters:
timeFilterClause - String
Returns:
comparison term for time filter int

UtcFromDate

public static java.lang.String UtcFromDate(java.util.Date origDate)
Parameters:
origDate - Date
Returns:
String

decode

public static java.lang.String decode(java.lang.String text,
                                      java.lang.String encodeType)
                               throws javax.mail.MessagingException

Decode the given text considering it encoded with the given encode type.

Parameters:
text -
encodeType -
Returns:
the decoded text
Throws:
javax.mail.MessagingException

needsFlagOptimization

public static boolean needsFlagOptimization(char status,
                                            java.lang.String FID,
                                            EmailFilter filter)
Checks if it's possible to optimize the syncml message dimension. For instance: an email in the inbox with only the 'read' flag updated and already on the client if the we have a filter with a set ID we have to returns false. this should be the case that the client ask all the email.

Parameters:
status - status of the item; char
FID - parent id of the item: String
Returns:
true if it's possible to optimize the syncml dimension

getFlags

public static FlagProperties getFlags(Email email)
returns an object with the flags: read, replied , flagged, forwarded.

Parameters:
email - Email
Returns:
FlagProperties

getFlags

public static FlagProperties getFlags(javax.mail.Message msg)
returns an object with the flags: read, replied , flagged, forwarded.

Parameters:
email - Email
Returns:
FlagProperties

d1Afterd2

public static boolean d1Afterd2(java.util.Date d1,
                                java.util.Date d2)
compare 2 date

Parameters:
d1 -
d2 -
Returns:
true if d1 >= d2

d1Befored2

public static boolean d1Befored2(java.util.Date d1,
                                 java.util.Date d2)
compare 2 date

Parameters:
d1 -
d2 -
Returns:
true if d1 < d2

readFile

public static java.lang.String readFile(java.lang.String filename)
                                 throws java.lang.Exception
utility method for the test classes

Throws:
java.lang.Exception

printMessage

public static void printMessage(javax.mail.Message msg)
for testing purpose


printMessageInFile

public static void printMessageInFile(javax.mail.Message msg,
                                      java.lang.String fileName)
for testing purpose default file name "D:\\development\\funambol_v6\\v6\\modules\\emailconnector\\src\\java\\com\\funambol\\email\\test\\A.txt";


printMessageInFile

public static void printMessageInFile(java.lang.String s,
                                      java.lang.String fileName)
for testing purpose


setSeconds

public static int setSeconds(int minutes)
Used in the ConsoleManager. From the UI we get a value in the minute format but we have to set in the DB a second format


setMinutes

public static int setMinutes(int seconds)
Used in the ConsoleDAO. in the DB there is a value in second format and we have to show in the UI a minute format


getMailServerIP

public static java.lang.String getMailServerIP(java.lang.String server)
used for debug purpose in the MailServer connection



Copyright © 2005-2006 Funambol.