public SiteNodeVersionVO getLatestSiteNodeVersionVO(Integer siteNodeId) throws SystemException, Bug
{
String key = "" + siteNodeId;
SiteNodeVersionVO siteNodeVersionVO = (SiteNodeVersionVO)CacheController.getCachedObjectFromAdvancedCache("latestSiteNodeVersionCache", key);
if(siteNodeVersionVO != null)
{
if(logger.isInfoEnabled())
logger.info("There was an cached siteNodeVersionVO:" + siteNodeVersionVO);
}
else
{
SiteNodeVersion siteNodeVersion = null;
Database db = CastorDatabaseService.getDatabase();
ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
beginTransaction(db);
try
{
OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SmallSiteNodeVersionImpl cv WHERE cv.siteNodeId = $1 ORDER BY cv.siteNodeVersionId desc");
oql.bind(siteNodeId);
QueryResults results = oql.execute(Database.READONLY);
if (results.hasMore())
{
siteNodeVersion = (SiteNodeVersion)results.next();
}
results.close();
oql.close();
if(siteNodeVersion != null)
siteNodeVersionVO = siteNodeVersion.getValueObject();
else
logger.warn("The siteNode " + siteNodeId + " did not have a latest active siteNodeVersion - very strange.");
if(siteNodeVersionVO != null)
{
String groupKey1 = CacheController.getPooledString(4, siteNodeVersionVO.getId());
String groupKey2 = CacheController.getPooledString(3, siteNodeId);
CacheController.cacheObjectInAdvancedCache("latestSiteNodeVersionCache", key, siteNodeVersionVO, new String[]{groupKey1, groupKey2}, true);
}
commitTransaction(db);