public class AdminFileMgr extends AdminBaseMgr implements AdminFileMgrIf
AdminBaseMgr.StaticData
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
imageIOInitMutex
Mutex for ImageIO initialisation
|
protected static java.lang.String |
imageIOReadMutex
Mutex for ImageIO reads
|
protected static boolean |
initialisedImageIO
Indicates whether or not ImageIO has been initialised
|
private static java.util.Comparator<java.io.File> |
lastModifiedAtTopOrdering |
protected static org.apache.commons.logging.Log |
log |
protected static java.util.Set<java.lang.String> |
permittedLocations
Permitted Locations for File I/O
|
protected static boolean |
synchroniseImageIOReads
Indicates whether or not ImageIO Reads should be synchronised for thread-safety reasons
|
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, debugStackTraceExclusions, kkAdminPropsFilePath, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
Constructor and Description |
---|
AdminFileMgr(KKAdminIf eng)
The AdminFileMgr constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addImage(AdminImageOptions options)
Add the image to the object defined in the AdminImageOptions object.
|
void |
checkFileAccess(java.lang.String fileName)
Check that we allow access to this location according to the permitted locations as specified
in the konakartadmin.properties file
|
void |
checkFileAccess(java.lang.String fileName,
java.util.Set<java.lang.String> _permittedLocations)
Check that we allow access to this location
|
boolean |
copyFile(java.lang.String srcFileName,
java.lang.String dstFileName)
Copy the source file to the destination file.
|
boolean |
copyFiles(java.lang.String[] srcFileNames,
java.lang.String[] dstFileNames)
Copy the source file to the destination file.
|
boolean |
deleteFile(java.lang.String fileName)
Delete the file.
|
AdminFile[] |
getConfigFiles()
Returns an array containing the configuration files.
|
java.lang.String |
getFileContents(java.lang.String fileName)
Get the file contents.
|
java.lang.String |
getFileContents(java.lang.String fileName,
int offset)
Get the file contents from the specified offset.
|
byte[] |
getFileContentsAsByteArray(java.lang.String fileName)
Get the file contents as a byte array.
|
AdminFile[] |
getFiles(java.lang.String directory,
java.lang.String extension)
Returns an array of files found in the directory.
|
protected java.util.Set<java.lang.String> |
getPermittedLocations()
Parses the konakart.permittedLocations property value in konakartadmin.properties to find the
permitted locations for file I/O.
|
protected void |
initImageIO() |
protected static boolean |
isSynchroniseImageIOReads() |
void |
refreshConfigs()
Refresh the configuration of the Manager
|
void |
removeImage(AdminImageOptions options)
Remove the image (or images) from the object defined in the AdminImageOptions object.
|
boolean |
renameFile(java.lang.String srcFileName,
java.lang.String dstFileName)
Rename the source file to the destination file.
|
boolean |
renameFiles(java.lang.String[] srcFileNames,
java.lang.String[] dstFileNames)
Rename the source files to the destination files.
|
int |
rsyncDirectory(java.lang.String remoteSessionId,
KKAdminIf remoteEng,
java.lang.String localSessionId,
KKAdminIf localEng,
java.lang.String remoteDir,
java.lang.String localDir)
Sync the files in the specified directory using a local and a remote engine.
|
void |
saveFileContents(java.lang.String fileName,
java.lang.String fileContents)
Writes the specified file contents into the specified file.
|
boolean |
scaleImage(AdminScaleOptions scaleOptions)
Scale the specified image to the specified name and dimensions.
|
protected static void |
setSynchroniseImageIOReads(boolean synchroniseImageIOReads) |
addInsertAttr, addInsertAttr, addStringRuleConstraint, addStringRuleConstraint, checkAPICallEnabled, checkIntInRange, checkIntIsSet, checkRequired, executeQuery, executeQuery, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminContentMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustPwdHistMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminEngineCacheMgr, getAdminEventMgr, getAdminExecuteMgr, getAdminFileMgr, getAdminFilterMgr, getAdminHtmlMgr, getAdminImportMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminMiscPriceMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminServletMgr, getAdminShipmentMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminSuggestionMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getDebugStackTraceExclusions, getEmailThreadGracefulShutdownTimeout, getExportMgr, getExportMgr, getExportXMLData, getIntFromString, getKkAdminPropsFilePath, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getNewCriteria, getNewCriteria, getOtherModuleByName, getPostSearchText, getPreSearchText, getProductsToCategoresCriteria, getPropertyValue, getPropertyValue, getPropertyValueAsBool, getPropertyValueAsInt, getPropertyValueAsLong, getRecordCount, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, insertKKEvent, insertKKEvent, isBusiness, isBusinessOrEnterprise, isCommunity, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareCustomersOrProducts, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, isUnix, isWindows, manageException, manageThrowable, removeCData, sendMQMessages, setAdminEng, setDebugStackTraceExclusions, setKkAdminPropsFilePath, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr, updateStaticVariablesNow
protected static org.apache.commons.logging.Log log
protected static boolean initialisedImageIO
protected static boolean synchroniseImageIOReads
protected static java.lang.String imageIOInitMutex
protected static java.util.Set<java.lang.String> permittedLocations
protected static java.lang.String imageIOReadMutex
private static final java.util.Comparator<java.io.File> lastModifiedAtTopOrdering
public AdminFileMgr(KKAdminIf eng) throws java.lang.Exception
eng
- the engjava.lang.Exception
- an unexpected exceptionpublic void checkFileAccess(java.lang.String fileName) throws KKAdminException
checkFileAccess
in interface AdminFileMgrIf
fileName
- the file to be accessed (read or written)KKAdminException
- if access to the filepath isn't permitted a Exception is thrown otherwise the
method returns successfully.public void checkFileAccess(java.lang.String fileName, java.util.Set<java.lang.String> _permittedLocations) throws KKAdminException
checkFileAccess
in interface AdminFileMgrIf
fileName
- the file to be accessed (read or written)_permittedLocations
- a set of Strings that are sub-strings of filepaths of permitted locations. A
normalised filepath is permitted if it contains one of the permitted location
substrings.KKAdminException
- if access to the filepath isn't permitted a KKAdminException is thrown otherwise
the method returns successfully.public java.lang.String getFileContents(java.lang.String fileName) throws KKAdminException
getFileContents
in interface AdminFileMgrIf
fileName
- the filename in the server's contextKKAdminException
- if the file's not present or can't be read, or it's not a text filepublic java.lang.String getFileContents(java.lang.String fileName, int offset) throws KKAdminException
getFileContents
in interface AdminFileMgrIf
fileName
- the filename in the server's contextoffset
- the offset from the start of the file in bytesKKAdminException
- if the file's not present or can't be read, or it's not a text filepublic void saveFileContents(java.lang.String fileName, java.lang.String fileContents) throws KKAdminException
saveFileContents
in interface AdminFileMgrIf
fileName
- the filename in the server's contextfileContents
- the file contents to writeKKAdminException
- on any Security or IO problems that prevent us from saving the data to the file
or if the API call is disabledpublic boolean deleteFile(java.lang.String fileName) throws KKAdminException
deleteFile
in interface AdminFileMgrIf
fileName
- the filename in the server's contextKKAdminException
- if the file's not present or can't be deleted or if the API call is disabledpublic boolean copyFiles(java.lang.String[] srcFileNames, java.lang.String[] dstFileNames) throws KKAdminException
copyFiles
in interface AdminFileMgrIf
srcFileNames
- the filename in the server's context to copy fromdstFileNames
- the filename in the server's context to copy toKKAdminException
- if the source file's not present or can't be copied or if the API call is
disabledpublic boolean copyFile(java.lang.String srcFileName, java.lang.String dstFileName) throws KKAdminException
copyFile
in interface AdminFileMgrIf
srcFileName
- the filename in the server's context to copy fromdstFileName
- the filename in the server's context to copy toKKAdminException
- if the source file's not present or can't be copied or if the API call is
disabledpublic boolean renameFiles(java.lang.String[] srcFileNames, java.lang.String[] dstFileNames) throws KKAdminException
renameFiles
in interface AdminFileMgrIf
srcFileNames
- an array of filenames in the server's context to rename fromdstFileNames
- an array of filenames in the server's context to rename toKKAdminException
- if any of the source file are not present or can't be renamedpublic boolean renameFile(java.lang.String srcFileName, java.lang.String dstFileName) throws KKAdminException
renameFile
in interface AdminFileMgrIf
srcFileName
- the filename in the server's context to rename fromdstFileName
- the filename in the server's context to rename toKKAdminException
- if the source file's not present or can't be renamedpublic AdminFile[] getConfigFiles() throws KKAdminException
AdminFileMgrIf
getConfigFiles
in interface AdminFileMgrIf
KKAdminException
- unexpected exception in the KonaKart Admin Enginepublic AdminFile[] getFiles(java.lang.String directory, java.lang.String extension) throws KKAdminException
getFiles
in interface AdminFileMgrIf
directory
- the directoryextension
- the extensionKKAdminException
- unexpected exception in the KonaKart Admin Enginepublic byte[] getFileContentsAsByteArray(java.lang.String fileName) throws KKAdminException
getFileContentsAsByteArray
in interface AdminFileMgrIf
fileName
- the filename in the server's contextKKAdminException
- if the file's not present or can't be readpublic boolean scaleImage(AdminScaleOptions scaleOptions) throws KKAdminException
scaleImage
in interface AdminFileMgrIf
scaleOptions
- The scaling optionsKKAdminException
- unexpected exception in the KonaKart Admin Engineprotected void initImageIO()
public void addImage(AdminImageOptions options) throws KKAdminException
AdminFileMgrIf
When adding product images it uses the same conventions as used in the Admin Application and gets these definitions from the konakartadmin_gwt.properties file. Once an image is added to a product using this API the image will appear for the product in the Admin Application just as if it had been added via an image upload in the Admin application.
addImage
in interface AdminFileMgrIf
options
- The options that define which object the image should be added toKKAdminException
- if the image was not added successfullypublic void removeImage(AdminImageOptions options) throws KKAdminException
AdminFileMgrIf
removeImage
in interface AdminFileMgrIf
options
- The options that define which images should be removedKKAdminException
- for any unexpected problemsprotected static boolean isSynchroniseImageIOReads()
protected static void setSynchroniseImageIOReads(boolean synchroniseImageIOReads)
synchroniseImageIOReads
- the synchroniseImageIOReads to setprotected java.util.Set<java.lang.String> getPermittedLocations()
public void refreshConfigs() throws java.lang.Exception
refreshConfigs
in interface AdminFileMgrIf
refreshConfigs
in class AdminBaseMgr
java.lang.Exception
- an unexpected exceptionpublic int rsyncDirectory(java.lang.String remoteSessionId, KKAdminIf remoteEng, java.lang.String localSessionId, KKAdminIf localEng, java.lang.String remoteDir, java.lang.String localDir) throws KKAdminException
rsyncDirectory
in interface AdminFileMgrIf
remoteSessionId
- sessionId for the remote engineremoteEng
- the remote engine (probably a KKJSONAdminEng)localSessionId
- the local sessionId (could be the same as the remote sessionId for systems sharing
the same database)localEng
- the local engineremoteDir
- remote base directorylocalDir
- local base directory (often the same as the remote base directory)KKAdminException
- an unexpected exception in the KKAdmin engineCopyright © 2018 DS Data Systems UK Ltd.