public class QuotaManager extends java.lang.Object implements JPropertiesListener, AssociatedFilesEventListener, AlarmListener
Modifier and Type | Class and Description |
---|---|
static class |
QuotaManager.WorkspaceNode
Inner class to save a workspace and it's level in hierarchy
|
static class |
QuotaManager.WorkspaceNodeComparator |
REVISION
REVISION
Modifier and Type | Method and Description |
---|---|
void |
addDocumentToVersionCache(FileDocument fileDoc) |
void |
addDocumentVersionToVersionCache(FileDocument oldFileDoc,
FileDocument fileDoc) |
void |
associatedFileEventFired(AssociatedFileEvent event)
Trigger a quota refresh if a new associated file is added/updated or deleted
|
void |
checkQuotas()
Check all quotas and send notifications if needed.
|
void |
checkQuotas(Workspace workspace)
Check workspace quota and send notifications if needed, this method is called after the end of an analyzeThread.
|
static FileSize |
computeFileSizes(java.io.File realFile,
AssociatedFilesManager afMgr)
Compute file size (with and without associated files)
|
AssociatedFilesEventListener |
createAssociatedFilesEventListener() |
void |
deleteDocumentFromVersionCache(FileDocument fileDoc) |
FileAnalyzerThread |
executeFileAnalyzerThread(Workspace workspace) |
static java.util.List<QuotaManager.WorkspaceNode> |
generateWorkspaceTreeList()
|
java.util.concurrent.ExecutorService |
getAnalyzerThreadPool()
get analyzer thread pool use to compute workspace file analyze in background mode
|
java.util.List<java.lang.String> |
getCachedVersionList(FileDocument fileDoc) |
FileSize |
getCacheFileSize(java.io.File file)
get the cache file size with computed size
|
QuotaElement |
getChannelQuotaAlert() |
FileAnalyzerThread |
getCurrentChannelAnalyzerThread()
Return the current analyzer thread if analyze is in progress
|
int |
getDefaultAlertThreshold() |
long |
getDefaultQuotaSize() |
QuotaElement |
getElement(Workspace wk)
create a
QuotaElement for a Workspace . |
java.util.Map<Workspace,QuotaElement> |
getElements()
returns the
Map with all QuotaElement per workspace, the value with the null key is for the whole site. |
java.util.Map<Workspace,QuotaElement> |
getElements(Workspace workspace)
returns the
Map with all QuotaElement per workspace, the value with the null key is for the whole site. |
WorkspaceFileAnalyzer |
getGlobalFileAnalyzer(boolean refresh)
returns
WorkspaceFileAnalyzer instance associated with this site. |
static QuotaManager |
getInstance() |
long |
getLastChannelQuotaNotificationDate() |
QuotaElement |
getSiteElement()
create a
QuotaElement for a whiole site. |
void |
handleAlarm(AlarmEntry entry)
Manage periodically quota refresh
|
void |
handleFileAnalyzeEnd(WorkspaceFileAnalyzer fileAnalyzer)
This method is called when global file analyzer has end
|
boolean |
isQuotaEnabled() |
boolean |
isUploadAccepted(DocUploadInfo info)
indicates if document can be uploaded (regarding the global site quota)
|
boolean |
isUploadAccepted(DocUploadInfo info,
Workspace wk)
indicates if document can be uploaded (regarding the global site quota and provided workspace if not null)
|
boolean |
isUploadAccepted(long fileLength,
Workspace wk)
indicates if document can be uploaded (regarding the global site quota and provided workspace if not null)
|
boolean |
isUploadEnabled()
indicates if upload is enabled for all the site
|
boolean |
isUploadEnabled(Workspace wk)
indicates if upload is enabled for all the site and provided workspace if not null
|
void |
propertiesChange(JProperties properties)
Invoked after properties have been modified in JCMS and save on disk.
|
protected void |
readProperties() |
void |
setChannelQuotaAlert(QuotaElement channelQuotaAlert) |
void |
setDefaultAlertThreshold(int defaultAlertThreshold) |
void |
setDefaultQuotaSize(long defaultQuotaSize) |
void |
setLastChannelQuotaNotificationDate(long lastChannelQuotaNotificationDate) |
void |
shutdownThreads() |
void |
updateAfterFileChange(java.io.File file)
update quota after a file change
|
void |
updateAfterFileDocumentChange(FileDocument fileDoc)
update quota after a filedocument change
|
void |
updateCacheFileSize(java.io.File file,
FileSize fileSizeObj)
update the cache file size with computed size
|
void |
updateQuota(Workspace wk)
Update workspace quota in separate threads
|
void |
updateWorkspacesQuota()
Update all workspaces quota in separate threads
|
public static final java.lang.String ADMIN_QUOTA_DEFAULT_WORKSPACE_QUOTA
public static final java.lang.String ADMIN_QUOTA_MAXIMUM_SITE_QUOTA
public static final java.lang.String ADMIN_QUOTA_DEFAULT_WORKSPACE_ALERT_THRESHOLD
public static final java.lang.String ADMIN_QUOTA_SITE_ALERT_THRESHOLD
public static final java.lang.String ADMIN_QUOTA_DELAY_BETWEEN_QUOTA_ALERT
public static final java.lang.String ADMIN_QUOTA_CHECK_SCHEDULE
public static final java.lang.String CHANNEL_FILE_ANALYZER_THREAD_POOL_SIZE
public static final java.lang.String CHANNEL_QUOTA_MANAGEMENT_ENABLED
public static final java.lang.String REJECT_UPLOAD_OVER_QUOTA_PROPERTIES_NAME
public static final int DEFAULT_ALERT_THRESHOLD
public static final long DEFAULT_WORKSPACE_QUOTA
public static final long DEFAULT_SITE_QUOTA
public static final long DEFAULT_DELAY
public static final boolean ENABLED_DEFAULT
protected transient WorkspaceFileAnalyzer channelFileAnalyzer
protected transient WorkspaceFileAnalyzer previousChannelFileAnalyzer
protected transient FileAnalyzerThread currentChannelAnalyzerThread
protected transient java.util.concurrent.ExecutorService analyzerThreadPool
protected transient long lastChannelQuotaNotificationDate
protected transient QuotaElement channelQuotaAlert
protected transient java.util.Map<java.lang.String,FileSize> cacheFileSize
public static QuotaManager getInstance()
public void propertiesChange(JProperties properties)
JPropertiesListener
You cannot alter the value received in parameters.
propertiesChange
in interface JPropertiesListener
properties
- the properties which have been modified (may not contain all JCMS properties)protected void readProperties()
public QuotaElement getElement(Workspace wk)
QuotaElement
for a Workspace
. If the workspace has a running analyze thread, this method will return nullwk
- the Workspace
QuotaElement
public QuotaElement getSiteElement()
QuotaElement
for a whiole site. If the site has a running analyze thread, this method will return nullQuotaElement
public java.util.Map<Workspace,QuotaElement> getElements()
Map
with all QuotaElement
per workspace, the value with the null key is for the whole site. Values can be null is a running analyze thread exists for the workspace or site.Map
with all QuotaElement
per workspace, the value with the null key is for the whole site. Values can be null is a running analyze thread exists for the workspace or site.public java.util.Map<Workspace,QuotaElement> getElements(Workspace workspace)
Map
with all QuotaElement
per workspace, the value with the null key is for the whole site. Values can be null is a running analyze thread exists for the workspace or site.workspace
- the workspace used to filter elements (if null, global element are returned)Map
with all QuotaElement
per workspace, the value with the null key is for the whole site. Values can be null is a running analyze thread exists for the workspace or site.public boolean isQuotaEnabled()
public long getDefaultQuotaSize()
public void setDefaultQuotaSize(long defaultQuotaSize)
public int getDefaultAlertThreshold()
public void setDefaultAlertThreshold(int defaultAlertThreshold)
public AssociatedFilesEventListener createAssociatedFilesEventListener()
public void updateWorkspacesQuota()
public void updateQuota(Workspace wk)
wk
- the workspacepublic void associatedFileEventFired(AssociatedFileEvent event)
associatedFileEventFired
in interface AssociatedFilesEventListener
public void updateAfterFileChange(java.io.File file)
file
- the File
public void updateAfterFileDocumentChange(FileDocument fileDoc)
fileDoc
- the FileDocument
public void handleAlarm(AlarmEntry entry)
handleAlarm
in interface AlarmListener
entry
- the AlarmEntry which has been triggered.public void checkQuotas()
public void checkQuotas(Workspace workspace)
workspace
- the workspace to check, or null for the global sirepublic FileAnalyzerThread executeFileAnalyzerThread(Workspace workspace)
public java.util.concurrent.ExecutorService getAnalyzerThreadPool()
ExecutorService
public WorkspaceFileAnalyzer getGlobalFileAnalyzer(boolean refresh)
WorkspaceFileAnalyzer
instance associated with this site. Note that as file analyze is down asynchronously, this method should returns null if an analyze is in progress (or if refresh is asked).
In this case, user should ask getCurrentAnalyzerThread() to retrieve the analyze thread. getCompleteness() method on the thread can be used to know the state of the thread.refresh
- force to ignore data previously present in cacheWorkspaceFileAnalyzer
instance associated with this site or null if an analyze is in progress (or if refresh is asked).public FileAnalyzerThread getCurrentChannelAnalyzerThread()
FileAnalyzerThread
or null if no analyze is runningpublic void handleFileAnalyzeEnd(WorkspaceFileAnalyzer fileAnalyzer)
fileAnalyzer
- a WorkspaceFileAnalyzerpublic long getLastChannelQuotaNotificationDate()
public void setLastChannelQuotaNotificationDate(long lastChannelQuotaNotificationDate)
public QuotaElement getChannelQuotaAlert()
public void setChannelQuotaAlert(QuotaElement channelQuotaAlert)
public void shutdownThreads()
public void updateCacheFileSize(java.io.File file, FileSize fileSizeObj)
file
- the File
used to generate map keyfileSizeObj
- the FileSize
to storepublic FileSize getCacheFileSize(java.io.File file)
file
- the File
used to generate map keypublic static FileSize computeFileSizes(java.io.File realFile, AssociatedFilesManager afMgr)
realFile
- the File
afMgr
- the current AssociatedFilesManager
if anypublic static java.util.List<QuotaManager.WorkspaceNode> generateWorkspaceTreeList()
Workspace
List
already sortedpublic java.util.List<java.lang.String> getCachedVersionList(FileDocument fileDoc)
public void addDocumentToVersionCache(FileDocument fileDoc)
public void addDocumentVersionToVersionCache(FileDocument oldFileDoc, FileDocument fileDoc)
public void deleteDocumentFromVersionCache(FileDocument fileDoc)
public boolean isUploadEnabled()
JcmsMessage
is available in JcmsContext
if it's disabled and a request exists.public boolean isUploadEnabled(Workspace wk)
wk
- the Workspace
to check for quotaJcmsMessage
is available in JcmsContext
if it's disabled and a request exists.public boolean isUploadAccepted(DocUploadInfo info)
info
- the DocUploadInfo
used to compute new sizeJcmsMessage
is available in JcmsContext
if it's disabled.public boolean isUploadAccepted(DocUploadInfo info, Workspace wk)
info
- the DocUploadInfo
used to compute new sizewk
- the Workspace
to check for quotaJcmsMessage
is available in JcmsContext
if it's disabled.public boolean isUploadAccepted(long fileLength, Workspace wk)
fileLength
- the length of the file used to compute new sizewk
- the Workspace
to check for quotaJcmsMessage
is available in JcmsContext
if it's disabled.Copyright © 2001-2017 Jalios SA. All Rights Reserved.