Class AbstractTagService

    • Constructor Detail

      • AbstractTagService

        public AbstractTagService()
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Description copied from interface: TagService
        Defines if tag service is enable.
        Specified by:
        isEnabled in interface TagService
        Returns:
        true if the underlying repository supports the tag feature
      • tag

        public void tag​(CoreSession session,
                        String docId,
                        String label)
        Description copied from interface: TagService
        Tags a document with a given tag.
        Specified by:
        tag in interface TagService
        Parameters:
        session - the session
        docId - the document id
        label - the tag
      • tag

        public void tag​(CoreSession session,
                        String docId,
                        String label,
                        String username)
        Description copied from interface: TagService
        Tags a document with a given tag.
        Specified by:
        tag in interface TagService
        Parameters:
        session - the session
        docId - the document id
        label - the tag
        username - the user associated to the tagging
      • untag

        public void untag​(CoreSession session,
                          String docId,
                          String label)
        Description copied from interface: TagService
        Untags a document of the given tag
        Specified by:
        untag in interface TagService
        Parameters:
        session - the session
        docId - the document id
        label - the tag, or null for all tags
      • untag

        public void untag​(CoreSession session,
                          String docId,
                          String label,
                          String username)
        Description copied from interface: TagService
        Untags a document of the given tag
        Specified by:
        untag in interface TagService
        Parameters:
        session - the session
        docId - the document id
        label - the tag, or null for all tags
        username - the user associated to the tagging
      • canUntag

        public boolean canUntag​(CoreSession session,
                                String docId,
                                String label)
        Description copied from interface: TagService
        Returns whether or not the current session can untag tag on provided document.
        Specified by:
        canUntag in interface TagService
        Parameters:
        session - the session
        docId - the document id
        label - the tag, or null for all tags
        Returns:
        whether or not the current session can untag provided document
      • getTags

        public Set<String> getTags​(CoreSession session,
                                   String docId)
        Description copied from interface: TagService
        Gets the tags applied to a document.
        Specified by:
        getTags in interface TagService
        Parameters:
        session - the session
        docId - the document id
        Returns:
        the list of tags
      • getDocumentTags

        public List<Tag> getDocumentTags​(CoreSession session,
                                         String docId,
                                         String username)
        Description copied from interface: TagService
        Gets the tags applied to a document by a given user, or by all users.
        Specified by:
        getDocumentTags in interface TagService
        Parameters:
        session - the session
        docId - the document id
        username - the user name, or null for all users
        Returns:
        the list of tags
      • getDocumentTags

        public List<Tag> getDocumentTags​(CoreSession session,
                                         String docId,
                                         String username,
                                         boolean useCore)
        Description copied from interface: TagService
        Gets the tags applied to a document by a given user, or by all users.

        Alternative method allowing to specify whether the core should be used for this query.

        Specified by:
        getDocumentTags in interface TagService
        Parameters:
        session - the session
        docId - the document id
        username - the user name, or null for all users
        useCore - if true, the core should be used to retrieve tags.
        Returns:
        the list of tags
      • copyTags

        public void copyTags​(CoreSession session,
                             String srcDocId,
                             String dstDocId)
        Description copied from interface: TagService
        Copy all the tags applied to the source document to the destination document.

        The tags are merged.

        Specified by:
        copyTags in interface TagService
        srcDocId - the source document id
        dstDocId - the destination document id
      • copyTags

        protected void copyTags​(CoreSession session,
                                String srcDocId,
                                String dstDocId,
                                boolean removeExistingTags)
      • replaceTags

        public void replaceTags​(CoreSession session,
                                String srcDocId,
                                String dstDocId)
        Description copied from interface: TagService
        Replace all the existing tags applied on the destination document by the ones applied on the source document.
        Specified by:
        replaceTags in interface TagService
        srcDocId - the source document id
        dstDocId - the destination document id
      • getTagDocumentIds

        public List<String> getTagDocumentIds​(CoreSession session,
                                              String label)
        Description copied from interface: TagService
        Gets the documents to which a tag is applied.
        Specified by:
        getTagDocumentIds in interface TagService
        Parameters:
        session - the session
        label - the tag
        Returns:
        the set of document ids
      • getTagDocumentIds

        public List<String> getTagDocumentIds​(CoreSession session,
                                              String label,
                                              String username)
        Description copied from interface: TagService
        Gets the documents to which a tag is applied.
        Specified by:
        getTagDocumentIds in interface TagService
        Parameters:
        session - the session
        label - the tag
        username - the user name, or null for all users
        Returns:
        the set of document ids
      • getSuggestions

        public Set<String> getSuggestions​(CoreSession session,
                                          String label)
        Description copied from interface: TagService
        Gets suggestions for a given tag label prefix.
        Specified by:
        getSuggestions in interface TagService
        Parameters:
        session - the session
        label - the tag label prefix
        Returns:
        a list of tags
      • getSuggestions

        public List<Tag> getSuggestions​(CoreSession session,
                                        String label,
                                        String username)
        Description copied from interface: TagService
        Gets suggestions for a given tag label prefix.
        Specified by:
        getSuggestions in interface TagService
        Parameters:
        session - the session
        label - the tag label prefix
        username - the user name, or null for all users
        Returns:
        a list of tags
      • isTagSanitizationEnabled

        protected boolean isTagSanitizationEnabled()
      • doCopyTags

        public abstract void doCopyTags​(CoreSession session,
                                        String srcDocId,
                                        String dstDocId,
                                        boolean removeExistingTags)
      • cleanLabel

        protected String cleanLabel​(String label,
                                    boolean allowEmpty,
                                    boolean allowPercent)
      • cleanUsername

        protected static String cleanUsername​(String username)
      • fireUpdateEvent

        protected void fireUpdateEvent​(CoreSession session,
                                       String docId)