org.exoplatform.forum.common
Class CommonUtils

java.lang.Object
  extended by org.exoplatform.forum.common.CommonUtils

public class CommonUtils
extends Object

Version:
$Revision$

Field Summary
static String AMP
           
static String AMP_HEX
           
static String AMP_NUMBER
           
static String AMP_SPACE
           
static String ASTERISK_STR
           
static String COLON
           
static String COMMA
           
static String DOMAIN_KEY
           
static String EMPTY_STR
           
static String FROM_KEY
           
static String GREATER_THAN
           
static String LESS_THAN
           
static String PERCENT_STR
           
static String QUOT
           
static String SEMICOLON
           
static String SLASH
           
static String SPACE
           
 
Constructor Summary
CommonUtils()
           
 
Method Summary
static String convertCodeHTML(String s)
           
static org.exoplatform.services.jcr.ext.common.SessionProvider createSystemProvider()
           
static String decodeSpecialCharToHTMLnumber(String s)
           
static String decodeSpecialCharToHTMLnumber(String s, List<String> lIgnore)
           
static String decodeSpecialCharToHTMLnumberIgnore(String str)
          Decode special chars to HTML number ignore char Less than '<' and Greater than '>'
static String encodeSpecialCharInContent(String s)
          Encode special character, use for input content of object (only apply for input by FCKEditer).
static String encodeSpecialCharInSearchTerm(String s)
          Encode special character, use for input search
static String encodeSpecialCharInTitle(String s)
          Encode special character, use for input title or name of the object.
static String encodeSpecialCharToHTMLnumber(String s, String charIgnore, boolean isTitle)
          Encode special character to html number.
static String generateCheckSum(byte[] b)
          Generates checksum for files, and get a file ending in .sha1 This task can also be used to perform checksum verifications.
static
<T> T
getComponent(Class<T> type)
           
static String getDomainURL()
           
static org.exoplatform.container.ExoContainer getExoContainer(org.quartz.JobExecutionContext context)
          Get a Component from the current container context
static Calendar getGreenwichMeanTime()
          Get current time GMT/Zulu or UTC,(zone time is 0+GMT)
static String getImageUrl(String imagePath)
           
static String getRSSLink(String appType, String portalName, String objectId)
           
static String getUserRSSLink(String apptype, String userId)
           
static File getXMLFile(ByteArrayOutputStream bos, String appName, String objectType, Date createDate, String fileName)
           
static boolean hasSpecialCharacter(String input)
          To check the input content has special characters or not.
static boolean isContainSpecialCharacter(String s)
           
static boolean isEmpty(String s)
          Check string is null or empty
static boolean isEmpty(String[] array)
          check string array is whether empty or not
static String makeNotificationSender(String from)
          This function will change email address in 'from' field by address of mail service which is configured as system property : gatein.email.smtp.from or mail.from.
static String processBBCode(String s)
           
static String processSearchCondition(String searchCondition)
          Process the search condition correspond to each context
static String removeSpecialCharacterForSearch(String input)
          Filter all invalid character (anything except word, number, space and search wildcard) from search conditional.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMA

public static final String COMMA
See Also:
Constant Field Values

SLASH

public static final String SLASH
See Also:
Constant Field Values

EMPTY_STR

public static final String EMPTY_STR
See Also:
Constant Field Values

COLON

public static final String COLON
See Also:
Constant Field Values

SEMICOLON

public static final String SEMICOLON
See Also:
Constant Field Values

SPACE

public static final String SPACE
See Also:
Constant Field Values

ASTERISK_STR

public static final String ASTERISK_STR
See Also:
Constant Field Values

PERCENT_STR

public static final String PERCENT_STR
See Also:
Constant Field Values

AMP_NUMBER

public static final String AMP_NUMBER
See Also:
Constant Field Values

LESS_THAN

public static final String LESS_THAN
See Also:
Constant Field Values

GREATER_THAN

public static final String GREATER_THAN
See Also:
Constant Field Values

QUOT

public static final String QUOT
See Also:
Constant Field Values

AMP_SPACE

public static final String AMP_SPACE
See Also:
Constant Field Values

AMP_HEX

public static final String AMP_HEX
See Also:
Constant Field Values

AMP

public static final String AMP
See Also:
Constant Field Values

DOMAIN_KEY

public static final String DOMAIN_KEY
See Also:
Constant Field Values

FROM_KEY

public static final String FROM_KEY
See Also:
Constant Field Values
Constructor Detail

CommonUtils

public CommonUtils()
Method Detail

generateCheckSum

public static String generateCheckSum(byte[] b)
                               throws Exception
Generates checksum for files, and get a file ending in .sha1 This task can also be used to perform checksum verifications.

Parameters:
b -
Returns:
Throws:
Exception

getXMLFile

public static File getXMLFile(ByteArrayOutputStream bos,
                              String appName,
                              String objectType,
                              Date createDate,
                              String fileName)
                       throws Exception
Throws:
Exception

getImageUrl

public static String getImageUrl(String imagePath)
                          throws Exception
Throws:
Exception

convertCodeHTML

public static String convertCodeHTML(String s)

makeNotificationSender

public static String makeNotificationSender(String from)
This function will change email address in 'from' field by address of mail service which is configured as system property : gatein.email.smtp.from or mail.from.
That ensures that 'emailAddress' part of 'from' field in a message object is always the same identity with authentication of smtp configuration.
It's because of 2 reasons:
  • we don't want notification message to show email address of user as sender. Instead, we use mail service of kernel.
  • Almost authenticated smtp systems do not allow to separate email address in from field of message from smtp authentication (for now, GMX, MS exchange deny, Gmail efforts to modify the such value)
  • Parameters:
    from -
    Returns:
    null if can not find suitable sender.

    getDomainURL

    public static String getDomainURL()
    Returns:

    processBBCode

    public static String processBBCode(String s)
    Parameters:
    s -
    Returns:

    getExoContainer

    public static org.exoplatform.container.ExoContainer getExoContainer(org.quartz.JobExecutionContext context)
    Get a Component from the current container context

    Type Parameters:
    T - type of the expected component
    Parameters:
    type - key for the component
    Returns:

    getRSSLink

    public static String getRSSLink(String appType,
                                    String portalName,
                                    String objectId)

    getUserRSSLink

    public static String getUserRSSLink(String apptype,
                                        String userId)

    isEmpty

    public static boolean isEmpty(String s)
    Check string is null or empty

    Parameters:
    String - s
    Returns:
    boolean

    isEmpty

    public static boolean isEmpty(String[] array)
    check string array is whether empty or not

    Parameters:
    array -
    Returns:
    false if at least one element of array is not empty, true in the opposite case.

    removeSpecialCharacterForSearch

    public static String removeSpecialCharacterForSearch(String input)
    Filter all invalid character (anything except word, number, space and search wildcard) from search conditional.

    Parameters:
    input - the input string
    Returns:
    String after remove all special characters
    Since:
    4.0.x

    hasSpecialCharacter

    public static boolean hasSpecialCharacter(String input)
    To check the input content has special characters or not.

    Parameters:
    input -
    Returns:

    processSearchCondition

    public static String processSearchCondition(String searchCondition)
    Process the search condition correspond to each context

    Parameters:
    searchCondition - the search condition

    encodeSpecialCharInSearchTerm

    public static String encodeSpecialCharInSearchTerm(String s)
    Encode special character, use for input search

    Parameters:
    String - s, the string input
    Returns:
    String

    encodeSpecialCharInTitle

    public static String encodeSpecialCharInTitle(String s)
    Encode special character, use for input title or name of the object.

    Parameters:
    String - s, the string input
    Returns:
    String

    encodeSpecialCharInContent

    public static String encodeSpecialCharInContent(String s)
    Encode special character, use for input content of object (only apply for input by FCKEditer).

    Parameters:
    String - s, the string input
    Returns:
    String

    isContainSpecialCharacter

    public static boolean isContainSpecialCharacter(String s)

    encodeSpecialCharToHTMLnumber

    public static String encodeSpecialCharToHTMLnumber(String s,
                                                       String charIgnore,
                                                       boolean isTitle)
    Encode special character to html number. Ex: '/' --> /

    Parameters:
    String - s, the string input
    String - charIgnore, the string content ignore some special character can not encode.
    boolean - isTitle, the boolean for check convert is title or not.
    Returns:
    String

    decodeSpecialCharToHTMLnumber

    public static String decodeSpecialCharToHTMLnumber(String s,
                                                       List<String> lIgnore)

    decodeSpecialCharToHTMLnumber

    public static String decodeSpecialCharToHTMLnumber(String s)

    decodeSpecialCharToHTMLnumberIgnore

    public static String decodeSpecialCharToHTMLnumberIgnore(String str)
    Decode special chars to HTML number ignore char Less than '<' and Greater than '>'

    Parameters:
    str -
    Returns:

    getGreenwichMeanTime

    public static Calendar getGreenwichMeanTime()
    Get current time GMT/Zulu or UTC,(zone time is 0+GMT)

    Returns:
    Calendar

    getComponent

    public static <T> T getComponent(Class<T> type)

    createSystemProvider

    public static org.exoplatform.services.jcr.ext.common.SessionProvider createSystemProvider()


    Copyright © 2003-2013 eXo Platform SAS. All Rights Reserved.