Class CommonUtils

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

public class CommonUtils extends Object
Version:
$Revision$
  • Field Details

  • Constructor Details

    • CommonUtils

      public CommonUtils()
  • Method Details

    • 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.
    • getURI

      public static String getURI(String url)
      Get the URI of full URL
      Parameters:
      url - The URL input
      Returns:
    • processBBCode

      public static String processBBCode(String s)
      Parameters:
      s -
      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:
      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
    • removeSpecialCharacterForUnifiedSearch

      public static String removeSpecialCharacterForUnifiedSearch(String input)
    • processUnifiedSearchSearchCondition

      public static String processUnifiedSearchSearchCondition(String input)
    • normalizeUnifiedSearchInput

      public static String normalizeUnifiedSearchInput(String input)
      Normalize Unified search input
      Parameters:
      input - The key search
      Returns:
    • 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
    • getExcerpt

      public static String getExcerpt(String str, String textQuery, int maxLength)
      Get excerpt of given string with start position is the first position of textQuery.
      Parameters:
      str - the give string
      textQuery - the text that we truncate at the first appear
      maxLength - max of string length
      Returns:
      the excerpt string
    • centerTrunc

      public static final String centerTrunc(String str, int middlePosition, int maxLength)
      Truncates large Strings showing the string around the specific middle position with the specific length.
      Parameters:
      str - the string to truncate
      middlePosition - the middle position we will show string around
      maxLength - the max length of string to show
      Returns:
      the truncated string
    • 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()