Class FileArchiveService
java.lang.Object
sk.iway.iwcm.components.file_archiv.FileArchivSupportMethodsService
sk.iway.iwcm.components.file_archiv.FileArchiveService
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFile operation requested while an archive record is being saved. -
Field Summary
Fields inherited from class sk.iway.iwcm.components.file_archiv.FileArchivSupportMethodsService
cachePrefix, currentUser, domainId, errorList, errorParams, fab, fileToUpload, fileToUploadName, isPatternFile, prop, referenceId, renameFile, repository, request, sameFiles, saveAfterId, saveLater, SEPARATOR, uploadType -
Constructor Summary
ConstructorsConstructorDescriptionFileArchiveService(Identity user, Prop prop, FileArchivatorBean fab, FileArchiveRepository repository) Creates a service for one archive entity and initializes its requested file operation. -
Method Summary
Modifier and TypeMethodDescriptionintRenames the current archive file when a new name was requested in the editor.voidcheckFileProperties(org.springframework.validation.Errors errors) voidcheckFileProperties(org.springframework.validation.Errors errors, boolean requireEditPermission) Validates file properties while optionally enforcing the archive edit permission.Deletes a main archive record together with its history versions, patterns, and physical files.Deletes the current waiting upload and its associated pattern files.final String[]static final LonggetId(String filePath, String fileName, FileArchiveRepository far) Finds the ID of an existing archive file by its folder path and file name.static FileArchiveServicegetInstance(Identity user, Long fileArchivId) Creates an archive service for legacy Java and JSP callers outside Spring dependency injection.final List<FileArchivatorBean>static final List<LabelValue>getStatusIconOptions(Prop prop) Builds localized status filters for the archive table.getUploadType(String key) Converts a request value to a supported archive upload operation.static final List<LabelValue>getUploadTypeOptions(Prop prop) Builds the localized upload-operation options shown by the archive editor.static List<FileArchivatorBean>getWaitingFileList(Long mainId, FileArchiveRepository repo) Returns scheduled uploads from the domain cache, optionally limited to one main file.moveBehind(int moveBelowFileId) Inserts the uploaded file into archive history immediately after a selected version.booleanrollback()Removes the current file from its version thread and promotes the preceding version.saveFile()Executes the selected archive record and file operation under the shared file-operation lock.Methods inherited from class sk.iway.iwcm.components.file_archiv.FileArchivSupportMethodsService
checkPerms, deleteFile, deleteFilePatterns, findSameFiles, getCacheTime, getFileDirPath, isConcurrentModification, isCorrectEmails, isUploadDateCorrect, normalizePath, normalizeToOldPath, prepareFileArchivatorBean, resolveFileDestinationDirPath, resolveFileDirPath, updateReferenceToMainFile, updateReferenceToMainFile
-
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 operationprop- localization provider, ornullto use the default providerfab- archive entity being processedrepository- archive repository, ornullto resolve the Spring bean
-
-
Method Details
-
getUploadType
Converts a request value to a supported archive upload operation.- Parameters:
key- upload operation key- Returns:
- matching upload type, or
FileArchiveService.UploadType.NO_ACTIONfor empty or unknown values
-
getUploadTypeOptions
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
Builds localized status filters for the archive table.- Parameters:
prop- localization provider- Returns:
- status filter labels and query values
-
getInstance
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 operationfileArchivId- identifier of the archive record- Returns:
- initialized service, or
nullwhen the record does not exist in the current domain
-
getErrorList
-
getErrorParams
-
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 errorsrequireEditPermission- whether the archive edit permission is required
-
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:
1when renamed,0when renaming fails, or-1when no rename was requested
-
rollback
public boolean rollback()Removes the current file from its version thread and promotes the preceding version.- Returns:
truewhen the rollback and history updates complete successfully
-
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
Deletes the current waiting upload and its associated pattern files.- Returns:
- an error key when deletion fails; otherwise
null
-
getWaitingFileList
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, ornullfor all recordsrepo- archive repository used when the cache is empty- Returns:
- waiting archive records, possibly filtered by their main-file identifier
-
moveBehind
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
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 residesfileName- file name to look upfar- file archive repository- Returns:
- archive record identifier, or
-1when no record matches
-