org.exoplatform.wiki.utils
Class Utils

java.lang.Object
  extended by org.exoplatform.wiki.utils.Utils

public class Utils
extends Object


Field Summary
static String COMPARE_REVISION
           
static String DOT
           
static String PAGE
           
static String SLASH
           
static String SPACE
           
static String SPLIT_TEXT_OF_DRAFT_FOR_NEW_PAGE
           
static String VER_NAME
           
static String WIKI_RESOUCE_BUNDLE_NAME
           
 
Constructor Summary
Utils()
           
 
Method Summary
static long countSearchResult(WikiSearchData data)
           
static org.exoplatform.services.jcr.ext.common.SessionProvider createSystemProvider()
           
static String escapeIllegalCharacterInQuery(String query)
           
static HashMap<String,IDType> getACLForAdmins()
           
static Wiki[] getAllWikiSpace()
           
static List<NTVersion> getCurrentPageRevisions(Page wikipage)
           
static String getCurrentRepositoryWebDavUri()
           
static String getCurrentUser()
           
static String getDefaultRestBaseURI()
           
static String getDocumentURL(WikiContext wikiContext)
           
static String getEmailUser(String userName)
           
static String getGroupIdByJcrPath(String jcrPath)
           
static NTVersion getLastRevisionOfPage(Page wikipage)
           
static List<String> getListOfUserEditingPage(String pageId)
          Get the list of user that're editing the wiki page
static Map<String,WikiPageHistory> getLogOfPage(String pageId)
          Get the editting log of wiki page
static Object getObject(String path, String type)
           
static Object getObjectFromParams(WikiPageParams param)
           
static String getPageNameForAddingPage()
           
static String getPermanlink(WikiPageParams params, boolean hasDowmainUrl)
          Get the permalink of current wiki page
With the current page param: type = "group" owner = "spaces/test_space" pageId = "test_page"
The permalink will be: http://int.exoplatform.org/portal/intranet/wiki/group/spaces/test_space/test_page
static String getPortalIdByJcrPath(String jcrPath)
           
static String getPortalName()
           
static String getPortalWikisPath()
           
static String getSpaceIdByJcrPath(String jcrPath)
           
static Stack<WikiPageParams> getStackParams(PageImpl page)
           
static String getURL(String url, String verName)
           
static String getUserIdByJcrPath(String jcrPath)
           
static Wiki getWiki(WikiPageParams params)
           
static WikiPageParams getWikiPageParams(Page page)
           
static String getWikiResourceBundle(String key, ClassLoader cl)
          Get resource bundle from given resource file
static Collection<Wiki> getWikisByType(WikiType wikiType)
           
static String getWikiType(String jcrPath)
           
static boolean hasPermission(org.exoplatform.services.jcr.access.AccessControlList acl, String[] permission, org.exoplatform.services.security.Identity user)
          Has permission.
static boolean isDescendantPage(PageImpl page, PageImpl parentPage)
           
static boolean isWikiAvailable(String wikiType, String wikiOwner)
           
static void logEditPageTime(WikiPageParams pageParams, String username, long updateTime, String draftName, boolean isNewPage)
          Log the edit page action of user
static void sendMailOnChangeContent(AttachmentImpl content)
           
static String validateWikiOwner(String wikiType, String wikiOwner)
          Validate wikiOwner depending on wikiType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLASH

public static final String SLASH
See Also:
Constant Field Values

DOT

public static final String DOT
See Also:
Constant Field Values

SPACE

public static final String SPACE
See Also:
Constant Field Values

PAGE

public static final String PAGE
See Also:
Constant Field Values

COMPARE_REVISION

public static final String COMPARE_REVISION
See Also:
Constant Field Values

VER_NAME

public static final String VER_NAME
See Also:
Constant Field Values

WIKI_RESOUCE_BUNDLE_NAME

public static final String WIKI_RESOUCE_BUNDLE_NAME
See Also:
Constant Field Values

SPLIT_TEXT_OF_DRAFT_FOR_NEW_PAGE

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

Utils

public Utils()
Method Detail

escapeIllegalCharacterInQuery

public static String escapeIllegalCharacterInQuery(String query)

getPortalName

public static String getPortalName()

getWikiResourceBundle

public static String getWikiResourceBundle(String key,
                                           ClassLoader cl)
Get resource bundle from given resource file

Parameters:
key - key
cl - ClassLoader to load resource file
Returns:
The value of key in resource bundle

logEditPageTime

public static void logEditPageTime(WikiPageParams pageParams,
                                   String username,
                                   long updateTime,
                                   String draftName,
                                   boolean isNewPage)
Log the edit page action of user

Parameters:
pageParams - The page that has been editing
username - The name of user that editing wiki page
updateTime - The time that this page is edited
draftName - The name of draft for this edit
isNewPage - Is the wiki page a draft or not

getListOfUserEditingPage

public static List<String> getListOfUserEditingPage(String pageId)
Get the list of user that're editing the wiki page

Parameters:
pageId - The id of wiki page
Returns:
The list of user that're editing this wiki page

getPermanlink

public static String getPermanlink(WikiPageParams params,
                                   boolean hasDowmainUrl)
                            throws Exception
Get the permalink of current wiki page
  • type = "group"
  • owner = "spaces/test_space"
  • pageId = "test_page"

  • http://int.exoplatform.org/portal/intranet/wiki/group/spaces/test_space/test_page

  • Returns:
    The permalink of current wiki page
    Throws:
    Exception

    getPageNameForAddingPage

    public static String getPageNameForAddingPage()

    getLogOfPage

    public static Map<String,WikiPageHistory> getLogOfPage(String pageId)
    Get the editting log of wiki page

    Parameters:
    pageId - The id of wiki page to get log
    Returns:
    The editting log of wiki pgae

    getPortalWikisPath

    public static String getPortalWikisPath()

    getSpaceIdByJcrPath

    public static String getSpaceIdByJcrPath(String jcrPath)
                                      throws IllegalArgumentException
    Returns:
  • portal name if wiki is portal type
  • groupid if wiki is group type
  • userid if wiki is personal type
  • Throws:
    IllegalArgumentException - if jcr path is not of a wiki page node.

    getGroupIdByJcrPath

    public static String getGroupIdByJcrPath(String jcrPath)
                                      throws IllegalArgumentException
    Parameters:
    jcrPath - follows the format /Groups/$GROUP/ApplicationData/eXoWiki/[wikipage]
    Returns:
    $GROUP of jcrPath
    Throws:
    IllegalArgumentException - if jcrPath is not as expected.

    getCurrentPageRevisions

    public static List<NTVersion> getCurrentPageRevisions(Page wikipage)
                                                   throws Exception
    Throws:
    Exception

    getUserIdByJcrPath

    public static String getUserIdByJcrPath(String jcrPath)
                                     throws IllegalArgumentException
    Parameters:
    jcrPath - follows the format /Users/$USERNAME/ApplicationData/eXoWiki/...
    Returns:
    $USERNAME of jcrPath
    Throws:
    IllegalArgumentException - if jcrPath is not as expected.

    getPortalIdByJcrPath

    public static String getPortalIdByJcrPath(String jcrPath)
                                       throws IllegalArgumentException
    Parameters:
    jcrPath - follows the format /exo:applications/eXoWiki/wikis/$PORTAL/...
    Returns:
    $PORTAL of jcrPath
    Throws:
    IllegalArgumentException - if jcrPath is not as expected.

    getWikiType

    public static String getWikiType(String jcrPath)
                              throws IllegalArgumentException
    Parameters:
    jcrPath - absolute jcr path of page node.
    Returns:
    type of wiki page.
    Throws:
    IllegalArgumentException

    validateWikiOwner

    public static String validateWikiOwner(String wikiType,
                                           String wikiOwner)
    Validate wikiOwner depending on wikiType.
    If wikiType is PortalConfig.GROUP_TYPE, wikiOwner is checked to removed slashes at the begin and the end point of it.

    Parameters:
    wikiType -
    wikiOwner -
    Returns:
    wikiOwner after validated.

    getDefaultRestBaseURI

    public static String getDefaultRestBaseURI()

    getCurrentRepositoryWebDavUri

    public static String getCurrentRepositoryWebDavUri()

    getDocumentURL

    public static String getDocumentURL(WikiContext wikiContext)

    getCurrentUser

    public static String getCurrentUser()

    getWikisByType

    public static Collection<Wiki> getWikisByType(WikiType wikiType)

    getWiki

    public static Wiki getWiki(WikiPageParams params)

    getAllWikiSpace

    public static Wiki[] getAllWikiSpace()

    isDescendantPage

    public static boolean isDescendantPage(PageImpl page,
                                           PageImpl parentPage)
                                    throws Exception
    Throws:
    Exception

    getObject

    public static Object getObject(String path,
                                   String type)
                            throws Exception
    Throws:
    Exception

    getLastRevisionOfPage

    public static NTVersion getLastRevisionOfPage(Page wikipage)
                                           throws Exception
    Throws:
    Exception

    getObjectFromParams

    public static Object getObjectFromParams(WikiPageParams param)
                                      throws Exception
    Throws:
    Exception

    getStackParams

    public static Stack<WikiPageParams> getStackParams(PageImpl page)
                                                throws Exception
    Throws:
    Exception

    getWikiPageParams

    public static WikiPageParams getWikiPageParams(Page page)

    sendMailOnChangeContent

    public static void sendMailOnChangeContent(AttachmentImpl content)
                                        throws Exception
    Throws:
    Exception

    getEmailUser

    public static String getEmailUser(String userName)
                               throws Exception
    Throws:
    Exception

    isWikiAvailable

    public static boolean isWikiAvailable(String wikiType,
                                          String wikiOwner)

    getACLForAdmins

    public static HashMap<String,IDType> getACLForAdmins()

    hasPermission

    public static boolean hasPermission(org.exoplatform.services.jcr.access.AccessControlList acl,
                                        String[] permission,
                                        org.exoplatform.services.security.Identity user)
    Has permission.

    Parameters:
    acl - access control list
    permission - permissions array
    user - user Identity
    Returns:
    boolean

    getURL

    public static String getURL(String url,
                                String verName)

    createSystemProvider

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

    countSearchResult

    public static long countSearchResult(WikiSearchData data)
                                  throws Exception
    Throws:
    Exception


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