Class FileArchiveService

java.lang.Object
sk.iway.iwcm.components.file_archiv.FileArchivSupportMethodsService
sk.iway.iwcm.components.file_archiv.FileArchiveService

public class FileArchiveService extends FileArchivSupportMethodsService
Validates and executes file archive create, edit, version, replacement, rollback, and delete operations. The service coordinates domain-scoped persistence with the corresponding physical file changes.
  • Constructor Details

    • FileArchiveService

      public FileArchiveService(Identity user, Prop prop, FileArchivatorBean fab, FileArchiveRepository repository)
      Creates a service for one archive entity and initializes its requested file operation.
      Parameters:
      user - user performing the operation
      prop - localization provider, or null to use the default provider
      fab - archive entity being processed
      repository - archive repository, or null to resolve the Spring bean
  • Method Details

    • getUploadType

      public FileArchiveService.UploadType getUploadType(String key)
      Converts a request value to a supported archive upload operation.
      Parameters:
      key - upload operation key
      Returns:
      matching upload type, or FileArchiveService.UploadType.NO_ACTION for empty or unknown values
    • getUploadTypeOptions

      public static final List<LabelValue> getUploadTypeOptions(Prop prop)
      Builds the localized upload-operation options shown by the archive editor.
      Parameters:
      prop - localization provider
      Returns:
      upload-operation labels and values in display order
    • getStatusIconOptions

      public static final List<LabelValue> getStatusIconOptions(Prop prop)
      Builds localized status filters for the archive table.
      Parameters:
      prop - localization provider
      Returns:
      status filter labels and query values
    • getInstance

      public static FileArchiveService getInstance(Identity user, Long fileArchivId)
      Creates an archive service for legacy Java and JSP callers outside Spring dependency injection. Spring-managed callers should use the regular constructor.
      Parameters:
      user - user performing the operation
      fileArchivId - identifier of the archive record
      Returns:
      initialized service, or null when the record does not exist in the current domain
    • getErrorList

      public final List<String> getErrorList()
    • getErrorParams

      public final String[] getErrorParams()
    • getSameFiles

      public final List<FileArchivatorBean> getSameFiles()
    • checkFileProperties

      public void checkFileProperties(org.springframework.validation.Errors errors)
    • checkFileProperties

      public void checkFileProperties(org.springframework.validation.Errors errors, boolean requireEditPermission)
      Validates file properties while optionally enforcing the archive edit permission. The bulk upload create flow historically requires only the archive upload permission, while edits and the standard archive editor require the edit permission as well.
      Parameters:
      errors - validation errors
      requireEditPermission - whether the archive edit permission is required
    • saveFile

      public String saveFile()
      Executes the selected archive record and file operation under the shared file-operation lock.
      Returns:
      an error key when the operation fails; otherwise null
    • checkAndRenameFile

      public int checkAndRenameFile()
      Renames the current archive file when a new name was requested in the editor.
      Returns:
      1 when renamed, 0 when renaming fails, or -1 when no rename was requested
    • rollback

      public boolean rollback()
      Removes the current file from its version thread and promotes the preceding version.
      Returns:
      true when the rollback and history updates complete successfully
    • deleteStructure

      public String deleteStructure()
      Deletes a main archive record together with its history versions, patterns, and physical files.
      Returns:
      an error key when deletion fails; otherwise null
    • deleteWaitingFile

      public String deleteWaitingFile()
      Deletes the current waiting upload and its associated pattern files.
      Returns:
      an error key when deletion fails; otherwise null
    • getWaitingFileList

      public static List<FileArchivatorBean> getWaitingFileList(Long mainId, FileArchiveRepository repo)
      Returns scheduled uploads from the domain cache, optionally limited to one main file. The cache always stores the complete domain-scoped waiting list.
      Parameters:
      mainId - main-file identifier used to filter the cached list, or null for all records
      repo - archive repository used when the cache is empty
      Returns:
      waiting archive records, possibly filtered by their main-file identifier
    • moveBehind

      public String moveBehind(int moveBelowFileId)
      Inserts the uploaded file into archive history immediately after a selected version.
      Parameters:
      moveBelowFileId - identifier of the version after which the upload is inserted
      Returns:
      an error key when insertion fails; otherwise null
    • getId

      public static final Long getId(String filePath, String fileName, FileArchiveRepository far)
      Finds the ID of an existing archive file by its folder path and file name. Performs a dual lookup: first using the legacy (old) path format for backward compatibility, then using the normalized path format.
      Parameters:
      filePath - folder path where the file resides
      fileName - file name to look up
      far - file archive repository
      Returns:
      archive record identifier, or -1 when no record matches