Class CoreAttachImplementation

    • Constructor Detail

      • CoreAttachImplementation

        public CoreAttachImplementation()
    • Method Detail

      • uploadFile

        public void uploadFile​(Attachment attachment,
                               String dataType,
                               Map<String,​Object> parameters,
                               File file,
                               String tabId)
                        throws OBException
        Description copied from class: AttachImplementation
        Method in charge of File upload. Invoked when a new file is attached to a record.
        Specified by:
        uploadFile in class AttachImplementation
        Parameters:
        attachment - The attachment created in c_file
        dataType - DataType of the attachment
        parameters - A map with the metadata and its values to be updated in the corresponding file management system and in the attachment
        file - The file to be uploaded
        tabId - The tabID where the file is attached
        Throws:
        OBException - Thrown when any error occurs during the upload
      • downloadFile

        public File downloadFile​(Attachment attachment)
        Description copied from class: AttachImplementation
        Method invoked when an attached file needs to be downloaded from the corresponding file management system.
        Specified by:
        downloadFile in class AttachImplementation
        Parameters:
        attachment - The attachment that will be downloaded
        Returns:
        the attached file.
      • deleteFile

        public void deleteFile​(Attachment attachment)
        Description copied from class: AttachImplementation
        Method invoked when an attached file needs to be removed from the corresponding file management system.
        Specified by:
        deleteFile in class AttachImplementation
        Parameters:
        attachment - The attachment to be removed
      • updateFile

        public void updateFile​(Attachment attachment,
                               String tabId,
                               Map<String,​Object> parameters)
                        throws OBException
        Description copied from class: AttachImplementation
        Method invoked when an existing attachment metadata is updated.
        Specified by:
        updateFile in class AttachImplementation
        Parameters:
        attachment - The attachment to be modified
        tabId - The tabID where the file was attached
        parameters - The metadata with the new values.
        Throws:
        OBException - Thrown when any error occurs when updating the file
      • isTempFile

        public boolean isTempFile()
        Description copied from class: AttachImplementation
        Method invoked to check if the downloaded file has to be deleted when the download is completed by the user. Some attachment methods might create temporary files in Openbravo server that should be removed when the download is completed.
        Specified by:
        isTempFile in class AttachImplementation
        Returns:
        true if the downloaded File has to be deleted.
      • getAttachmentDirectoryForNewAttachments

        public static String getAttachmentDirectoryForNewAttachments​(String tableID,
                                                                     String recordID)
        Provides the directory in which the attachment has to be stored. For example for tableId "259", recordId "0F3A10E019754BACA5844387FB37B0D5", the file directory returned is "259/0F3/A10/E01/975/4BA/CA5/844/387/FB3/7B0/D5". In case 'SaveAttachmentsOldWay' preference is enabled then the file directory returned is "259-0F3A10E019754BACA5844387FB37B0D5"
        Parameters:
        tableID - UUID of the table
        recordID - UUID of the record
        Returns:
        file directory to save the attachment
      • getAttachmentDirectory

        public static String getAttachmentDirectory​(String tableID,
                                                    String recordID,
                                                    String fileName)
        Provides the directory in which the attachment is stored. For example for tableId "259", recordId "0F3A10E019754BACA5844387FB37B0D5", and fileName "test.txt" the file directory returned is "259/0F3/A10/E01/975/4BA/CA5/844/387/FB3/7B0/D5". In case 'SaveAttachmentsOldWay' preference is enabled then the file directory returned is "259-0F3A10E019754BACA5844387FB37B0D5"
        Parameters:
        tableID - UUID of the table
        recordID - UUID of the record
        fileName - Name of the file
        Returns:
        file directory in which the attachment is stored
      • getPath

        public static String getPath​(String fileDirectory)
        Provides the value to be saved in path field in c_file. The path field is used to get the location of the attachment. For example 259/0F3/A10/E01/975/4BA/CA5/844/387/FB3/7B0/D5. This path is relative to the attachments folder
        Parameters:
        fileDirectory - the directory that is retrieved from getFileDirectory()
        Returns:
        value to be saved in path in c_file
      • splitPath

        public static String splitPath​(String origname)
        Splits the path name component so that the resulting path name is 3 characters long sub directories. For example 12345 is split to 123/45
        Parameters:
        origname - Original name
        Returns:
        split name.