Package org.infoglue.cms.entities.content

Examples of org.infoglue.cms.entities.content.ContentVersionVO


        contentVersionIds.addAll(templateController.getDeliveryContext().getUsedPageMetaInfoContentVersionIdSet());
       
      Set groups = new HashSet();
      if(templateController.getDeliveryContext().getUsedPageMetaInfoContentVersionIdSet().size() > 0)
      {
        ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getSmallContentVersionVOWithId((Integer)templateController.getDeliveryContext().getUsedPageMetaInfoContentVersionIdSet().toArray()[0], templateController.getDatabase());
        groups.add(CacheController.getPooledString(2, contentVersionVO.getId()));
        groups.add(CacheController.getPooledString(1, contentVersionVO.getContentId()));
      }
     
      if(groups.size() > 0)
      {
        CacheController.cacheObjectInAdvancedCacheWithGroupsAsSet("componentEditorVersionIdCache", versionKey, contentVersionIds, groups, true);
View Full Code Here


  {
    String imageHref = null;
    try
    {
      LanguageVO masterLanguage = LanguageController.getController().getMasterLanguage(ContentController.getContentController().getContentVOWithId(contentId, db).getRepositoryId(), db);
      ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, masterLanguage.getId(), db);
      if(contentVersionVO != null)
      {
        List digitalAssets = DigitalAssetController.getDigitalAssetVOList(contentVersionVO.getId(), db);
        Iterator i = digitalAssets.iterator();
        while(i.hasNext())
        {
          DigitalAssetVO digitalAssetVO = (DigitalAssetVO)i.next();
          if(digitalAssetVO.getAssetKey().equals(key))
View Full Code Here

      pageTemplateHTML += "<table border=\"0\" width=\"80%\" cellspacing=\"0\"><tr>";
      
      while(sortedPageTemplatesIterator.hasNext())
      {
        ContentVO contentVO = (ContentVO)sortedPageTemplatesIterator.next();
        ContentVersionVO contentVersionVO = this.getTemplateController().getContentVersion(contentVO.getId(), LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForSiteNode(getDatabase(), siteNodeId).getId(), false);
        if(contentVersionVO != null)
        {
          String imageUrl = this.getTemplateController().getAssetUrl(contentVO.getId(), "thumbnail");
             if(imageUrl == null || imageUrl.equals(""))
                 imageUrl = this.getRequest().getContextPath() + "/css/images/undefinedPageTemplate.jpg";
View Full Code Here

      db = CastorDatabaseService.getDatabase();
      CacheController.beginTransaction(db);

      // Setup
      Integer contentVersionId = new Integer(contentVersionIdString);
      ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(contentVersionId, db);
      int operationMode = Integer.parseInt(CmsPropertyHandler.getOperatingMode());
      if (contentVersionVO.getStateId() < operationMode)
      {
        logger.debug("Updated version had a to low state. State: " + contentVersionVO.getStateId() + ". Operation mode: " + operationMode);
      }
      else
      {
        Integer contentId = contentVersionVO.getContentId();
        Integer languageId = contentVersionVO.getLanguageId();
        Set<Integer> existingAssetIds = new HashSet<Integer>();

        logger.info("Starting asset on disc clean for ContentVersion. Id: " + contentId);

        // Get stuff from previous version
        ContentVersionVO previousContentVersionVO = ContentVersionController.getContentVersionController().getSecondLatestActiveContentVersionVO(contentId, languageId, false, db);
        if (logger.isInfoEnabled())
        {
          logger.info("Previous content version for cache cleaning of ContentVersion: " + contentVersionId + ". ContentVersion.id:" + (previousContentVersionVO == null ? "null" : previousContentVersionVO.getContentVersionId()));
        }
        if (previousContentVersionVO != null)
        {
          List<DigitalAssetVO> previousDigitalAssets = DigitalAssetController.getController().getDigitalAssetVOList(previousContentVersionVO.getContentVersionId(), db);
          for (DigitalAssetVO digitalAssetVO : previousDigitalAssets)
          {
            if (logger.isDebugEnabled())
            {
              logger.debug("Adding digital asset to previous assets. DigitalAsset.id: " + digitalAssetVO.getDigitalAssetId());
View Full Code Here

                          PageCacheHelper.getInstance().notify("content_" + contentId);
                          //clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                         
                          if((changes == null || changes.size() == 0) && CmsPropertyHandler.getOperatingMode().equals("3"))
                          {
                            ContentVersionVO oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
                            ContentVersionVO newContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, oldContentVersionVO.getLanguageId(), new Integer(CmsPropertyHandler.getOperatingMode()));
                            if(newContentVersionVO != null && oldContentVersionVO != null && newContentVersionVO.getId().equals(oldContentVersionVO.getId()))
                            {
                              oldContentVersionVO = null;
                              //System.out.println("SHIT - same version allready - must find other");
                              List<SmallestContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getSmallestContentVersionVOList(new Integer(contentId));
                              for(SmallestContentVersionVO cvVO : contentVersionVOList)
                              {
                                if(!cvVO.getId().equals(newContentVersionVO.getId()) && cvVO.getStateId().equals(new Integer(CmsPropertyHandler.getOperatingMode())) && cvVO.getLanguageId().equals(newContentVersionVO.getLanguageId()) && cvVO.getIsActive() && (oldContentVersionVO == null || oldContentVersionVO.getId() < cvVO.getId()))
                                {
                                  oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(cvVO.getId());
                                }
                              }
                            }
                           
                            //System.out.println("Now we should have current and previous version:" + newContentVersionVO + " / " + oldContentVersionVO);
                            if(newContentVersionVO != null && oldContentVersionVO != null)
                              changes = ContentVersionController.getContentVersionController().getChangedAttributeNames(newContentVersionVO, oldContentVersionVO);
                          }

                          //System.out.println("changes:" + changes);
                          for(String changedAttributeName : changes)
                          {
                            if(changedAttributeName.indexOf("ComponentStructure") > -1)
                            {
                              //Map allreadyFlushedEntries....
                              Set<String> groupEntries = (Set<String>)cacheInstance.getCache().cacheMap.getGroup("content_" + contentId + "_ComponentStructureDependency");
                              //System.out.println("groupEntries:" + groupEntries);
                              if(groupEntries != null)
                              {
                                System.out.println("groupEntries:" + groupEntries.size());
                                outer:for(String key : groupEntries)
                                {
                                  //System.out.println("key 1:" + key);
                                  try
                                  {
                                    //String[] usedEntities = (String[])cacheInstance.getFromCache(key + "_entities");
                                    byte[] usedEntitiesByteArray = (byte[])cacheInstance.getFromCache(key + "_entitiesAsByte");
                                    String usedEntitiesString = compressionHelper.decompress(usedEntitiesByteArray);
                                    //t.printElapsedTime("Decompress to " + usedEntitiesString.length() + " took");
                                    String[] usedEntities = StringUtils.split(usedEntitiesString, "|");
                                    //t.printElapsedTime("Split to usedEntities " + usedEntities.length + " took");
                                   
                                    ContentVersionVO newContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
                                    String newComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(newContentVersionVO, "ComponentStructure", false);
   
                                    for(String usedEntity : usedEntities)
                                    {
                                      //System.out.println("usedEntity:" + usedEntity);
                                      if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure("))
                                      {
                                        //System.out.println("Match - now lets parse: " + usedEntity);
                                        String arguments = usedEntity.substring(usedEntity.indexOf("(") + 1, usedEntity.indexOf(")"));
                                        Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.indexOf("=") + 1));
                                        String[] args = arguments.split(",");
                                        Integer componentId = new Integer(args[0]);
                                        String propertyName = args[1];
                                        Integer siteNodeId = new Integer(args[2]);
                                        Integer languageId = new Integer(args[3]);
                                        //System.out.println("componentId:" + componentId);
                                        //System.out.println("propertyName:" + propertyName);
                                        //System.out.println("siteNodeId:" + siteNodeId);
                                        //System.out.println("languageId:" + languageId);
                                     
                                        int newComponentPropertyHash = getPropertyAsStringHashCode(newComponentStructure, componentId, propertyName, siteNodeId, languageId);
                                        //System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
                                        //System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
                                        if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
                                        {
                                          //System.out.println("Yes - clearing - must have changed something important:" + usedEntity);
                                          PageCacheHelper.getInstance().notify(usedEntity);
                                          //clearFileCacheForGroup(cacheInstance, usedEntity);
                                        }
                                        else
                                        {
                                          //System.out.println("Flushing content_" + currentPageMetaInfoContentId + "_ComponentStructure just to catch page itself");
                                          //cacheInstance.flushGroup("content_" + currentPageMetaInfoContentId + "_ComponentStructure");
                                          //System.out.println("Flushing content_" + contentId + "_ComponentStructure just to catch page itself");
                                          //cacheInstance.flushGroup("content_" + contentId + "_ComponentStructure");
                                        }
                                       
                                      }
                                      else if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure:"))
                                      {
                                        //System.out.println("Match - now lets parse component order etc: " + usedEntity);
                                        String xPath = usedEntity.substring(usedEntity.indexOf(":") + 1, usedEntity.lastIndexOf("="));
                                        Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.lastIndexOf("=") + 1));
                                        //System.out.println("xPath:" + xPath);
                                       
                                        int newComponentPropertyHash = getComponentsAsStringHashCode(newComponentStructure, xPath);
                                        //System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
                                        //System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
                                        if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
                                        {
                                          //System.out.println("Yes - clearing - must have changed order or added/subtracted components:" + usedEntity);
                                          PageCacheHelper.getInstance().notify(usedEntity);
                                          //clearFileCacheForGroup(cacheInstance, usedEntity);
                                        }
                                      }
                                    }
                                  }
                                  catch (Exception ex)
                                  {
                                  //logger.error("Got error trying to update cache:" + ex.getMessage());
                                    logger.warn("Got error trying to update cache:" + ex.getMessage(), ex);

                                    //clearFileCacheForGroup(cacheInstance, "content_" + contentId + "_" + changedAttributeName);
                                    //cacheInstance.flushGroup("content_" + contentId + "_" + changedAttributeName);
                                    //logger.warn("Cleared pageCache for " + "content_" + contentId + "_" + changedAttributeName);

                                    break outer;
                                  }
                                }
                              }
                            }
                            else
                            {
                              PageCacheHelper.getInstance().notify("content_" + contentId + "_" + changedAttributeName);
                              //clearFileCacheForGroup(cacheInstance, "content_" + contentId + "_" + changedAttributeName);
                              //System.out.println("Cleared for " + "content_" + contentId + "_" + changedAttributeName);
                            }
                          } 

                          //t.printElapsedTime("Handled page cache extra");
                          RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Handled page cache extra", t.getElapsedTime())
                          //clearFileCacheForGroup(cacheInstance, "content_" + contentId);
                        }
                        else if(cacheName.equals("pageCache"))
                        {
                          //t.printElapsedTime("Page cache start");
                          RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Page cache start", t.getElapsedTime());
                          logger.info("Flushing pageCache for content type def");

                          String contentTypeDefKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId;
                          cacheInstance.flushGroup(contentTypeDefKey);
                          //cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                          //cacheInstance.flushGroup("content_" + contentVO.getId());
                          //System.out.println("Flushing:" + getPooledString(1, contentVO.getId()));
                          cacheInstance.flushGroup(getPooledString(1, new Integer(contentId)));
                          PageCacheHelper.getInstance().notify("content_" + contentId);

                          ContentVersionVO oldContentVersionVO = null;
                          ContentVersionVO newContentVersionVO = null;
                         
                          String debug = "";
                          if((changes == null || changes.size() == 0) && CmsPropertyHandler.getOperatingMode().equals("3"))
                          {
                            debug += "entityId:" + entityId + "\n";
                            debug += "contentId:" + contentId + "\n";
                            oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
                            debug += "oldContentVersionVO:" + oldContentVersionVO.getId() + ":" + oldContentVersionVO.getLanguageId() + "\n";
                            debug += "oldContentVersionVO:" + CmsPropertyHandler.getOperatingMode() + "\n";
                            newContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, oldContentVersionVO.getLanguageId(), new Integer(CmsPropertyHandler.getOperatingMode()));
                            debug += "newContentVersionVO:" + newContentVersionVO + "\n";
                            if(newContentVersionVO != null && oldContentVersionVO != null && newContentVersionVO.getId().equals(oldContentVersionVO.getId()))
                            {
                              debug += "newContentVersionVO:" + newContentVersionVO.getId() + "\n";
                              oldContentVersionVO = null;
                              debug += "SHIT - same version allready - must find other";
                              List<SmallestContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getSmallestContentVersionVOList(new Integer(contentId));
                              for(SmallestContentVersionVO cvVO : contentVersionVOList)
                              {
                                if(!cvVO.getId().equals(newContentVersionVO.getId()) && cvVO.getStateId().equals(new Integer(CmsPropertyHandler.getOperatingMode())) && cvVO.getLanguageId().equals(newContentVersionVO.getLanguageId()) && cvVO.getIsActive() && (oldContentVersionVO == null || oldContentVersionVO.getId() < cvVO.getId()))
                                {
                                  oldContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(cvVO.getId());
                                }
                              }
                              debug += "oldContentVersionVO:" + (oldContentVersionVO == null ? "null" : oldContentVersionVO.getId()) + "\n";
                            }
                           
                            //System.out.println("Now we should have current and previous version:" + newContentVersionVO + " / " + oldContentVersionVO);
                            if(newContentVersionVO != null && oldContentVersionVO != null)
                              changes = ContentVersionController.getContentVersionController().getChangedAttributeNames(newContentVersionVO, oldContentVersionVO);
                          }

                          //t.printElapsedTime("Changes analyzed");
                        //RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Changes analyzed", t.getElapsedTime());

                          if((changes == null || changes.size() == 0&& CmsPropertyHandler.getOperatingMode().equals("3"))
                          {
                            if(oldContentVersionVO == null || newContentVersionVO == null)
                            {
                              //Hur kan det bli detta????
                              logger.warn("Fishy 1: " + oldContentVersionVO + ":" + newContentVersionVO + " in " + CmsPropertyHandler.getContextRootPath());
                              logger.warn("DEBUG: " + debug);
                            }
                            else
                            {
                              logger.warn("Fishy 2: No changes found between content versions " + newContentVersionVO.getId() + " and " + oldContentVersionVO.getId() + " in " + CmsPropertyHandler.getContextRootPath());
                              logger.warn("DEBUG: " + debug);
                              logger.warn("Fishy: newContentVersionVO: " + newContentVersionVO.getVersionValue());
                              logger.warn("Fishy: newContentVersionVO: " + oldContentVersionVO.getVersionValue());
                            }
                            logger.warn("Just to make sure pages are updated we pretend all attributes changed until we find the bug");
                            changes = ContentVersionController.getContentVersionController().getAttributeNames(newContentVersionVO);
                          }
                         
                          //System.out.println("changes:" + changes);
                          for(String changedAttributeName : changes)
                          {
                            logger.warn("changedAttributeName: " + changedAttributeName);
                            if(changedAttributeName.indexOf("ComponentStructure") > -1 && cacheName.equals("pageCache"))
                            {
                              //Map allreadyFlushedEntries....
                              //It's something wrong here..
                              GeneralCacheAdministrator pageCacheExtraInstance = (GeneralCacheAdministrator)caches.get("pageCacheExtra");
                              String cacheGroupKey = "content_" + contentId + "_ComponentStructureDependency";
                              //Set<String> groupEntries = (Set<String>)cacheInstance.getCache().cacheMap.getGroup("content_" + contentId + "_ComponentStructureDependency");
                              Set<String> groupEntries = (Set<String>)cacheInstance.getCache().cacheMap.getGroup(getPooledString(cacheGroupKey.hashCode()));
                              //System.out.println("groupEntries:" + groupEntries);
                              if(groupEntries != null)
                              {
                                outer:for(String key : groupEntries)
                                {
                                logger.info("key 2:" + key);
                                try
                                {
                                  //String[] usedEntities = (String[])pageCacheExtraInstance.getFromCache(key + "_entities");
                                    byte[] usedEntitiesByteArray = (byte[])pageCacheExtraInstance.getFromCache(key + "_entitiesAsByte");
                                    String usedEntitiesString = compressionHelper.decompress(usedEntitiesByteArray);
                                    //t.printElapsedTime("Decompress to " + usedEntitiesString.length() + " took");
                                    String[] usedEntities = StringUtils.split(usedEntitiesString, ",");
                                    //t.printElapsedTime("Split to usedEntities " + usedEntities.length + " took");
                                 
                                    ContentVersionVO newestContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(entityId));
                                    String newComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(newestContentVersionVO, "ComponentStructure", false);
   
                                    for(String usedEntity : usedEntities)
                                    {
                                      //System.out.println("usedEntity:" + usedEntity);
                                      if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure("))
                                      {
                                        //System.out.println("Match - now lets parse: " + usedEntity);
                                        String arguments = usedEntity.substring(usedEntity.indexOf("(") + 1, usedEntity.indexOf(")"));
                                        Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.indexOf("=") + 1));
                                        String[] args = arguments.split(",");
                                        Integer componentId = new Integer(args[0]);
                                        String propertyName = args[1];
                                        Integer siteNodeId = new Integer(args[2]);
                                        Integer languageId = new Integer(args[3]);
                                        //System.out.println("componentId:" + componentId);
                                        //System.out.println("propertyName:" + propertyName);
                                        //System.out.println("siteNodeId:" + siteNodeId);
                                        //System.out.println("languageId:" + languageId);
                                     
                                        int newComponentPropertyHash = getPropertyAsStringHashCode(newComponentStructure, componentId, propertyName, siteNodeId, languageId);
                                        //System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
                                        //System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
                                        if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
                                        {
                                          //System.out.println("Yes - clearing - must have changed something important:" + usedEntity);
                                          //cacheInstance.flushGroup(usedEntity);
                                          cacheInstance.flushGroup(getPooledString(usedEntity.hashCode()));
                                          //clearFileCacheForGroup(cacheInstance, usedEntity);
                                        }
                                        else
                                        {
                                          //System.out.println("Flushing content_" + currentPageMetaInfoContentId + "_ComponentStructure just to catch page itself");
                                          //cacheInstance.flushGroup("content_" + currentPageMetaInfoContentId + "_ComponentStructure");
                                          //System.out.println("Flushing content_" + contentId + "_ComponentStructure just to catch page itself");
                                          String componentStructureKey = "content_" + contentId + "_ComponentStructure";
                                          //cacheInstance.flushGroup(componentStructureKey);
                                          cacheInstance.flushGroup(getPooledString(componentStructureKey.hashCode()));
                                          cacheInstance.flushGroup(getPooledString(usedEntity.hashCode()));
                                        }
                                       
                                      }
                                      else if(usedEntity.startsWith("content_" + contentId + "_ComponentStructure:"))
                                      {
                                        //System.out.println("Match - now lets parse component order etc: " + usedEntity);
                                        String xPath = usedEntity.substring(usedEntity.indexOf(":") + 1, usedEntity.lastIndexOf("="));
                                        Integer oldComponentPropertyHash = new Integer(usedEntity.substring(usedEntity.lastIndexOf("=") + 1));
                                        //System.out.println("xPath:" + xPath);
                                       
                                        int newComponentPropertyHash = getComponentsAsStringHashCode(newComponentStructure, xPath);
                                        //System.out.println("oldComponentPropertyHash:" + oldComponentPropertyHash);
                                        //System.out.println("newComponentPropertyHash:" + newComponentPropertyHash);
                                        if(oldComponentPropertyHash.intValue() != newComponentPropertyHash)
                                        {
                                          //System.out.println("Yes - clearing - must have changed order or added/subtracted components:" + usedEntity);
                                          cacheInstance.flushGroup(getPooledString(usedEntity.hashCode()));
                                          //cacheInstance.flushGroup(usedEntity);
                                        }
                                      }
   
                                    }
                                }
                                catch(Exception ex)
                                {
                                  //logger.error("Got error trying to update cache:" + ex.getMessage());
                                    logger.warn("Got error trying to update cache:" + ex.getMessage(), ex);
                                   
                                    try
                                    {
                                      String attributeKey = "content_" + contentId + "_" + changedAttributeName;
                                      //cacheInstance.flushGroup(attributeKey);
                                      cacheInstance.flushGroup(getPooledString(attributeKey.hashCode()));
                                      logger.warn("Cleared pageCache for " + getPooledString(attributeKey.hashCode()));
                                    }
                                  catch(Exception ex2)
                                  {
                                    logger.error("Got error trying to flushGroup 2:" + ex2.getMessage());
                                    cacheInstance.flushAll();
                                  }
                                    break outer;
                                }
                                t.printElapsedTime("Handled group entries");
                                //RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Handled group entries", t.getElapsedTime());
                                }
                              }
                            }
                            else
                            {
                              String attributeKey = "content_" + contentId + "_" + changedAttributeName;
                              //cacheInstance.flushGroup("content_" + contentId + "_" + changedAttributeName);
                              cacheInstance.flushGroup(getPooledString(attributeKey.hashCode()));
                              logger.info("Cleared pageCache for " + "content_" + contentId + "_" + changedAttributeName);
                            }
                          } 
                          //cacheInstance.flushGroup("content_" + contentId);
                        }
                        else
                        {
                          String contentTypeDefKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId;
                          //cacheInstance.flushGroup(contentTypeDefKey);
                          cacheInstance.flushGroup(contentTypeDefKey);
                          //System.out.println("Cleared for " + "content_" + contentId + " on cache " + cacheName);
                          String contentKey = "content_" + contentId;
                          cacheInstance.flushGroup(contentKey);
                          //cacheInstance.flushGroup(contentKey);
                        }

                        //t.printElapsedTime("Handled page cache");
                      //RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Handled page cache", t.getElapsedTime()); 
                        logger.info("After flushGroup2...");
                      }
                      //}

                    if (cacheName.equals("contentVersionCache"))
                    {
                      new AssetUpdatingThread(entityId).start();
                    }
                    }
                    catch(SystemException se)
                    {
                      se.printStackTrace();
                      logger.info("Missing content version: " + se.getMessage());
                    }
                    catch(Exception ex)
                    {
                      ex.printStackTrace();
                    }
                  }
                  else if(selectiveCacheUpdate && (entity.indexOf("Content") > 0 && entity.indexOf("ContentTypeDefinition") == -1 && entity.indexOf("ContentCategory") == -1) && useSelectivePageCacheUpdate)
                  {
                    logger.info("Content entity was sent: " + entity + ":" + entityId);
                    //System.out.println("Content entity was called and needs to be fixed:" + entity);
                   
                    //String[] changedAttributes = new String[]{"Title","NavigationTitle"};
                    /*
                    ContentVO contentVO = null;
                    if(isObjectCachedInCastor(SmallContentImpl.class, new Integer(entityId)))
                      contentVO = ContentController.getContentController().getContentVOWithId(new Integer(entityId));
                    */
                   
                    String repositoryId = sentRepositoryId;
                    String contentTypeDefinitionId = sentContentTypeDefinitionId;
                    String contentIsProtected = sentContentIsProtected;
                    if(repositoryId == null || contentTypeDefinitionId == null || contentIsProtected == null)
                    {
                      //System.out.println("repositoryId:" + repositoryId);
                      //System.out.println("contentTypeDefinitionId:" + contentTypeDefinitionId);
                      //System.out.println("contentIsProtected:" + contentIsProtected);
                      try
                      {
                        ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(entityId));
                        //t.printElapsedTime("clearCaches cv u1 contentVO", 10);
                      repositoryId = ""+contentVO.getRepositoryId();
                      contentTypeDefinitionId = ""+contentVO.getContentTypeDefinitionId();
                      contentIsProtected = ""+contentVO.getIsProtected();
                      }
                      catch (Exception e2)
                      {
                        logger.info("Error loading content with id " + entityId + ":" + e2.getMessage());
                    }
                    }
                   
                    if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
                    {
                      cacheInstance.flushGroup("" + repositoryId);
                      logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + repositoryId);
                    }

                    if(cacheName.equals("pageCacheExtra"))
                    {
                      //clearFileCacheForGroup(cacheInstance, "content_" + entityId);
                      PageCacheHelper.getInstance().notify("content_" + entityId);

                      try
                      {
                        //cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                        if(contentTypeDefinitionId != null)
                        {
                          //clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                          PageCacheHelper.getInstance().notify("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId);
                        }
                      }
                      catch (Exception e2)
                      {
                        logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
                    }
                    }
                    else if(cacheName.equals("pageCache"))
                    {
                      logger.info("Flushing page cache for {" + entityId + "} and {content_" + entityId + "}");
                     
                      String entityKey = "" + entityId;
                      String contentEntityKey = "content_" + entityId;
                      //cacheInstance.flushGroup("" + entityId);
                      //cacheInstance.flushGroup(contentEntityKey);
                      cacheInstance.flushGroup(entityKey);
                      cacheInstance.flushGroup(contentEntityKey);
                      try
                      {
                        if(contentTypeDefinitionId != null)
                        {
                          String contentTypeCacheKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId;
                          //cacheInstance.flushGroup(contentTypeCacheKey);
                          cacheInstance.flushGroup(contentTypeCacheKey);
                        }
                      }
                      catch (Exception e2)
                      {
                        logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
                    }
                    }
                    else
                    {
                      cacheInstance.flushGroup("" + entityId);
                      cacheInstance.flushGroup("content_" + entityId);
                      logger.info("clearing " + e.getKey() + " with selectiveCacheUpdateNonApplicable");
                      cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
                      if(contentTypeDefinitionId != null)
                      {
                        cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId);
                      }
                    }
                   
                    if(contentTypeDefinitionId != null)
                    {
                      //System.out.println("****************************************************************");
                      if(contentIsProtected.equals(""+ContentVO.YES.intValue()))
                      {
                        List<InterceptionPointVO> interceptionPointVOList = InterceptionPointController.getController().getInterceptionPointVOList("Content");
                        for(InterceptionPointVO interceptionPointVO : interceptionPointVOList)
                        {
                          if(interceptionPointVO.getName().endsWith(".Read"))
                          {
                            String acKey = "" + interceptionPointVO.getId() + "_" + entityId;
                            //System.out.println("Clearing access rights for:" + acKey);
                            CacheController.clearUserAccessCache(acKey);                     
                          }
                        }
                      }
                    }
                    //System.out.println("************************END************************************");

                    logger.info("clearing " + e.getKey() + " with group " + "content_" + entityId);
                }
                  else if(selectiveCacheUpdate && entity.indexOf("DigitalAsset") > -1)
                  {
                    logger.info("Asset entity was sent: " + entity + ":" + entityId);
                    Integer contentId = assetContentIdMapping.get(new Integer(entityId));
                    if(contentId == null)
                    {
                      logger.info("Checking fot cv for asset:" + entityId);
                      List<SmallestContentVersionVO> contentVersions = DigitalAssetController.getContentVersionVOListConnectedToAssetWithId(new Integer(entityId));
                      if(contentVersions != null)
                      {
                        for(SmallestContentVersionVO contentVersionVO : contentVersions)
                        {
                          contentId = contentVersionVO.getContentId();
                          assetContentIdMapping.put(new Integer(entityId), contentId);
                          break;
                        }
                      }
                    }
                    else
                      logger.info("Using read asset");
                   
                    //Integer contentId = null;
                   
                    ContentVO contentVO = null;
                    try
                    {
                      contentVO = ContentController.getContentController().getContentVOWithId(contentId);
                   
                      if(cacheName.equals("componentPropertyCacheRepoGroups") || cacheName.equals("componentPropertyVersionIdCacheRepoGroups"))
                      {
                        cacheInstance.flushGroup("" + contentVO.getRepositoryId());
                        logger.info("Clearing componentPropertyCacheRepoGroups for repo:" + contentVO.getRepositoryId());
                      }
                    }
                    catch (Exception e2)
                    {
                      logger.info("Error loading content with id " + contentId + ":" + e2.getMessage());
                  }
                    //ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(entityId));
                   
                    if(cacheName.equals("pageCacheExtra"))
                    {
                      //clearFileCacheForGroup(cacheInstance, "content_" + entityId);
                      PageCacheHelper.getInstance().notify("content_" + contentId);

                      try
                      {
                        //cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                        if(contentVO != null)
                        {
                          //clearFileCacheForGroup(cacheInstance, "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                          PageCacheHelper.getInstance().notify("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId());
                        }
                      }
                      catch (Exception e2)
                      {
                        logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
                    }
                    }
                    else if(cacheName.equals("pageCache"))
                    {
                      logger.info("Flushing page cache for {" + contentId + "} and {content_" + contentId + "}");
                     
                      String entityKey = "" + contentId;
                      String contentEntityKey = "content_" + contentId;
                      //cacheInstance.flushGroup("" + entityId);
                      //cacheInstance.flushGroup(contentEntityKey);
                      cacheInstance.flushGroup(entityKey);
                      cacheInstance.flushGroup(contentEntityKey);
                      try
                      {
                        if(contentVO != null)
                        {
                          String contentTypeCacheKey = "selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentVO.getContentTypeDefinitionId();
                          //cacheInstance.flushGroup(contentTypeCacheKey);
                          cacheInstance.flushGroup(contentTypeCacheKey);
                        }
                      }
                      catch (Exception e2)
                      {
                        logger.warn("Could not find content type to clear pages based on: " + e2.getMessage(), e2);
                    }
                    }
                    else
                    {
                      cacheInstance.flushGroup("" + contentId);
                      cacheInstance.flushGroup("content_" + contentId);
                      logger.info("clearing " + e.getKey() + " with selectiveCacheUpdateNonApplicable");
                      cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
                    }

                    logger.info("clearing " + e.getKey() + " with group " + "content_" + entityId);
                }
                  else if(selectiveCacheUpdate && entity.indexOf("Publication") > 0 && useSelectivePageCacheUpdate && (operatingMode != null && operatingMode.equalsIgnoreCase("3")) && CmsPropertyHandler.getLivePublicationThreadClass().equalsIgnoreCase("org.infoglue.deliver.util.SelectiveLivePublicationThread"))
                  {
                    logger.info("Now we will ease out the publication...");
                  /*
                    List publicationDetailVOList = PublicationController.getController().getPublicationDetailVOList(new Integer(entityId));
                  Iterator publicationDetailVOListIterator = publicationDetailVOList.iterator();
                  while(publicationDetailVOListIterator.hasNext())
                  {
                    PublicationDetailVO publicationDetailVO = (PublicationDetailVO)publicationDetailVOListIterator.next();
                    logger.info("publicationDetailVO.getEntityClass():" + publicationDetailVO.getEntityClass());
                    logger.info("publicationDetailVO.getEntityId():" + publicationDetailVO.getEntityId());
                    if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(ContentVersion.class.getName()))
                    {
                      logger.error("We clear all caches having references to contentVersion: " + publicationDetailVO.getEntityId());
                      Integer contentId = ContentVersionController.getContentVersionController().getContentIdForContentVersion(publicationDetailVO.getEntityId());

                        cacheInstance.flushGroup("content_" + contentId);
                        cacheInstance.flushGroup(CacheController.getPooledString(2, publicationDetailVO.getEntityId().toString()));
                        cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable");
                        logger.info("clearing " + e.getKey() + " with group " + "content_" + contentId);
                        logger.info("clearing " + e.getKey() + " with group " + "content_" + contentId);
                    }
                    else if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(SiteNodeVersion.class.getName()))
                    {
                      Integer siteNodeId = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(publicationDetailVO.getEntityId()).getSiteNodeId();
                        CacheController.clearCaches(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), null);
                    }
                   
                  }
                  */
                }
                  else if(entity.equals("org.infoglue.cms.entities.management.impl.simple.AccessRightImpl"))
                  {
                    //System.out.println("This was an access right update - do we handle it:" + cacheName);
                    if(!CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("3"))
                    {
                      try
                      {
                        AccessRightVO acVO = AccessRightController.getController().getAccessRightVOWithId(new Integer(entityId));
                        InterceptionPointVO icpVO = InterceptionPointController.getController().getInterceptionPointVOWithId(acVO.getInterceptionPointId());
                        //System.out.println("icpVO:" + icpVO.getName());
                        if(icpVO.getName().indexOf("Content.") > -1)
                        {
                          //System.out.println("Was a content access... let's clear caches for that content.");
                          String idAsString = acVO.getParameters();
                          if(idAsString != null && !idAsString.equals(""))
                            clearCaches("org.infoglue.cms.entities.content.impl.simple.ContentImpl", idAsString, null, cachesToSkip, forceClear);
                        }
                        else if(icpVO.getName().indexOf("ContentVersion.") > -1)
                        {
                          //System.out.println("Was a contentversion access... let's clear caches for that content.");
                          String idAsString = acVO.getParameters();
                          if(idAsString != null && !idAsString.equals(""))
                            clearCaches("org.infoglue.cms.entities.content.impl.simple.ContentVersionImpl", idAsString, null, cachesToSkip, forceClear);                       
                        }
                        else if(icpVO.getName().indexOf("SiteNode.") > -1)
                        {
                          //System.out.println("Was a sitenode access... let's clear caches for that content.");
                          String idAsString = acVO.getParameters();
                          if(idAsString != null && !idAsString.equals(""))
                            clearCaches("org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl", idAsString, null, cachesToSkip, forceClear);                                               
                        }
                      else if(icpVO.getName().indexOf("SiteNodeVersion.") > -1)
                      {
                        //System.out.println("Was a sitenode version access... let's clear caches for that content.");
                          String idAsString = acVO.getParameters();
                          if(idAsString != null && !idAsString.equals(""))
                            clearCaches("org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl", idAsString, null, cachesToSkip, forceClear);                                               
                      }
                      else
                      {
                        //System.out.println("****************************");
                        //System.out.println("* WHAT TO DO WITH IN CACHECONTROLLER: " + icpVO.getName() + " *");
                        //System.out.println("****************************");
                      }
                      }
                      catch(Exception e2)
                      {
                        logger.error("Error handling access right update: " + e2.getMessage(), e2);
                      }
                    }
                    else
                      logger.info("Skipping it as this is live mode..");
                  }
                  else if(selectiveCacheUpdate && (entity.indexOf("ServiceBinding") > 0 || entity.indexOf("Qualifyer") > 0))
                  {
                    logger.info("Ignoring this kind of notification... never used anymore:" + cacheName);
                  }
                  else if(entity.indexOf("AccessRightImpl") > -1)
                  {
                    logger.info("Ignoring handling of entity:" + entity);
                  }
                  else if(cacheName.equalsIgnoreCase("matchingContentsCache") && entity.indexOf("MediumContentCategoryImpl") > 0)
                  {
                    try
                    {
                      String contentId = sentContentId;
                      //if(contentId == null || contentId.equals(""))
                       
                      ContentCategoryVO contentCategoryVO = ContentCategoryController.getController().findById(new Integer(entityId));
                      ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(contentCategoryVO.getContentVersionId());
                      ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersionVO.getContentId());
                      String contentTypeDefinitionId = "" + contentVO.getContentTypeDefinitionId();
                      cacheInstance.flushGroup("selectiveCacheUpdateNonApplicable_contentTypeDefinitionId_" + contentTypeDefinitionId);
                      cacheInstance.putInCache("recacheMark_" + contentTypeDefinitionId, "" + System.currentTimeMillis());
                      cacheInstance.putInCache("recacheMark", "" + System.currentTimeMillis());
                    }
View Full Code Here

    return super.doEndTag();
  }

  private ContentVersionVO getContentVersion() throws JspTagException
  {
    ContentVersionVO contentVersion;
    try
    {
      contentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, languageId);
    }
    catch(Exception e)
View Full Code Here

        DeliveryContext deliveryContext = DeliveryContext.getDeliveryContext();
          ContentVO contentVO = ndc.getBoundContent(db, principal, siteNodeId, currentLanguage.getId(), false, BasicTemplateController.META_INFO_BINDING_NAME, deliveryContext);   
        if(contentVO != null)
        {
            ContentVersionVO contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(db, siteNodeId, contentVO.getId(), currentLanguage.getId(), false, deliveryContext, principal);
            if(contentVersionVO != null)
            {
            language = currentLanguage;
            logger.info("Language now: " + language.getName());
            }
View Full Code Here

    testContent.setPublishDateTime(changeDate(Calendar.YEAR, -1));
    testContent.setExpireDateTime(changeDate(Calendar.YEAR, 1));
    testContent = contentStore.create(null, null, REPO, testContent);
    allContent.add(testContent);

    testContentVersion = new ContentVersionVO();
    testContentVersion.setVersionModifier("frank");
    testContentVersion.setVersionValue(getName());
    testContentVersion = contentVersionStore.create(testContent.getId(), LANGUAGE, testContentVersion, null);

    // This is done here because of the static initializer tried to load properties
View Full Code Here

    testCategory = createContentCategory(testContentVersion.getId(), ATTRIBUTE);

    List found = testController.findContentVersionVOsForCategory(testDatabase, testCategory.getId(), ATTRIBUTE, ANON, SITENODE, LANGUAGE, true, DeliveryContext.getDeliveryContext());
    assertEquals("Wrong number of Content Versions found", 1, found.size());

    ContentVersionVO foundVersion = (ContentVersionVO)found.get(0);
    assertEquals("Wrong Content Version id", testContentVersion.getId(), foundVersion.getId());
  }
View Full Code Here

  public void testFindMostRecent() throws Exception
  {
    testCategory = createContentCategory(testContentVersion.getId(), ATTRIBUTE);

    ContentVersionVO another = addMoreContent();
    CategoryVO anotherCategory = createContentCategory(another.getId(), getName());

    List found = testController.findContentVersionVOsForCategory(testDatabase, anotherCategory.getId(), getName(), ANON, SITENODE, LANGUAGE, true, DeliveryContext.getDeliveryContext());
    assertEquals("Wrong number of Content Versions found", 1, found.size());
    assertEquals("Wrong Content Versions found", another.getId(), ((ContentVersionVO)found.get(0)).getId());
  }
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.content.ContentVersionVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.