Class AttachmentScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Singleton
    @Named("attachment")
    @Unstable
    public class AttachmentScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Provides the operations related to attachments manipulation. In particular regarding the operations to move attachments.
    Since:
    14.0RC1
    Version:
    $Id: f37883c017f5b26e21dc48d2fb383f0cd388ec0c $
    • Constructor Detail

      • AttachmentScriptService

        public AttachmentScriptService()
    • Method Detail

      • createMoveRequest

        public MoveAttachmentRequest createMoveRequest​(org.xwiki.model.reference.DocumentReference sourceLocation,
                                                       String sourceName,
                                                       org.xwiki.model.reference.DocumentReference targetLocation,
                                                       String targetName,
                                                       org.xwiki.model.reference.DocumentReference userReference,
                                                       boolean autoRedirect,
                                                       boolean updateReferences)
        Creates an attachment move request.
        Parameters:
        sourceLocation - the location of the document containing the source attachment
        sourceName - the name of the source attachment
        targetLocation - the target location of the document containing the attachment
        targetName - the target name of the attachment
        userReference - the reference of the user making the move request
        autoRedirect - if true a redirection will be set from the source location to the target location
        updateReferences - if true the references of the attachments will be refactored
        Returns:
        the initialized move attachment request
      • createMoveJob

        public org.xwiki.job.Job createMoveJob​(MoveAttachmentRequest request)
                                        throws org.xwiki.job.JobException
        Creates an attachment move job from a request.
        Parameters:
        request - a move attachment request to start a job from
        Returns:
        the initialized move attachment request
        Throws:
        org.xwiki.job.JobException
      • locationAvailable

        public boolean locationAvailable​(org.xwiki.model.reference.DocumentReference documentReference,
                                         String attachmentName)
        Parameters:
        documentReference - the document reference containing the attachment
        attachmentName - the name of the attachment
        Returns:
        true if the attachment exists or has existed (but was moved with a redirection) at the requested location.
      • backlinksCount

        @Unstable
        public long backlinksCount​(org.xwiki.model.reference.AttachmentReference attachmentReference)
                            throws AttachmentException
        Count the number of backlinks toward a given attachment.
        Parameters:
        attachmentReference - an attachment reference
        Returns:
        the number of backlinks to the attachment
        Throws:
        AttachmentException
        Since:
        14.2RC1