org.exoplatform.wiki.service.impl
Class WikiServiceImpl

java.lang.Object
  extended by org.exoplatform.wiki.service.impl.WikiServiceImpl
All Implemented Interfaces:
WikiService, org.picocontainer.Startable

public class WikiServiceImpl
extends Object
implements WikiService, org.picocontainer.Startable


Constructor Summary
WikiServiceImpl(org.exoplatform.container.configuration.ConfigurationManager configManager, JCRDataStorage jcrDataStorage, org.exoplatform.container.xml.InitParams initParams)
           
 
Method Summary
 void addComponentPlugin(org.exoplatform.container.component.ComponentPlugin plugin)
          register a PageWikiListener
 boolean addRelatedPage(WikiPageParams orginaryPageParams, WikiPageParams relatedPageParams)
           
 void addWikiTemplatePagePlugin(WikiTemplatePagePlugin plugin)
           
 DraftPage createDraftForExistPage(WikiPageParams param, String revision, long clientTime)
          Create a draft page for a wiki page which is specified by the wiki page param
 DraftPage createDraftForNewPage(WikiPageParams parentPageParam, long clientTime)
          Create a draft page for a new wiki page which parent is specified by the wiki page param
 Page createPage(String wikiType, String wikiOwner, String title, String parentId)
           
 Template createTemplatePage(String title, WikiPageParams params)
           
 void deleteDraftNewPage(String newDraftPageId)
           
 boolean deletePage(String wikiType, String wikiOwner, String pageId)
           
 void deleteTemplatePage(String wikiType, String wikiOwner, String templateId)
           
 Object findByPath(String path, String objectNodeType)
           
 InputStream getAttachmentAsStream(String path)
           
 List<BreadcrumbData> getBreadcumb(String wikiType, String wikiOwner, String pageId)
           
 String getDefaultWikiSyntaxId()
           
 DraftPage getDraft(String draftName)
          Get draft by draft name
 DraftPage getDraft(WikiPageParams param)
          Achieve a draft page for a wiki page which is specified by the wiki page param
 List<DraftPage> getDrafts(String username)
          Get collection of draft page belong to a user
 List<PageImpl> getDuplicatePages(PageImpl parentPage, Wiki targetWiki, List<PageImpl> resultList)
          Get a list of duppilcated page between all children pages of parentPage and targetWiki before execute moving page
 Page getExsitedOrNewDraftPageById(String wikiType, String wikiOwner, String pageId)
           
 PageImpl getHelpSyntaxPage(String syntaxId)
           
 DraftPage getLastestDraft()
          Get the draft that's created lastest
 Page getMetaDataPage(MetaDataPage metaPage)
           
 UserWiki getOrCreateUserWiki(String username)
          Get user wiki, and if it did not create yet then create new one
 Page getPageById(String wikiType, String wikiOwner, String pageId)
           
 Page getPageByRootPermission(String wikiType, String wikiOwner, String pageId)
           
 Page getPageByUUID(String uuid)
           
 List<PageWikiListener> getPageListeners()
           
 String getPageTitleOfAttachment(String path)
           
 String getPortalOwner()
          Get portal owner
 Page getRelatedPage(String wikiType, String wikiOwner, String pageId)
           
 List<Page> getRelatedPage(WikiPageParams pageParams)
           
 long getSaveDraftSequenceTime()
          Get the draft save sequence time from config file
 String getSpaceNameByGroupId(String groupId)
          Get space name by group Id
 Template getTemplatePage(WikiPageParams params, String templateId)
           
 Map<String,Template> getTemplates(WikiPageParams params)
           
 TemplateContainer getTemplatesContainer(WikiPageParams params)
           
 Wiki getWiki(String wikiType, String owner)
          Get a wiki that definds by wikiType and owner
 Wiki getWikiById(String wikiId)
          Get wiki by Id
 List<String> getWikiDefaultPermissions(String wikiType, String wikiOwner)
          Get wiki default permission
 String getWikiNameById(String wikiId)
          Get wiki name by wiki id
 Page getWikiPageByUUID(String uuid)
          Get wiki page by page UUID
 WikiPageParams getWikiPageParams(BreadcrumbData data)
           
 List<PermissionEntry> getWikiPermission(String wikiType, String wikiOwner)
           
 String getWikiWebappUri()
          Get the uri of wiki webapp
 boolean hasAdminPagePermission(String wikiType, String owner)
          Check if the current user has addmin permission on the page
 boolean hasAdminSpacePermission(String wikiType, String owner)
          Check if the current user has addmin permission on the space
 void initDefaultTemplatePage(String path)
           
 boolean isExisting(String wikiType, String wikiOwner, String pageId)
           
 boolean isHiddenSpace(String groupId)
          Check if the space is hidden or not
 boolean isSpaceMember(String spaceId, String userId)
          Checks whether a user is a space's member or not.
 void modifyTemplate(WikiPageParams params, Template template, String newTitle, String newDescription, String newContent, String newSyntaxId)
           
 boolean movePage(WikiPageParams currentLocationParams, WikiPageParams newLocationParams)
           
 void removeDraft(String draftName)
          Remove a draft page by draft name
 void removeDraft(WikiPageParams param)
          Remove a draft page for a wiki page which is specified by the wiki page param
 boolean removeRelatedPage(WikiPageParams orginaryPageParams, WikiPageParams relatedPageParams)
           
 boolean renamePage(String wikiType, String wikiOwner, String pageName, String newName, String newTitle)
           
 org.exoplatform.commons.utils.PageList<SearchResult> search(WikiSearchData data)
           
 org.exoplatform.commons.utils.PageList<SearchResult> searchContent(WikiSearchData data)
           
 List<TitleSearchResult> searchDataByTitle(WikiSearchData data)
           
 List<SearchResult> searchRenamedPage(String wikiType, String wikiOwner, String pageId)
           
 List<SpaceBean> searchSpaces(String keyword)
          Search for spaces by keyword
 List<TemplateSearchResult> searchTemplate(TemplateSearchData data)
           
 void setTemplatePagePlugin()
           
 void setWikiPermission(String wikiType, String wikiOwner, List<PermissionEntry> permissionEntries)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WikiServiceImpl

public WikiServiceImpl(org.exoplatform.container.configuration.ConfigurationManager configManager,
                       JCRDataStorage jcrDataStorage,
                       org.exoplatform.container.xml.InitParams initParams)
Method Detail

initDefaultTemplatePage

public void initDefaultTemplatePage(String path)
Specified by:
initDefaultTemplatePage in interface WikiService

createPage

public Page createPage(String wikiType,
                       String wikiOwner,
                       String title,
                       String parentId)
                throws Exception
Specified by:
createPage in interface WikiService
Throws:
Exception

isExisting

public boolean isExisting(String wikiType,
                          String wikiOwner,
                          String pageId)
                   throws Exception
Specified by:
isExisting in interface WikiService
Throws:
Exception

deletePage

public boolean deletePage(String wikiType,
                          String wikiOwner,
                          String pageId)
                   throws Exception
Specified by:
deletePage in interface WikiService
Throws:
Exception

deleteTemplatePage

public void deleteTemplatePage(String wikiType,
                               String wikiOwner,
                               String templateId)
                        throws Exception
Specified by:
deleteTemplatePage in interface WikiService
Throws:
Exception

deleteDraftNewPage

public void deleteDraftNewPage(String newDraftPageId)
                        throws Exception
Specified by:
deleteDraftNewPage in interface WikiService
Throws:
Exception

renamePage

public boolean renamePage(String wikiType,
                          String wikiOwner,
                          String pageName,
                          String newName,
                          String newTitle)
                   throws Exception
Specified by:
renamePage in interface WikiService
Throws:
Exception

movePage

public boolean movePage(WikiPageParams currentLocationParams,
                        WikiPageParams newLocationParams)
                 throws Exception
Specified by:
movePage in interface WikiService
Throws:
Exception

getWikiPermission

public List<PermissionEntry> getWikiPermission(String wikiType,
                                               String wikiOwner)
                                        throws Exception
Specified by:
getWikiPermission in interface WikiService
Throws:
Exception

setWikiPermission

public void setWikiPermission(String wikiType,
                              String wikiOwner,
                              List<PermissionEntry> permissionEntries)
                       throws Exception
Specified by:
setWikiPermission in interface WikiService
Throws:
Exception

getPageById

public Page getPageById(String wikiType,
                        String wikiOwner,
                        String pageId)
                 throws Exception
Specified by:
getPageById in interface WikiService
Throws:
Exception

getPageByRootPermission

public Page getPageByRootPermission(String wikiType,
                                    String wikiOwner,
                                    String pageId)
                             throws Exception
Specified by:
getPageByRootPermission in interface WikiService
Throws:
Exception

getRelatedPage

public Page getRelatedPage(String wikiType,
                           String wikiOwner,
                           String pageId)
                    throws Exception
Specified by:
getRelatedPage in interface WikiService
Throws:
Exception

getExsitedOrNewDraftPageById

public Page getExsitedOrNewDraftPageById(String wikiType,
                                         String wikiOwner,
                                         String pageId)
                                  throws Exception
Specified by:
getExsitedOrNewDraftPageById in interface WikiService
Throws:
Exception

getPageByUUID

public Page getPageByUUID(String uuid)
                   throws Exception
Specified by:
getPageByUUID in interface WikiService
Throws:
Exception

getTemplatePage

public Template getTemplatePage(WikiPageParams params,
                                String templateId)
                         throws Exception
Specified by:
getTemplatePage in interface WikiService
Throws:
Exception

getTemplates

public Map<String,Template> getTemplates(WikiPageParams params)
                                  throws Exception
Specified by:
getTemplates in interface WikiService
Throws:
Exception

getTemplatesContainer

public TemplateContainer getTemplatesContainer(WikiPageParams params)
                                        throws Exception
Specified by:
getTemplatesContainer in interface WikiService
Throws:
Exception

modifyTemplate

public void modifyTemplate(WikiPageParams params,
                           Template template,
                           String newTitle,
                           String newDescription,
                           String newContent,
                           String newSyntaxId)
                    throws Exception
Specified by:
modifyTemplate in interface WikiService
Throws:
Exception

searchContent

public org.exoplatform.commons.utils.PageList<SearchResult> searchContent(WikiSearchData data)
                                                                   throws Exception
Specified by:
searchContent in interface WikiService
Throws:
Exception

search

public org.exoplatform.commons.utils.PageList<SearchResult> search(WikiSearchData data)
                                                            throws Exception
Specified by:
search in interface WikiService
Throws:
Exception

searchTemplate

public List<TemplateSearchResult> searchTemplate(TemplateSearchData data)
                                          throws Exception
Specified by:
searchTemplate in interface WikiService
Throws:
Exception

searchRenamedPage

public List<SearchResult> searchRenamedPage(String wikiType,
                                            String wikiOwner,
                                            String pageId)
                                     throws Exception
Specified by:
searchRenamedPage in interface WikiService
Throws:
Exception

findByPath

public Object findByPath(String path,
                         String objectNodeType)
Specified by:
findByPath in interface WikiService

getPageTitleOfAttachment

public String getPageTitleOfAttachment(String path)
                                throws Exception
Specified by:
getPageTitleOfAttachment in interface WikiService
Throws:
Exception

getAttachmentAsStream

public InputStream getAttachmentAsStream(String path)
                                  throws Exception
Specified by:
getAttachmentAsStream in interface WikiService
Throws:
Exception

getBreadcumb

public List<BreadcrumbData> getBreadcumb(String wikiType,
                                         String wikiOwner,
                                         String pageId)
                                  throws Exception
Specified by:
getBreadcumb in interface WikiService
Throws:
Exception

getHelpSyntaxPage

public PageImpl getHelpSyntaxPage(String syntaxId)
                           throws Exception
Specified by:
getHelpSyntaxPage in interface WikiService
Throws:
Exception

getMetaDataPage

public Page getMetaDataPage(MetaDataPage metaPage)
                     throws Exception
Specified by:
getMetaDataPage in interface WikiService
Throws:
Exception

getDefaultWikiSyntaxId

public String getDefaultWikiSyntaxId()
Specified by:
getDefaultWikiSyntaxId in interface WikiService

getSaveDraftSequenceTime

public long getSaveDraftSequenceTime()
Description copied from interface: WikiService
Get the draft save sequence time from config file

Specified by:
getSaveDraftSequenceTime in interface WikiService
Returns:
The save draft sequence time

getWikiPageParams

public WikiPageParams getWikiPageParams(BreadcrumbData data)
Specified by:
getWikiPageParams in interface WikiService

searchDataByTitle

public List<TitleSearchResult> searchDataByTitle(WikiSearchData data)
                                          throws Exception
Specified by:
searchDataByTitle in interface WikiService
Throws:
Exception

getDuplicatePages

public List<PageImpl> getDuplicatePages(PageImpl parentPage,
                                        Wiki targetWiki,
                                        List<PageImpl> resultList)
                                 throws Exception
Description copied from interface: WikiService
Get a list of duppilcated page between all children pages of parentPage and targetWiki before execute moving page

Specified by:
getDuplicatePages in interface WikiService
Parameters:
parentPage - The page to check before execute moving
targetWiki - The target wiki to move page to
resultList - The list of duppicate wiki page
Returns:
The list of duppicate wiki page
Throws:
Exception

getWiki

public Wiki getWiki(String wikiType,
                    String owner)
Description copied from interface: WikiService
Get a wiki that definds by wikiType and owner

Specified by:
getWiki in interface WikiService
Parameters:
wikiType - The wiki type
owner - Wiki owner
Returns:
The wiki

getPortalOwner

public String getPortalOwner()
Description copied from interface: WikiService
Get portal owner

Specified by:
getPortalOwner in interface WikiService
Returns:
portal owner

hasAdminSpacePermission

public boolean hasAdminSpacePermission(String wikiType,
                                       String owner)
                                throws Exception
Check if the current user has addmin permission on the space

Specified by:
hasAdminSpacePermission in interface WikiService
Parameters:
wikiType - The wiki type of the space
owner - The owner of the space
Returns:
current user has addmin permisison on the space or not
Throws:
Exception

hasAdminPagePermission

public boolean hasAdminPagePermission(String wikiType,
                                      String owner)
                               throws Exception
Check if the current user has addmin permission on the page

Specified by:
hasAdminPagePermission in interface WikiService
Parameters:
wikiType - The wiki type of the space
owner - The owner of the space
Returns:
current user has addmin permisison on the page or not
Throws:
Exception

createTemplatePage

public Template createTemplatePage(String title,
                                   WikiPageParams params)
                            throws Exception
Specified by:
createTemplatePage in interface WikiService
Throws:
Exception

getWikiDefaultPermissions

public List<String> getWikiDefaultPermissions(String wikiType,
                                              String wikiOwner)
                                       throws Exception
Description copied from interface: WikiService
Get wiki default permission

Specified by:
getWikiDefaultPermissions in interface WikiService
Parameters:
wikiType - The type of wiki
wikiOwner - The owner of wiki
Returns:
The permisison list for wiki
Throws:
Exception

addComponentPlugin

public void addComponentPlugin(org.exoplatform.container.component.ComponentPlugin plugin)
Description copied from interface: WikiService
register a PageWikiListener

Specified by:
addComponentPlugin in interface WikiService

addWikiTemplatePagePlugin

public void addWikiTemplatePagePlugin(WikiTemplatePagePlugin plugin)
Specified by:
addWikiTemplatePagePlugin in interface WikiService

getPageListeners

public List<PageWikiListener> getPageListeners()
Specified by:
getPageListeners in interface WikiService
Returns:
list of PageWikiListener

setTemplatePagePlugin

public void setTemplatePagePlugin()

getOrCreateUserWiki

public UserWiki getOrCreateUserWiki(String username)
Description copied from interface: WikiService
Get user wiki, and if it did not create yet then create new one

Specified by:
getOrCreateUserWiki in interface WikiService
Parameters:
username - The user name
Returns:
The UserWiki for user

searchSpaces

public List<SpaceBean> searchSpaces(String keyword)
                             throws Exception
Description copied from interface: WikiService
Search for spaces by keyword

Specified by:
searchSpaces in interface WikiService
Parameters:
keyword - The keyword to search spaces
Returns:
The list of spaces that match wiki keyword
Throws:
Exception

addRelatedPage

public boolean addRelatedPage(WikiPageParams orginaryPageParams,
                              WikiPageParams relatedPageParams)
                       throws Exception
Specified by:
addRelatedPage in interface WikiService
Throws:
Exception

getRelatedPage

public List<Page> getRelatedPage(WikiPageParams pageParams)
                          throws Exception
Specified by:
getRelatedPage in interface WikiService
Throws:
Exception

removeRelatedPage

public boolean removeRelatedPage(WikiPageParams orginaryPageParams,
                                 WikiPageParams relatedPageParams)
                          throws Exception
Specified by:
removeRelatedPage in interface WikiService
Throws:
Exception

getWikiWebappUri

public String getWikiWebappUri()
Description copied from interface: WikiService
Get the uri of wiki webapp

Specified by:
getWikiWebappUri in interface WikiService
Returns:
The uri of wiki webapp

isSpaceMember

public boolean isSpaceMember(String spaceId,
                             String userId)
Description copied from interface: WikiService
Checks whether a user is a space's member or not.

Specified by:
isSpaceMember in interface WikiService
Parameters:
spaceId - the existing space id
userId - the remote user id
Returns:
true if that user is a member; otherwise, false

isHiddenSpace

public boolean isHiddenSpace(String groupId)
                      throws Exception
Description copied from interface: WikiService
Check if the space is hidden or not

Specified by:
isHiddenSpace in interface WikiService
Parameters:
groupId - The group Id to check
Returns:
the space is hidden or not
Throws:
Exception

createDraftForNewPage

public DraftPage createDraftForNewPage(WikiPageParams parentPageParam,
                                       long clientTime)
                                throws Exception
Description copied from interface: WikiService
Create a draft page for a new wiki page which parent is specified by the wiki page param

Specified by:
createDraftForNewPage in interface WikiService
clientTime - The time of client when save draft
Returns:
draft page
Throws:
Exception - if create draft not success

createDraftForExistPage

public DraftPage createDraftForExistPage(WikiPageParams param,
                                         String revision,
                                         long clientTime)
                                  throws Exception
Description copied from interface: WikiService
Create a draft page for a wiki page which is specified by the wiki page param

Specified by:
createDraftForExistPage in interface WikiService
Parameters:
param - wiki page param
revision - the target revision, null if it's the lastest revision
clientTime - The time of client when save draft
Returns:
draft page
Throws:
Exception - if create draft not success

getDraft

public DraftPage getDraft(WikiPageParams param)
                   throws Exception
Description copied from interface: WikiService
Achieve a draft page for a wiki page which is specified by the wiki page param

Specified by:
getDraft in interface WikiService
Parameters:
param - wiki page param
Returns:
draft page or null if draft page doesn't exist.
Throws:
Exception

getLastestDraft

public DraftPage getLastestDraft()
                          throws Exception
Description copied from interface: WikiService
Get the draft that's created lastest

Specified by:
getLastestDraft in interface WikiService
Returns:
lastest draft
Throws:
Exception

getDraft

public DraftPage getDraft(String draftName)
                   throws Exception
Description copied from interface: WikiService
Get draft by draft name

Specified by:
getDraft in interface WikiService
Parameters:
draftName - draft name
Returns:
draft page or null if draft page doesn't exist.
Throws:
Exception

removeDraft

public void removeDraft(WikiPageParams param)
                 throws Exception
Description copied from interface: WikiService
Remove a draft page for a wiki page which is specified by the wiki page param

Specified by:
removeDraft in interface WikiService
Parameters:
param - wiki page param
Throws:
Exception

removeDraft

public void removeDraft(String draftName)
                 throws Exception
Description copied from interface: WikiService
Remove a draft page by draft name

Specified by:
removeDraft in interface WikiService
Parameters:
draftName - draft name
Throws:
Exception

getDrafts

public List<DraftPage> getDrafts(String username)
                          throws Exception
Description copied from interface: WikiService
Get collection of draft page belong to a user

Specified by:
getDrafts in interface WikiService
Parameters:
username - user name
Returns:
draft list of user
Throws:
Exception

getWikiPageByUUID

public Page getWikiPageByUUID(String uuid)
                       throws Exception
Description copied from interface: WikiService
Get wiki page by page UUID

Specified by:
getWikiPageByUUID in interface WikiService
Parameters:
uuid - of wiki page
Returns:
wiki page
Throws:
Exception

getSpaceNameByGroupId

public String getSpaceNameByGroupId(String groupId)
                             throws Exception
Description copied from interface: WikiService
Get space name by group Id

Specified by:
getSpaceNameByGroupId in interface WikiService
Parameters:
groupId - The group Id to get space name
Returns:
The space name
Throws:
Exception

getWikiById

public Wiki getWikiById(String wikiId)
Description copied from interface: WikiService
Get wiki by Id

Specified by:
getWikiById in interface WikiService
Parameters:
wikiId - The wiki id
Returns:
The wiki

getWikiNameById

public String getWikiNameById(String wikiId)
                       throws Exception
Description copied from interface: WikiService
Get wiki name by wiki id

Specified by:
getWikiNameById in interface WikiService
Parameters:
wikiId - The wiki id
Returns:
The wiki name
Throws:
Exception

start

public void start()
Specified by:
start in interface org.picocontainer.Startable

stop

public void stop()
Specified by:
stop in interface org.picocontainer.Startable


Copyright © 2013 eXo Platform SAS. All Rights Reserved.