* This method returns the latest sitenodeVersion there is for the given siteNode.
*/
public SiteNodeVersion getLatestActiveSiteNodeVersion(Integer siteNodeId, Database db) throws SystemException, Exception
{
SiteNodeVersion siteNodeVersion = null;
String versionKey = "" + siteNodeId + "_" + getOperatingMode() + "_siteNodeVersionId";
//Integer siteNodeVersionId = (Integer)CacheController.getCachedObject("latestSiteNodeVersionCache", versionKey);
Integer siteNodeVersionId = (Integer)CacheController.getCachedObjectFromAdvancedCache("latestSiteNodeVersionCache", versionKey);
if(siteNodeVersionId != null)
{
logger.info("There was a cached sitenode version id:" + siteNodeVersionId);
siteNodeVersion = (SiteNodeVersion)getObjectWithId(SiteNodeVersionImpl.class, siteNodeVersionId, db);
}
else
{
OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.stateId >= $2 AND cv.isActive = $3 ORDER BY cv.siteNodeVersionId desc");
oql.bind(siteNodeId);
oql.bind(getOperatingMode());
oql.bind(true);
QueryResults results = oql.execute(Database.READONLY);
if (results.hasMore())
{
siteNodeVersion = (SiteNodeVersion)results.next();
//CacheController.cacheObject("latestSiteNodeVersionCache", versionKey, siteNodeVersion.getId());
String groupKey1 = CacheController.getPooledString(4, siteNodeVersion.getId());
String groupKey2 = CacheController.getPooledString(3, siteNodeId);
CacheController.cacheObjectInAdvancedCache("latestSiteNodeVersionCache", versionKey, siteNodeVersion.getId(), new String[]{groupKey1, groupKey2}, true);
}
results.close();
oql.close();
}