Class WikiServiceImpl

  • All Implemented Interfaces:
    WikiService, org.picocontainer.Startable

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

      • WikiServiceImpl

        public WikiServiceImpl​(org.exoplatform.container.configuration.ConfigurationManager configManager,
                               org.exoplatform.portal.config.UserACL userACL,
                               DataStorage dataStorage,
                               org.exoplatform.services.cache.CacheService cacheService,
                               org.exoplatform.services.organization.OrganizationService orgService,
                               org.exoplatform.container.xml.InitParams initParams)
    • Method Detail

      • start

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

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

        public org.exoplatform.services.cache.ExoCache<Integer,​MarkupData> getRenderingCache()
      • addComponentPlugin

        public void addComponentPlugin​(org.exoplatform.container.component.ComponentPlugin plugin)
        Configuration
        Specified by:
        addComponentPlugin in interface WikiService
        Parameters:
        plugin - The component plugin to be registered.
      • getSaveDraftSequenceTime

        public long getSaveDraftSequenceTime()
        Description copied from interface: WikiService
        Gets an interval which specifies the periodical auto-saving for pages in Wiki.
        Specified by:
        getSaveDraftSequenceTime in interface WikiService
        Returns:
        The interval. Its default value is 30 seconds.
      • getEditPageLivingTime

        public long getEditPageLivingTime()
        Description copied from interface: WikiService
        Get the living time of edited page
        Specified by:
        getEditPageLivingTime in interface WikiService
        Returns:
        The living time of edited page
      • getWikiPermission

        public List<PermissionEntry> getWikiPermission​(String wikiType,
                                                       String wikiOwner)
                                                throws WikiException
        Description copied from interface: WikiService
        Gets a list of Wiki permissions based on its type and owner.
        Specified by:
        getWikiPermission in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        Returns:
        The list of Wiki permissions.
        Throws:
        WikiException - if an error occured if an error occured
      • updateWikiPermission

        public void updateWikiPermission​(String wikiType,
                                         String wikiOwner,
                                         List<PermissionEntry> permissionEntries)
                                  throws WikiException
        Description copied from interface: WikiService
        Adds a list of permissions to Wiki.
        Specified by:
        updateWikiPermission in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        permissionEntries - The list of permissions.
        Throws:
        WikiException - if an error occured if an error occured
      • createWiki

        public Wiki createWiki​(String wikiType,
                               String owner)
                        throws WikiException
        Description copied from interface: WikiService
        Creates a wiki with the given type and owner
        Specified by:
        createWiki in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        owner - The Wiki owner.
        Returns:
        Wiki created
        Throws:
        WikiException - if an error occured
      • createPage

        public Page createPage​(Wiki wiki,
                               String parentPageName,
                               Page page)
                        throws WikiException
        Page
        Specified by:
        createPage in interface WikiService
        Parameters:
        wiki - It can be Portal, Group, or User.
        parentPageName - Name of the parent wiki page.
        page - wiki page object to create.
        Returns:
        The new wiki page.
        Throws:
        WikiException - if an error occured if an error occured
      • getPageOfWikiByName

        public Page getPageOfWikiByName​(String wikiType,
                                        String wikiOwner,
                                        String pageName)
                                 throws WikiException
        Description copied from interface: WikiService
        Gets a wiki page by its unique name in the wiki.
        Specified by:
        getPageOfWikiByName in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageName - Id of the wiki page.
        Returns:
        The wiki page if the current user has the read permission. Otherwise, it is "null".
        Throws:
        WikiException - if an error occured if an error occured
      • getPageById

        public Page getPageById​(String id)
                         throws WikiException
        Description copied from interface: WikiService
        Gets a wiki page based on its unique id.
        Specified by:
        getPageById in interface WikiService
        Parameters:
        id - Unique id of the wiki page.
        Returns:
        The wiki page.
        Throws:
        WikiException - if an error occured if an error occured
      • getPageByRootPermission

        public Page getPageByRootPermission​(String wikiType,
                                            String wikiOwner,
                                            String pageId)
                                     throws WikiException
        Description copied from interface: WikiService
        Gets a wiki page regardless of the current user's permission.
        Specified by:
        getPageByRootPermission in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageId - Id of the wiki page.
        Returns:
        The wiki page.
        Throws:
        WikiException - if an error occured if an error occured
      • getChildrenPageOf

        public List<Page> getChildrenPageOf​(Page page,
                                            String userId,
                                            boolean withDrafts)
                                     throws WikiException
        Description copied from interface: WikiService
        Get all the children pages of a wiki page
        Specified by:
        getChildrenPageOf in interface WikiService
        Parameters:
        page - Wiki page.
        withDrafts - if set to true returns the children notes and draft notes
        Returns:
        The list of children pages
        Throws:
        WikiException - if an error occured
      • deletePage

        public boolean deletePage​(String wikiType,
                                  String wikiOwner,
                                  String pageName,
                                  String userId)
                           throws WikiException
        Description copied from interface: WikiService
        Deletes a wiki page.
        Specified by:
        deletePage in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageName - Id of the wiki page.
        Returns:
        "True" if deleting the wiki page is successful, or "false" if not.
        Throws:
        WikiException - if an error occured if an error occured
      • renamePage

        public boolean renamePage​(String wikiType,
                                  String wikiOwner,
                                  String pageName,
                                  String newName,
                                  String newTitle)
                           throws WikiException
        Description copied from interface: WikiService
        Renames a wiki page.
        Specified by:
        renamePage in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageName - Old name of the wiki page.
        newName - New name of the wiki page.
        newTitle - New title of the wiki page.
        Returns:
        "True" if renaming the wiki page is successful, or "false" if not.
        Throws:
        WikiException - if an error occured if an error occured
      • movePage

        public boolean movePage​(WikiPageParams currentLocationParams,
                                WikiPageParams newLocationParams)
                         throws WikiException
        Description copied from interface: WikiService
        Move a wiki Page
        Specified by:
        movePage in interface WikiService
        Parameters:
        currentLocationParams - The current location of the wiki page.
        newLocationParams - The new location of the wiki page.
        Returns:
        "True" if moving the wiki page is successful, or "false" if not.
        Throws:
        WikiException - if an error occured if an error occured
      • getPageRenderedContent

        public String getPageRenderedContent​(Page page)
        Description copied from interface: WikiService
        Get renderd content of a page
        Specified by:
        getPageRenderedContent in interface WikiService
        Parameters:
        page - The wiki page
        Returns:
        The rendered content
      • invalidateCache

        protected void invalidateCache​(Page page)
      • invalidateAttachmentCache

        protected void invalidateAttachmentCache​(Page page)
      • invalidateCachesOfPageTree

        protected void invalidateCachesOfPageTree​(Page page,
                                                  String userId)
                                           throws WikiException
        Invalidate all caches of a page and all its descendants
        Parameters:
        page - root page
        userId -
        Throws:
        WikiException - if an error occured
      • getRelatedPage

        public Page getRelatedPage​(String wikiType,
                                   String wikiOwner,
                                   String pageId)
                            throws WikiException
        Description copied from interface: WikiService
        Gets a related page of a wiki page which is specified by a given Id.
        Specified by:
        getRelatedPage in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageId - Id of the wiki page.
        Returns:
        The related wiki page.
        Throws:
        WikiException - if an error occured if an error occured
      • isExisting

        public boolean isExisting​(String wikiType,
                                  String wikiOwner,
                                  String pageId)
                           throws WikiException
        Description copied from interface: WikiService
        Checks if a wiki page exists or not.
        Specified by:
        isExisting in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageId - Id of the wiki page.
        Returns:
        The returned value is "true" if the page exists, or "false" if not.
        Throws:
        WikiException - if an error occured
      • getHelpSyntaxPage

        public Page getHelpSyntaxPage​(String syntaxId,
                                      boolean fullContent)
                               throws WikiException
        Description copied from interface: WikiService
        Gets a Help wiki page based on a given syntax Id.
        Specified by:
        getHelpSyntaxPage in interface WikiService
        Parameters:
        syntaxId - Id of the syntax.
        fullContent - true to get the full help page content, false to get an excerpt
        Returns:
        The Help wiki page.
        Throws:
        WikiException - if an error occured
      • getDuplicatePages

        public List<Page> getDuplicatePages​(Page parentPage,
                                            Wiki targetWiki,
                                            List<Page> resultList,
                                            String userId)
                                     throws WikiException
        Description copied from interface: WikiService
        Checks if a page and its children are duplicated with ones in the target Wiki or not, then gets a list of duplicated pages if any.
        Specified by:
        getDuplicatePages in interface WikiService
        Parameters:
        parentPage - The page to check.
        targetWiki - The target Wiki to check.
        resultList - The list of duplicated wiki pages.
        Returns:
        The list of duplicated wiki pages.
        Throws:
        WikiException - if an error occured if an error occured
      • hasPermissionOnWiki

        public boolean hasPermissionOnWiki​(Wiki wiki,
                                           PermissionType permissionType,
                                           org.exoplatform.services.security.Identity user)
                                    throws WikiException
        Description copied from interface: WikiService
        Check if the identity has the given permission type on a wiki
        Specified by:
        hasPermissionOnWiki in interface WikiService
        Parameters:
        wiki - Wiki
        permissionType - Permission type to check
        user - Identity of the user
        Returns:
        true if the user has the given permission type on the wiki
        Throws:
        WikiException - if an error occured
      • hasPermissionOnPage

        public boolean hasPermissionOnPage​(Page page,
                                           PermissionType permissionType,
                                           org.exoplatform.services.security.Identity user)
                                    throws WikiException
        Description copied from interface: WikiService
        Checks if the given user has the permission on a page
        Specified by:
        hasPermissionOnPage in interface WikiService
        Parameters:
        page - the wiki page object
        permissionType - permission Type
        user - the userName
        Returns:
        true if user has permissions
        Throws:
        WikiException - if an error occured
      • canModifyPagePermission

        public boolean canModifyPagePermission​(Page currentPage,
                                               String currentUser)
                                        throws WikiException
        Description copied from interface: WikiService
        Check if the given user can update the page
        Specified by:
        canModifyPagePermission in interface WikiService
        Parameters:
        currentPage - The page to update
        currentUser - The user that needs to update the page
        Returns:
        true if the user can update the page
        Throws:
        WikiException - if an error occured
      • canPublicAndRetrictPage

        public boolean canPublicAndRetrictPage​(Page currentPage,
                                               String currentUser)
                                        throws WikiException
        Description copied from interface: WikiService
        Check if the given user can public or restrict the page
        Specified by:
        canPublicAndRetrictPage in interface WikiService
        Parameters:
        currentPage - page to check
        currentUser - user to chck permissions
        Returns:
        true if the current user has EditPage permission or admin page or admin space
        Throws:
        WikiException - if an error occured
      • createVersionOfPage

        public void createVersionOfPage​(Page page)
                                 throws WikiException
        Description copied from interface: WikiService
        Creates a version of a page. This method only tag the current page data as a new version, it does not update the page data
        Specified by:
        createVersionOfPage in interface WikiService
        Parameters:
        page - The wiki page
        Throws:
        WikiException - if an error occured
      • updatePage

        public void updatePage​(Page page,
                               PageUpdateType updateType)
                        throws WikiException
        Description copied from interface: WikiService
        Update the given page. This does not automatically create a new version. If a new version must be created it should be explicitly done by calling createVersionOfPage(). The second parameter is the type of update done (title only, content only, both, move, ...).
        Specified by:
        updatePage in interface WikiService
        Parameters:
        page - Updated page
        updateType - Type of update
        Throws:
        WikiException - if an error occured
      • createTemplatePage

        public void createTemplatePage​(Wiki wiki,
                                       Template template)
                                throws WikiException
        Template
        Specified by:
        createTemplatePage in interface WikiService
        Parameters:
        wiki - Wiki of the template
        template - The params object which is used for creating the new Wiki template.
        Throws:
        WikiException - if an error occured if an error occured
      • getTemplatePage

        public Template getTemplatePage​(WikiPageParams params,
                                        String templateId)
                                 throws WikiException
        Description copied from interface: WikiService
        Gets a Wiki template.
        Specified by:
        getTemplatePage in interface WikiService
        Parameters:
        params - The params object which is used for creating the Wiki template.
        templateId - Id of the wiki template.
        Returns:
        The wiki template.
        Throws:
        WikiException - if an error occured if an error occured
      • deleteTemplatePage

        public void deleteTemplatePage​(String wikiType,
                                       String wikiOwner,
                                       String templateName)
                                throws WikiException
        Description copied from interface: WikiService
        Deletes a Wiki template.
        Specified by:
        deleteTemplatePage in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        templateName - Name of the Wiki template.
        Throws:
        WikiException - if an error occured if an error occured
      • addRelatedPage

        public void addRelatedPage​(WikiPageParams orginaryPageParams,
                                   WikiPageParams relatedPageParams)
                            throws WikiException
        Description copied from interface: WikiService
        Adds a related page to the current wiki page.
        Specified by:
        addRelatedPage in interface WikiService
        Parameters:
        orginaryPageParams - The params object of the current wiki page.
        relatedPageParams - The params object of the related page.
        Throws:
        WikiException - if an error occured
      • removeRelatedPage

        public void removeRelatedPage​(WikiPageParams orginaryPageParams,
                                      WikiPageParams relatedPageParams)
                               throws WikiException
        Description copied from interface: WikiService
        Removes a related page of the current wiki page.
        Specified by:
        removeRelatedPage in interface WikiService
        Parameters:
        orginaryPageParams - The params object of the current wiki page.
        relatedPageParams - The params object of the related page.
        Throws:
        WikiException - if an error occured
      • getExsitedOrNewDraftPageById

        public Page getExsitedOrNewDraftPageById​(String wikiType,
                                                 String wikiOwner,
                                                 String pageId)
                                          throws WikiException
        Draft
        Specified by:
        getExsitedOrNewDraftPageById in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageId - Id of the wiki page.
        Returns:
        The wiki page or its draft.
        Throws:
        WikiException - if an error occured if an error occured
      • createDraftForNewPage

        public DraftPage createDraftForNewPage​(DraftPage draftPage,
                                               Page parentPage,
                                               long clientTime)
                                        throws WikiException
        Description copied from interface: WikiService
        Creates a draft page for a new wiki page whose parent is specified by a given param object.
        Specified by:
        createDraftForNewPage in interface WikiService
        Parameters:
        draftPage - The draft object
        parentPage - The parent wiki page.
        clientTime - The time of client when the draft page is saved.
        Returns:
        The draft page.
        Throws:
        WikiException - if an error occured if the draft page cannot be created.
      • createDraftForExistPage

        public DraftPage createDraftForExistPage​(DraftPage draftPage,
                                                 Page targetPage,
                                                 String revision,
                                                 long clientTime)
                                          throws WikiException
        Description copied from interface: WikiService
        Creates a draft page for a wiki page which is specified by a given param object.
        Specified by:
        createDraftForExistPage in interface WikiService
        Parameters:
        draftPage - The draft object
        targetPage - The target wiki page.
        revision - The revision which is used for creating the draft page. If "null", this will be the last revision.
        clientTime - The time of client when the draft page is saved.
        Returns:
        The draft page.
        Throws:
        WikiException - if an error occured if the draft page cannot be created.
      • getDraftOfPage

        public DraftPage getDraftOfPage​(Page page)
                                 throws WikiException
        Description copied from interface: WikiService
        Gets a draft page of a wiki page which is specified by a given param object.
        Specified by:
        getDraftOfPage in interface WikiService
        Parameters:
        page - The wiki page.
        Returns:
        The draft page, or "null" if the draft page does not exist.
        Throws:
        WikiException - if an error occured
      • getDraft

        public DraftPage getDraft​(String draftName)
                           throws WikiException
        Description copied from interface: WikiService
        Gets a draft page by its name.
        Specified by:
        getDraft in interface WikiService
        Parameters:
        draftName - Name of the draft page.
        Returns:
        The draft page, or "null" if it does not exist.
        Throws:
        WikiException - if an error occured
      • isDraftOutDated

        public boolean isDraftOutDated​(DraftPage draftPage)
                                throws WikiException
        Description copied from interface: WikiService
        Check if a draft page is outdated
        Specified by:
        isDraftOutDated in interface WikiService
        Parameters:
        draftPage - the draft page object
        Returns:
        true if the draft is outdated
        Throws:
        WikiException - if an error occured
      • getDraftChanges

        public org.exoplatform.commons.diff.DiffResult getDraftChanges​(DraftPage draftPage)
                                                                throws WikiException
        Description copied from interface: WikiService
        Gets the changes between the draft page and the target page
        Specified by:
        getDraftChanges in interface WikiService
        Parameters:
        draftPage - the draft page object
        Returns:
        list of changes
        Throws:
        WikiException - if an error occured
      • getAttachmentsOfPage

        public List<Attachment> getAttachmentsOfPage​(Page page,
                                                     boolean loadContent)
                                              throws WikiException
        Description copied from interface: WikiService
        Gets attachments of the given page, and allow to load their attachment content by setting loadContent to true
        Specified by:
        getAttachmentsOfPage in interface WikiService
        Parameters:
        page - The wiki page
        loadContent - treue if need to load the attachement content
        Returns:
        The attachments of the page
        Throws:
        WikiException - if an error occured if an error occured
      • getNbOfAttachmentsOfPage

        public int getNbOfAttachmentsOfPage​(Page page)
                                     throws WikiException
        Description copied from interface: WikiService
        Get the number of attachment of the given page
        Specified by:
        getNbOfAttachmentsOfPage in interface WikiService
        Parameters:
        page - The wiki page
        Returns:
        The number of attachments of the page
        Throws:
        WikiException - if an error occured if an error occured
      • getAttachmentOfPageByName

        public Attachment getAttachmentOfPageByName​(String attachmentName,
                                                    Page page)
                                             throws WikiException
        Description copied from interface: WikiService
        Get a attachment of a the given page by name, without loading its content
        Specified by:
        getAttachmentOfPageByName in interface WikiService
        Parameters:
        attachmentName - The name of the attachment
        page - The wiki page
        Returns:
        Attachment
        Throws:
        WikiException - if an error occured if an error occured
      • getAttachmentOfPageByName

        public Attachment getAttachmentOfPageByName​(String attachmentName,
                                                    Page page,
                                                    boolean loadContent)
                                             throws WikiException
        Description copied from interface: WikiService
        Get a attachment of a the given page by name, and allow to load the attachment content by setting loadContent to true
        Specified by:
        getAttachmentOfPageByName in interface WikiService
        Parameters:
        attachmentName - The name of the attachment
        page - The wiki page
        loadContent - true to load the attachment content
        Returns:
        attachement
        Throws:
        WikiException - if an error occured if an error occured
      • addWatcherToPage

        public void addWatcherToPage​(String username,
                                     Page page)
                              throws WikiException
        Description copied from interface: WikiService
        Add the given user as watcher of the wiki page
        Specified by:
        addWatcherToPage in interface WikiService
        Parameters:
        username - Username of the user to add as watcher
        page - The wiki page
        Throws:
        WikiException - if an error occured
      • deleteWatcherOfPage

        public void deleteWatcherOfPage​(String username,
                                        Page page)
                                 throws WikiException
        Description copied from interface: WikiService
        Delete a user as watcher of the given page
        Specified by:
        deleteWatcherOfPage in interface WikiService
        Parameters:
        username - Username of the user to delete as watcher
        page - The wiki page
        Throws:
        WikiException - if an error occured
      • hasAdminSpacePermission

        public boolean hasAdminSpacePermission​(String wikiType,
                                               String owner)
                                        throws WikiException
        Description copied from interface: WikiService
        Checks if the current user has the admin permission on a space or not.
        Specified by:
        hasAdminSpacePermission in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        owner - Owner of the space.
        Returns:
        The returned value is "true" if the current user has the admin permission on the space, or "false" if not.
        Throws:
        WikiException - if an error occured
      • getSpaceNameByGroupId

        public String getSpaceNameByGroupId​(String groupId)
        Description copied from interface: WikiService
        Gets a space name by a given group Id.
        Specified by:
        getSpaceNameByGroupId in interface WikiService
        Parameters:
        groupId - The group Id.
        Returns:
        The space name.
      • getBreadcumb

        public List<BreadcrumbData> getBreadcumb​(String wikiType,
                                                 String wikiOwner,
                                                 String pageId)
                                          throws WikiException
        Description copied from interface: WikiService
        Gets a list of data which is used for composing the breadcrumb.
        Specified by:
        getBreadcumb in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        wikiOwner - The Wiki owner.
        pageId - Id of the wiki page to which the breadcrumb points.
        Returns:
        The list of data.
        Throws:
        WikiException - if an error occured if an error occured
      • getWikiPageParams

        public WikiPageParams getWikiPageParams​(BreadcrumbData data)
        Description copied from interface: WikiService
        Gets parameters of a wiki page based on the data stored in the breadcrumb.
        Specified by:
        getWikiPageParams in interface WikiService
        Parameters:
        data - The data in the breadcrumb that identifies the wiki page.
        Returns:
        The parameters identifying the wiki page.
      • hasAdminPagePermission

        public boolean hasAdminPagePermission​(String wikiType,
                                              String owner)
                                       throws WikiException
        Description copied from interface: WikiService
        Checks if the current user has the admin permission on a wiki page.
        Specified by:
        hasAdminPagePermission in interface WikiService
        Parameters:
        wikiType - It can be Portal, Group, or User.
        owner - Owner of the wiki page.
        Returns:
        "True" if the current user has the admin permission on the wiki page, or "false" if not.
        Throws:
        WikiException - if an error occured
      • getUploadLimit

        public int getUploadLimit()
        Specified by:
        getUploadLimit in interface WikiService
        Returns:
        Upload limit for Wiki Attachment
      • getPagesOfWiki

        public List<Page> getPagesOfWiki​(String wikiType,
                                         String wikiOwner)
        Description copied from interface: WikiService
        Retrieve the all pages contained in wiki
        Specified by:
        getPagesOfWiki in interface WikiService
        Parameters:
        wikiType - the wiki type
        wikiOwner - the wiki owner
        Returns:
        List of pages