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 class
PersistenceService.LoadingBean
static class
PersistenceService.MetaPersistenceBean
-
Field Summary
Fields Modifier and Type Field Description Integer
__version
protected boolean
canRedo
TimeMap<Long,DayInfo>
dayInfoCache
static String
GLOBAL_MAP_NAME
protected static Logger
logger
create a static logger.static SimpleDateFormat
PERSISTENCE_DATE_FORMAT
static boolean
STORE_DATA_PROPERTIES
static String
STORE_FILE_PREFIX
static int
UNDO_DEPTH
-
Constructor Summary
Constructors Constructor Description PersistenceService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRedo()
boolean
canUndo()
int
checkStructureIntegrity(ContentContext ctx, PrintStream out, MenuElement root)
boolean
clean(ContentContext ctx)
void
cleanFile()
void
clearTrackCache()
void
correctAllFiles()
protected void
finalize()
void
flush()
Track[]
getAllTrack(Date day)
get list of track access to a resource.static Track[]
getAllTrack(Date day, String trackingDir)
List<Date>
getBackupDates()
String
getBackupDirectory()
String
getDirectory()
static PersistenceService
getInstance(GlobalContext globalContext)
static String
getKey(GlobalContext globalContext)
String
getPersistenceFilePrefix(int mode)
List<PersistenceService.MetaPersistenceBean>
getPersistences()
Properties
getTrackCache()
DayInfo
getTrackDayInfo(Calendar cal, Map<String,Object> globalMem)
static DayInfo
getTrackDayInfo(Calendar cal, Map<String,Object> globalMem, TimeMap<Long,DayInfo> dayInfoCache, String trackingDir)
String
getTrackingDirectory()
int
getVersion()
protected File
getXMLPersistenceFile(int mode)
File
getXMLPersistenceFile(int mode, long version)
void
insertContent(NodeXML pageXML, MenuElement elem, String defaultLg, boolean releaseID, boolean update)
MenuElement
insertPage(ContentContext ctx, NodeXML pageXML, MenuElement parent, Map<MenuElement,String[]> vparentPreparation, String defaultLg, boolean checkName, boolean updateIfExist)
boolean
isAskStore()
boolean
isFileExist(File file)
boolean
isLoaded()
boolean
isPreviewVersion(int version)
check if a preview version exist on FileSystem.MenuElement
load(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate)
protected MenuElement
load(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate, boolean correctXML, Integer previewVersion)
MenuElement
load(ContentContext ctx, int renderMode, Map<String,String> contentAttributeMap, Date timeTravelDate, Integer version)
protected PersistenceService.LoadingBean
load(ContentContext ctx, Object in, File propFile, Map<String,String> contentAttributeMap, TaxonomyBean taxonomyBean, int renderMode)
load data from InputStream of ReaderMenuElement
loadPreview(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 void
main(String[] args)
static Date
parseDate(String date)
void
publishPreviewFile(ContentContext ctx)
void
redo()
static String
renderDate(Date date)
void
resetVersion()
protected void
saveVersion()
void
sendPersistenceErrorToAdministrator(String message, File file, Throwable e)
void
setAskStore(boolean askStore)
ask storage of data at the end of requestboolean
setVersion(int version)
set preview version for next loading.void
store(ContentContext ctx)
void
store(ContentContext ctx, boolean async)
void
store(ContentContext ctx, int renderMode)
void
store(ContentContext ctx, int renderMode, boolean async)
void
store(Track track)
void
storeTrackCache()
void
storeView(InputStream in)
void
undo()
-
-
-
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:
ServiceException
InterruptedException
-
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:
IOException
ParseException
-
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()
-
-