Package org.javlo.service
Class PersistenceService
- java.lang.Object
-
- org.javlo.service.PersistenceService
-
- Direct Known Subclasses:
TestPersistenceService
public class PersistenceService extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPersistenceService.LoadingBeanstatic classPersistenceService.MetaPersistenceBean
-
Field Summary
Fields Modifier and Type Field Description Integer__versionprotected booleancanRedoTimeMap<Long,DayInfo>dayInfoCachestatic StringGLOBAL_MAP_NAMEprotected static Loggerloggercreate a static logger.static SimpleDateFormatPERSISTENCE_DATE_FORMATstatic booleanSTORE_DATA_PROPERTIESstatic StringSTORE_FILE_PREFIXstatic intUNDO_DEPTH
-
Constructor Summary
Constructors Constructor Description PersistenceService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRedo()booleancanUndo()intcheckStructureIntegrity(ContentContext ctx, PrintStream out, MenuElement root)booleanclean(ContentContext ctx)voidcleanFile()voidclearTrackCache()voidcorrectAllFiles()protected voidfinalize()voidflush()Track[]getAllTrack(Date day)get list of track access to a resource.static Track[]getAllTrack(Date day, String trackingDir)List<Date>getBackupDates()StringgetBackupDirectory()StringgetDirectory()static PersistenceServicegetInstance(GlobalContext globalContext)static StringgetKey(GlobalContext globalContext)StringgetPersistenceFilePrefix(int mode)List<PersistenceService.MetaPersistenceBean>getPersistences()PropertiesgetTrackCache()DayInfogetTrackDayInfo(Calendar cal, Map<String,Object> globalMem)static DayInfogetTrackDayInfo(Calendar cal, Map<String,Object> globalMem, TimeMap<Long,DayInfo> dayInfoCache, String trackingDir)StringgetTrackingDirectory()intgetVersion()protected FilegetXMLPersistenceFile(int mode)FilegetXMLPersistenceFile(int mode, long version)voidinsertContent(NodeXML pageXML, MenuElement elem, String defaultLg, boolean releaseID, boolean update)MenuElementinsertPage(ContentContext ctx, NodeXML pageXML, MenuElement parent, Map<MenuElement,String[]> vparentPreparation, String defaultLg, boolean checkName, boolean updateIfExist)booleanisAskStore()booleanisFileExist(File file)booleanisLoaded()booleanisPreviewVersion(int version)check if a preview version exist on FileSystem.MenuElementload(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate)protected MenuElementload(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate, boolean correctXML, Integer previewVersion)MenuElementload(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate, Integer version)protected PersistenceService.LoadingBeanload(ContentContext ctx, Object in, File propFile, Map<String,String> contentAttributeMap, TaxonomyBean taxonomyBean, int renderMode)load data from InputStream of ReaderMenuElementloadPreview(ContentContext ctx, Integer version)load a specific preview version.Track[]loadTracks(Date from, Date to, boolean onlyViewClick, boolean onlyResource)load current version of preview content.static Track[]loadTracks(Date from, Date to, boolean onlyViewClick, boolean onlyResource, String trackingDir)static voidmain(String[] args)static DateparseDate(String date)voidpublishPreviewFile(ContentContext ctx)voidredo()static StringrenderDate(Date date)voidresetVersion()protected voidsaveVersion()voidsendPersistenceErrorToAdministrator(String message, File file, Throwable e)voidsetAskStore(boolean askStore)ask storage of data at the end of requestbooleansetVersion(int version)set preview version for next loading.voidstore(ContentContext ctx)voidstore(ContentContext ctx, boolean async)voidstore(ContentContext ctx, int renderMode)voidstore(ContentContext ctx, int renderMode, boolean async)voidstore(Track track)voidstoreTrackCache()voidstoreView(InputStream in)voidundo()
-
-
-
Field Detail
-
STORE_DATA_PROPERTIES
public static boolean STORE_DATA_PROPERTIES
-
logger
protected static Logger logger
create a static logger.
-
PERSISTENCE_DATE_FORMAT
public static SimpleDateFormat PERSISTENCE_DATE_FORMAT
-
GLOBAL_MAP_NAME
public static final String GLOBAL_MAP_NAME
- See Also:
- Constant Field Values
-
STORE_FILE_PREFIX
public static final String STORE_FILE_PREFIX
- See Also:
- Constant Field Values
-
UNDO_DEPTH
public static int UNDO_DEPTH
-
__version
public Integer __version
-
canRedo
protected boolean canRedo
-
-
Method Detail
-
parseDate
public static final Date parseDate(String date) throws ParseException
- Throws:
ParseException
-
getInstance
public static final PersistenceService getInstance(GlobalContext globalContext) throws ServiceException
- Throws:
ServiceException
-
getKey
public static String getKey(GlobalContext globalContext)
-
canRedo
public boolean canRedo()
-
canUndo
public boolean canUndo()
-
cleanFile
public void cleanFile()
-
correctAllFiles
public void correctAllFiles()
-
getPersistences
public List<PersistenceService.MetaPersistenceBean> getPersistences()
-
getBackupDirectory
public String getBackupDirectory()
-
getDirectory
public String getDirectory()
-
getTrackingDirectory
public String getTrackingDirectory()
-
getAllTrack
public Track[] getAllTrack(Date day)
get list of track access to a resource.- Returns:
- a list of track.
-
getTrackDayInfo
public DayInfo getTrackDayInfo(Calendar cal, Map<String,Object> globalMem) throws IOException
- Throws:
IOException
-
getTrackDayInfo
public static DayInfo getTrackDayInfo(Calendar cal, Map<String,Object> globalMem, TimeMap<Long,DayInfo> dayInfoCache, String trackingDir) throws IOException
- Throws:
IOException
-
getTrackCache
public Properties getTrackCache()
-
clearTrackCache
public void clearTrackCache()
-
storeTrackCache
public void storeTrackCache()
-
finalize
protected void finalize() throws Throwable
-
getVersion
public int getVersion()
-
resetVersion
public void resetVersion()
-
insertContent
public void insertContent(NodeXML pageXML, MenuElement elem, String defaultLg, boolean releaseID, boolean update) throws DebugHelper.StructureException
- Throws:
DebugHelper.StructureException
-
insertPage
public MenuElement insertPage(ContentContext ctx, NodeXML pageXML, MenuElement parent, Map<MenuElement,String[]> vparentPreparation, String defaultLg, boolean checkName, boolean updateIfExist) throws DebugHelper.StructureException, IOException
-
load
protected PersistenceService.LoadingBean load(ContentContext ctx, Object in, File propFile, Map<String,String> contentAttributeMap, TaxonomyBean taxonomyBean, int renderMode) throws ServiceException, InterruptedException
load data from InputStream of Reader- Parameters:
ctx-in- can Reader of InputStreamcontentAttributeMap-renderMode-- Returns:
- Throws:
ServiceExceptionInterruptedException
-
load
public MenuElement load(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate) throws Exception
- Throws:
Exception
-
load
public MenuElement load(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate, Integer version) throws Exception
- Throws:
Exception
-
isPreviewVersion
public boolean isPreviewVersion(int version)
check if a preview version exist on FileSystem.- Parameters:
version-- Returns:
-
isFileExist
public boolean isFileExist(File file)
-
loadPreview
public MenuElement loadPreview(ContentContext ctx, Integer version) throws Exception
load a specific preview version.- Parameters:
ctx-version-- Returns:
- Throws:
Exception
-
checkStructureIntegrity
public int checkStructureIntegrity(ContentContext ctx, PrintStream out, MenuElement root)
-
getPersistenceFilePrefix
public String getPersistenceFilePrefix(int mode)
-
load
protected MenuElement load(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate, boolean correctXML, Integer previewVersion) throws Exception
- Throws:
Exception
-
loadTracks
public Track[] loadTracks(Date from, Date to, boolean onlyViewClick, boolean onlyResource)
load current version of preview content.- Returns:
- the current version
- Throws:
IOException
-
loadTracks
public static Track[] loadTracks(Date from, Date to, boolean onlyViewClick, boolean onlyResource, String trackingDir)
-
publishPreviewFile
public void publishPreviewFile(ContentContext ctx) throws IOException, ParseException
- Throws:
IOExceptionParseException
-
redo
public void redo()
-
setVersion
public boolean setVersion(int version)
set preview version for next loading.- Parameters:
version- a content version- Returns:
- true if version has changed and false if this version doens'nt exist.
-
saveVersion
protected void saveVersion()
-
setAskStore
public void setAskStore(boolean askStore)
ask storage of data at the end of request- Parameters:
askStore-
-
isAskStore
public boolean isAskStore()
-
store
public void store(ContentContext ctx) throws Exception
- Throws:
Exception
-
store
public void store(ContentContext ctx, boolean async) throws Exception
- Throws:
Exception
-
store
public void store(ContentContext ctx, int renderMode) throws Exception
- Throws:
Exception
-
store
public void store(ContentContext ctx, int renderMode, boolean async) throws Exception
- Throws:
Exception
-
flush
public void flush()
-
storeView
public void storeView(InputStream in) throws Exception
- Throws:
Exception
-
undo
public void undo()
-
sendPersistenceErrorToAdministrator
public void sendPersistenceErrorToAdministrator(String message, File file, Throwable e) throws javax.mail.internet.AddressException
- Throws:
javax.mail.internet.AddressException
-
getXMLPersistenceFile
public File getXMLPersistenceFile(int mode, long version)
-
getXMLPersistenceFile
protected File getXMLPersistenceFile(int mode)
-
clean
public boolean clean(ContentContext ctx)
-
isLoaded
public boolean isLoaded()
-
-