org.exoplatform.forum.common
Class CommonUtils

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

public class CommonUtils
extends Object

Version:
$Revision$
Author:
Patrice Lamarque

Field Summary
static String AMP
           
static String AMP_HEX
           
static String AMP_NUMBER
           
static String AMP_SPACE
           
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 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 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)
           
static
<T> T
getComponent(Class<T> type)
          Get a Component from the current container context
static String getDomainURL()
           
static org.exoplatform.container.ExoContainer getExoContainer(org.quartz.JobExecutionContext 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 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)
           
 
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

SLASH

public static final String SLASH

EMPTY_STR

public static final String EMPTY_STR

COLON

public static final String COLON

SEMICOLON

public static final String SEMICOLON

SPACE

public static final String SPACE

AMP_NUMBER

public static final String AMP_NUMBER

LESS_THAN

public static final String LESS_THAN

GREATER_THAN

public static final String GREATER_THAN

QUOT

public static final String QUOT

AMP_SPACE

public static final String AMP_SPACE

AMP_HEX

public static final String AMP_HEX

AMP

public static final String AMP

DOMAIN_KEY

public static final String DOMAIN_KEY

FROM_KEY

public static final String FROM_KEY
Constructor Detail

CommonUtils

public CommonUtils()
Method Detail

generateCheckSum

public static String generateCheckSum(byte[] b)
                               throws Exception
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()

    processBBCode

    public static String processBBCode(String s)

    getComponent

    public static <T> T getComponent(Class<T> type)
    Get a Component from the current container context

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

    getExoContainer

    public static org.exoplatform.container.ExoContainer getExoContainer(org.quartz.JobExecutionContext context)

    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.

    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

    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)

    getGreenwichMeanTime

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

    Returns:
    Calendar

    createSystemProvider

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


    Copyright © 2013 eXo Platform SAS. All Rights Reserved.