Package de.valtech.aecu.core.history
Class HistoryUtil
- java.lang.Object
-
- de.valtech.aecu.core.history.HistoryUtil
-
public class HistoryUtil extends Object
Reads and writes history entries.- Author:
- Roland Gruber
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringATTR_ENDstatic StringATTR_PATHprotected static StringATTR_RESULTprotected static StringATTR_RUN_OUTPUTprotected static StringATTR_RUN_RESULTprotected static StringATTR_RUN_STATEprotected static StringATTR_RUN_TIMEprotected static StringATTR_STARTprotected static StringATTR_STATEstatic StringHISTORY_BASEBase node for history entriesstatic StringNODE_FALLBACK
-
Constructor Summary
Constructors Constructor Description HistoryUtil()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description de.valtech.aecu.api.service.HistoryEntrycreateHistoryEntry(org.apache.sling.api.resource.ResourceResolver resolver)Starts a new history entry.protected voidcreatePath(String path, org.apache.sling.api.resource.ResourceResolver resolver, String primaryType)Creates the folder at the given path if not yet existing.voidfinishHistoryEntry(de.valtech.aecu.api.service.HistoryEntry history, org.apache.sling.api.resource.ResourceResolver resolver)Finishes the history entry.List<de.valtech.aecu.api.service.HistoryEntry>getHistory(int startIndex, int count, org.apache.sling.api.resource.ResourceResolver resolver)Returns the last history entries.org.apache.sling.api.resource.ResourcegetHistoryEntryResource(org.apache.sling.api.resource.Resource child)Returns the base resource for a (fallback) script resource.voidpurgeHistory(org.apache.sling.api.resource.ResourceResolver resolver, int daysToKeep)Purges the history by keeping only entries within the set number of days.de.valtech.aecu.api.service.HistoryEntryreadHistoryEntry(org.apache.sling.api.resource.Resource resource)Reads a history entry from JCR.de.valtech.aecu.api.service.ExecutionResultreadHistorySingleResult(org.apache.sling.api.resource.Resource resource)Reads a single script run from history.voidselfCheck(org.apache.sling.api.resource.ResourceResolver resolver)Self test of history.voidstoreExecutionInHistory(de.valtech.aecu.api.service.HistoryEntry history, de.valtech.aecu.api.service.ExecutionResult result, org.apache.sling.api.resource.ResourceResolver resolver)Stores an execution run in existing history.
-
-
-
Field Detail
-
HISTORY_BASE
public static final String HISTORY_BASE
Base node for history entries- See Also:
- Constant Field Values
-
NODE_FALLBACK
public static final String NODE_FALLBACK
- See Also:
- Constant Field Values
-
ATTR_PATH
public static final String ATTR_PATH
- See Also:
- Constant Field Values
-
ATTR_RUN_OUTPUT
protected static final String ATTR_RUN_OUTPUT
- See Also:
- Constant Field Values
-
ATTR_RUN_STATE
protected static final String ATTR_RUN_STATE
- See Also:
- Constant Field Values
-
ATTR_RUN_RESULT
protected static final String ATTR_RUN_RESULT
- See Also:
- Constant Field Values
-
ATTR_RUN_TIME
protected static final String ATTR_RUN_TIME
- See Also:
- Constant Field Values
-
ATTR_RESULT
protected static final String ATTR_RESULT
- See Also:
- Constant Field Values
-
ATTR_STATE
protected static final String ATTR_STATE
- See Also:
- Constant Field Values
-
ATTR_START
protected static final String ATTR_START
- See Also:
- Constant Field Values
-
ATTR_END
protected static final String ATTR_END
- See Also:
- Constant Field Values
-
-
Method Detail
-
createHistoryEntry
public de.valtech.aecu.api.service.HistoryEntry createHistoryEntry(org.apache.sling.api.resource.ResourceResolver resolver) throws de.valtech.aecu.api.service.AecuExceptionStarts a new history entry.- Parameters:
resolver- resource resolver- Returns:
- history entry
- Throws:
de.valtech.aecu.api.service.AecuException- error setting up entry
-
storeExecutionInHistory
public void storeExecutionInHistory(de.valtech.aecu.api.service.HistoryEntry history, de.valtech.aecu.api.service.ExecutionResult result, org.apache.sling.api.resource.ResourceResolver resolver) throws de.valtech.aecu.api.service.AecuExceptionStores an execution run in existing history.- Parameters:
history- history entryresult- script execution resultresolver- resource resolver- Throws:
de.valtech.aecu.api.service.AecuException- error inserting history entry
-
finishHistoryEntry
public void finishHistoryEntry(de.valtech.aecu.api.service.HistoryEntry history, org.apache.sling.api.resource.ResourceResolver resolver)Finishes the history entry.- Parameters:
history- open history entryresolver- resource resolver
-
getHistory
public List<de.valtech.aecu.api.service.HistoryEntry> getHistory(int startIndex, int count, org.apache.sling.api.resource.ResourceResolver resolver)
Returns the last history entries. The search starts at the newest entry.- Parameters:
startIndex- start reading at this index (first is 0)count- number of entries to readresolver- resource resolver- Returns:
- history entries (newest first)
-
getHistoryEntryResource
public org.apache.sling.api.resource.Resource getHistoryEntryResource(org.apache.sling.api.resource.Resource child)
Returns the base resource for a (fallback) script resource.- Parameters:
child- child of base resource- Returns:
- base run resource
-
readHistoryEntry
public de.valtech.aecu.api.service.HistoryEntry readHistoryEntry(org.apache.sling.api.resource.Resource resource)
Reads a history entry from JCR.- Parameters:
resource- history resource- Returns:
- history entry
-
readHistorySingleResult
public de.valtech.aecu.api.service.ExecutionResult readHistorySingleResult(org.apache.sling.api.resource.Resource resource)
Reads a single script run from history.- Parameters:
resource- resource- Returns:
- result
-
createPath
protected void createPath(String path, org.apache.sling.api.resource.ResourceResolver resolver, String primaryType) throws de.valtech.aecu.api.service.AecuException
Creates the folder at the given path if not yet existing.- Parameters:
path- pathresolver- resource resolverprimaryType- primary type- Throws:
de.valtech.aecu.api.service.AecuException- error creating folder
-
purgeHistory
public void purgeHistory(org.apache.sling.api.resource.ResourceResolver resolver, int daysToKeep) throws org.apache.sling.api.resource.PersistenceExceptionPurges the history by keeping only entries within the set number of days.- Parameters:
resolver- resource resolverdaysToKeep- number of days to keep- Throws:
org.apache.sling.api.resource.PersistenceException- error deleting node
-
selfCheck
public void selfCheck(org.apache.sling.api.resource.ResourceResolver resolver) throws de.valtech.aecu.api.service.AecuExceptionSelf test of history. Checks if the history node exists.- Parameters:
resolver- resource resolver- Throws:
de.valtech.aecu.api.service.AecuException- check failed
-
-