Examples of CacheEvictionBean


Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

          }
       
        Iterator i = localNotifications.iterator();
      while(i.hasNext())
      {
          CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)i.next();
          String className = cacheEvictionBean.getClassName();
         
        logger.info("className:" + className);
        logger.info("pt:" + pt);
        //RequestAnalyser.getRequestAnalyser().addPublication("" + formatter.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss") + " - " + cacheEvictionBean.getClassName() + " - " + cacheEvictionBean.getObjectId());
       
View Full Code Here

Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

        List<String> accessRightsToClear = new ArrayList<String>();

        Iterator i = cacheEvictionBeans.iterator();
        while(i.hasNext())
        {
            CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)i.next();
           
            RequestAnalyser.getRequestAnalyser().addOngoingPublications(cacheEvictionBean);

            String className = cacheEvictionBean.getClassName();
            String objectId = cacheEvictionBean.getObjectId();
            String objectName = cacheEvictionBean.getObjectName();
          String typeId = cacheEvictionBean.getTypeId();
          Map<String,String> extraInformation = cacheEvictionBean.getExtraInformation();
          String changedAttributeNames = extraInformation.get("changedAttributeNames");
            logger.info("className:" + className);
          logger.info("objectId:" + objectId);
          logger.info("objectName:" + objectName);
          logger.info("typeId:" + typeId);
          logger.info("changedAttributeNames:" + changedAttributeNames);

            boolean skipOriginalEntity = false;

          List<Map<String,String>> allIGCacheCalls = new ArrayList<Map<String,String>>();

          logger.info("className:" + className + " objectId:" + objectId + " objectName: " + objectName + " typeId: " + typeId + ":" + extraInformation);
            if(className.indexOf("AccessRight") > -1)
            {
              logger.info("Special handling of access rights..");
              if(!accessRightsFlushed)
              {
                  CacheController.clearCache(AccessRightImpl.class);
                  CacheController.clearCache(AccessRightRoleImpl.class);
                  CacheController.clearCache(AccessRightGroupImpl.class);
                  CacheController.clearCache(AccessRightUserImpl.class);
                 
                CacheController.clearCache("personalAuthorizationCache");
                CacheController.clearCache("userAccessCache");
                accessRightsFlushed = true;
              }
             
              skipOriginalEntity = true;
             
              try
              {
                AccessRightVO acVO = AccessRightController.getController().getAccessRightVOWithId(new Integer(objectId));
                InterceptionPointVO icpVO = InterceptionPointController.getController().getInterceptionPointVOWithId(acVO.getInterceptionPointId());
                if(!processedEntities.contains("" + icpVO.getCategory() + "_" + acVO.getParameters()))
                {
                  String acKey = "" + icpVO.getId() + "_" + acVO.getParameters();
                accessRightsToClear.add(acKey);

                  //logger.info("icpVO:" + icpVO.getName());
                  if(icpVO.getName().indexOf("Content.") > -1)
                  {
                    //logger.info("Was a content access... let's clear caches for that content.");
                    String idAsString = acVO.getParameters();
                    if(idAsString != null && !idAsString.equals(""))
                      addCacheUpdateDirective("org.infoglue.cms.entities.content.impl.simple.ContentImpl", idAsString, allIGCacheCalls);
                  }
                  else if(icpVO.getName().indexOf("ContentVersion.") > -1)
                  {
                    //logger.info("Was a contentversion access... let's clear caches for that content.");
                    String idAsString = acVO.getParameters();
                    if(idAsString != null && !idAsString.equals(""))
                      addCacheUpdateDirective("org.infoglue.cms.entities.content.impl.simple.ContentVersionImpl", idAsString, allIGCacheCalls);
                  }
                  else if(icpVO.getName().indexOf("SiteNode.") > -1)
                  {
                    //logger.info("Was a sitenode access... let's clear caches for that content.");
                    String idAsString = acVO.getParameters();
                    if(idAsString != null && !idAsString.equals(""))
                      addCacheUpdateDirective("org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl", idAsString, allIGCacheCalls);
                  }
                else if(icpVO.getName().indexOf("SiteNodeVersion.") > -1)
                {
                  //logger.info("Was a sitenode version access... let's clear caches for that content.");
                    String idAsString = acVO.getParameters();
                    if(idAsString != null && !idAsString.equals(""))
                      addCacheUpdateDirective("org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl", idAsString, allIGCacheCalls);
                }
                else
                {
                  logger.info("****************************");
                  logger.info("* WHAT TO DO WITH: " + icpVO.getName() + " *");
                  logger.info("****************************");
                }
                  logger.info("Feeling done with " + "" + icpVO.getName() + "_" + acVO.getParameters());
                  processedEntities.add("" + icpVO.getName() + "_" + acVO.getParameters());
                }
                else
                  logger.info("Allready processed " + icpVO.getCategory() + "_" + acVO.getParameters());
              }
              catch(Exception e2)
              {
                logger.warn("Error handling access right update: " + e2.getMessage());
              }
             
              if(!accessRightsFlushed)
              {
                 CacheController.clearCache("personalAuthorizationCache");
                accessRightsFlushed = true;
              }
              //t.printElapsedTime("Access rights");
              //continue;
            }
            //t.printElapsedTime("First part in working thread done...");
          //logger.info("changedAttributeNames in working thread:" + changedAttributeNames);
         
          //logger.info("className:" + className);
          //logger.info("objectId:" + objectId);
          //logger.info("objectName:" + objectName);
          //logger.info("typeId:" + typeId);

          try
          {
                boolean isDependsClass = false;
              if(className != null && className.equalsIgnoreCase(PublicationDetailImpl.class.getName()))
                  isDependsClass = true;
       
              if(!skipOriginalEntity)
                addCacheUpdateDirective(className, objectId, allIGCacheCalls);
             
              //t.printElapsedTime("1.1");

              logger.info("Updating className with id:" + className + ":" + objectId);
              if(className != null && !typeId.equalsIgnoreCase("" + NotificationMessage.SYSTEM) && !skipOriginalEntity)
            {
                Class type = Class.forName(className);
     
                if(!isDependsClass &&
                    className.equalsIgnoreCase(SystemUserImpl.class.getName()) ||
                    className.equalsIgnoreCase(RoleImpl.class.getName()) ||
                    className.equalsIgnoreCase(GroupImpl.class.getName()) ||
                    className.equalsIgnoreCase(SmallSystemUserImpl.class.getName()) ||
                    className.equalsIgnoreCase(SmallRoleImpl.class.getName()) ||
                    className.equalsIgnoreCase(SmallGroupImpl.class.getName()) ||
                    className.equalsIgnoreCase(SystemUserRoleImpl.class.getName()) ||
                    className.equalsIgnoreCase(SystemUserGroupImpl.class.getName()))
                {
                    Object[] ids = {objectId};
                    CacheController.clearCache(type, ids);
                    //t.printElapsedTime("1.2");
              }
                else if(!isDependsClass)
                {
                  try
                  {
                      Object[] ids = {new Integer(objectId)};
                    CacheController.clearCache(type, ids);
                    //t.printElapsedTime("1.3");
                  }
                  catch (Exception e)
                  {
                    logger.warn("Problem clearing cache for type:" + type + " AND ID:" + objectId);
                }
                }
     
                //t.printElapsedTime("2");

              //If it's an contentVersion we should delete all images it might have generated from attributes.
              if(Class.forName(className).getName().equals(ContentImpl.class.getName()))
              {
                  logger.info("We clear all small contents as well " + objectId);
                Class typesExtra = SmallContentImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
 
                  logger.info("We clear all smallish contents as well " + objectId);
                Class typesExtraSmallish = SmallishContentImpl.class;
                Object[] idsExtraSmallish = {new Integer(objectId)};
                CacheController.clearCache(typesExtraSmallish, idsExtraSmallish);
 
                logger.info("We clear all medium contents as well " + objectId);
                Class typesExtraMedium = MediumContentImpl.class;
                Object[] idsExtraMedium = {new Integer(objectId)};
                CacheController.clearCache(typesExtraMedium, idsExtraMedium);
              }
              if(Class.forName(className).getName().equals(ContentVersionImpl.class.getName()))
              {
                  logger.info("We clear all small contents as well " + objectId);
                Class typesExtra = SmallContentVersionImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
 
                logger.info("We clear all small contents as well " + objectId);
                Class typesExtraSmallest = SmallestContentVersionImpl.class;
                Object[] idsExtraSmallest = {new Integer(objectId)};
                CacheController.clearCache(typesExtraSmallest, idsExtraSmallest);
                //t.printElapsedTime("ContentVersionImpl...");
              }
              else if(Class.forName(className).getName().equals(AvailableServiceBindingImpl.class.getName()))
              {
                  Class typesExtra = SmallAvailableServiceBindingImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(SiteNodeImpl.class.getName()))
              {
                  Class typesExtra = SmallSiteNodeImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(SiteNodeVersionImpl.class.getName()))
              {
                  Class typesExtra = SmallSiteNodeVersionImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(RepositoryImpl.class.getName()))
              {
                CacheController.clearServerNodeProperty(true);

                Class repoClass = RepositoryImpl.class;
                CacheController.clearCache(repoClass);
                CacheController.clearCaches(repoClass.getName(), null, null);

                CacheController.clearCache("repositoryCache");
                CacheController.clearCache("masterRepository");
                CacheController.clearCache("parentRepository");
                CacheController.clearCache("componentPropertyCache");
                    //CacheController.clearFileCaches("pageCache");
                PageCacheHelper.getInstance().clearPageCache();

                    CacheController.clearCache("pageCache");
                CacheController.clearCache("pageCacheExtra");
                CacheController.clearCache("componentCache");
                CacheController.clearCache("NavigationCache");
                CacheController.clearCache("pagePathCache");
                  URIMapperCache.getInstance().clear();
              }
              else if(Class.forName(className).getName().equals(DigitalAssetImpl.class.getName()))
              {
                CacheController.clearCache("digitalAssetCache");
                Class typesExtra = SmallDigitalAssetImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
 
                Class typesExtraMedium = MediumDigitalAssetImpl.class;
                Object[] idsExtraMedium = {new Integer(objectId)};
                CacheController.clearCache(typesExtraMedium, idsExtraMedium);
 
                String disableAssetDeletionInWorkThread = CmsPropertyHandler.getDisableAssetDeletionInWorkThread();
                if(disableAssetDeletionInWorkThread != null && !disableAssetDeletionInWorkThread.equals("true"))
                {
                  logger.info("We should delete all images with digitalAssetId " + objectId);
                  DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer(objectId));
                }
               
                Set<String> handledVersions = new HashSet<String>();
                List<SmallestContentVersionVO> contentVersionVOList = DigitalAssetController.getContentVersionVOListConnectedToAssetWithId(new Integer(objectId))
                  Iterator<SmallestContentVersionVO> contentVersionVOListIterator = contentVersionVOList.iterator();
                  while(contentVersionVOListIterator.hasNext())
                  {
                    SmallestContentVersionVO contentVersionVO = contentVersionVOListIterator.next();
                    logger.info("Invoking clearCaches for ContentVersionImpl with id:" + contentVersionVO.getId());
                    String key = contentVersionVO.getContentId() + "_" + contentVersionVO.getLanguageId();
                    //System.out.println("Invoking clearCaches for ContentVersionImpl with id:" + key + " " + contentVersionVO.getId());
                    if(!handledVersions.contains(key))
                    {
                      CacheController.clearCaches(ContentVersionImpl.class.getName(), contentVersionVO.getId().toString(), null);             
                      CacheController.clearCaches(SmallContentVersionImpl.class.getName(), contentVersionVO.getId().toString(), null);                   
                      CacheController.clearCaches(SmallestContentVersionImpl.class.getName(), contentVersionVO.getId().toString(), null);
                      handledVersions.add(key);
                    }
                  }
              }
              else if(Class.forName(className).getName().equals(MediumDigitalAssetImpl.class.getName()))
              {
                CacheController.clearCache("digitalAssetCache");
                Class typesExtra = SmallDigitalAssetImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
 
                Class typesExtraMedium = DigitalAssetImpl.class;
                Object[] idsExtraMedium = {new Integer(objectId)};
                CacheController.clearCache(typesExtraMedium, idsExtraMedium);
 
                String disableAssetDeletionInWorkThread = CmsPropertyHandler.getDisableAssetDeletionInWorkThread();
                if(disableAssetDeletionInWorkThread != null && !disableAssetDeletionInWorkThread.equals("true"))
                {
                  logger.info("We should delete all images with digitalAssetId " + objectId);
                  DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer(objectId));
                }
               
                Set<String> handledVersions = new HashSet<String>();
                List<SmallestContentVersionVO> contentVersionVOList = DigitalAssetController.getContentVersionVOListConnectedToAssetWithId(new Integer(objectId))
                  Iterator<SmallestContentVersionVO> contentVersionVOListIterator = contentVersionVOList.iterator();
                  while(contentVersionVOListIterator.hasNext())
                  {
                    SmallestContentVersionVO contentVersionVO = contentVersionVOListIterator.next();
                    String key = contentVersionVO.getContentId() + "_" + contentVersionVO.getLanguageId();
                    //System.out.println("Invoking clearCaches for ContentVersionImpl with id:" + key + " " + contentVersionVO.getId());
                    if(!handledVersions.contains(key))
                    {
                      CacheController.clearCaches(ContentVersionImpl.class.getName(), contentVersionVO.getId().toString(), null);             
                      CacheController.clearCaches(SmallContentVersionImpl.class.getName(), contentVersionVO.getId().toString(), null);                   
                      CacheController.clearCaches(SmallestContentVersionImpl.class.getName(), contentVersionVO.getId().toString(), null)
                      handledVersions.add(key);
                    }
                  }
              }
              else if(Class.forName(className).getName().equals(SystemUserImpl.class.getName()))
              {
                  Class typesExtra = SmallSystemUserImpl.class;
                Object[] idsExtra = {objectId};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(RoleImpl.class.getName()))
              {
                  Class typesExtra = SmallRoleImpl.class;
                Object[] idsExtra = {objectId};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(GroupImpl.class.getName()))
              {
                  Class typesExtra = SmallGroupImpl.class;
                Object[] idsExtra = {objectId};
                CacheController.clearCache(typesExtra, idsExtra);
              }
            } 
             
              // t.printElapsedTime("3");
              long elapsedTime = t.getElapsedTime();
              if(elapsedTime > 50)
                RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Clearing all castor caches in working publication thread took", elapsedTime);
           
             
              for(Map<String,String> igCacheCall : allIGCacheCalls)
            {
              logger.info("Calling clear caches with:" + igCacheCall.get("className") + ":" + igCacheCall.get("objectId") + ":" + extraInformation);
              CacheController.clearCaches(igCacheCall.get("className"), igCacheCall.get("objectId"), extraInformation, null);
              handledCacheCalls.put("" + igCacheCall.get("className") + "_" + igCacheCall.get("objectId") + "_" + extraInformation, new Boolean(true));
             
                elapsedTime = t.getElapsedTime();
                if(elapsedTime > 50)
                  logger.warn("Clearing all caches for " + igCacheCall.get("className") + ":" + igCacheCall.get("objectId"));
            }
             
              String key = "" + className + "_" + objectId + "_" + extraInformation;
              if(!skipOriginalEntity && handledCacheCalls.get(key) == null)
              {
                logger.info("" + className + ":" + objectId + ":" + extraInformation);
                CacheController.clearCaches(className, objectId, extraInformation, null);
              CacheController.setForcedCacheEvictionMode(true);
              
              if(elapsedTime > 100)
                  logger.warn("Clearing all caches for " + className + ":" + objectId + ":" + changedAttributeNames);
              }
              else
                logger.info("Skipping cache clear for the same entity..");
             
              //System.out.println("Adding:" + cacheEvictionBean.getObjectName() + ":" + cacheEvictionBean.getObjectId());
            CacheEvictionBeanListenerService.getService().notifyListeners(cacheEvictionBean);
          }
          catch (Exception e)
          {
            if(e.getMessage().indexOf("was not found") > -1 || (e.getCause() != null && e.getCause().getMessage().indexOf("was not found") > -1))
              logger.warn("A delete operation probably gave us trouble clearing the correct caches");
            else
              logger.warn("Error handling cache update message:" + className + ":" + objectId, e);
          }
         
            RequestAnalyser.getRequestAnalyser().removeOngoingPublications(cacheEvictionBean);
            cacheEvictionBean.setProcessed();
            //if(cacheEvictionBean.getPublicationId() > -1)
              RequestAnalyser.getRequestAnalyser().addPublication(cacheEvictionBean);
        }
       
        //TEST
View Full Code Here

Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

          publicationsToShow = publicationsToShow.subList(0, 20);
       
        Iterator<CacheEvictionBean> publicationsIterator = publicationsToShow.iterator();
        while(publicationsIterator.hasNext())
        {
          CacheEvictionBean publication = publicationsIterator.next();
          states.add(getList("<a href=\"javascript:void(0);\" onclick=\"window.open('" + CmsPropertyHandler.getCmsFullBaseUrl() + "/ViewPublications!showPublicationDetails.action?publicationId=" + publication.getPublicationId() + "', 'Publication details', 'width=900,height=600');\">PublicationId: " + publication.getPublicationId() + ", User: " + publication.getUserName() + ", Finished: " + formatter.formatDate(publication.getProcessedTimestamp(), "yyyy-MM-dd HH:mm:ss") + ", Initiated: " + formatter.formatDate(publication.getTimestamp(), "yyyy-MM-dd HH:mm:ss") + ", Received: " + formatter.formatDate(publication.getReceivedTimestamp(), "yyyy-MM-dd HH:mm:ss") + ", Entity: " + publication.getClassName().replaceAll(".*\\.", "") + "</a>", ""));
        }
           
        states.add(getList("<a href=\"ViewApplicationState!clearPublications.action\">Clear (" + publications.size() + " publications done since last reset)</a>", "&nbsp;"));

      getApplicationAttributes();
View Full Code Here

Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

   
        StringBuffer sb = new StringBuffer();
        List<CacheEvictionBean> latestPublications = RequestAnalyser.getRequestAnalyser().getLatestPublications();
        List<CacheEvictionBean> ongoingPublications = RequestAnalyser.getRequestAnalyser().getOngoingPublications();
       
        CacheEvictionBean foundPublishedBean = null;
        CacheEvictionBean foundOngoingPublicationBean = null;
       
        for(CacheEvictionBean latestPublication : latestPublications)
        {
          if(latestPublication.getPublicationId().equals(this.publicationId))
            foundPublishedBean = latestPublication;
        }

        for(CacheEvictionBean ongoingPublication : ongoingPublications)
        {
          foundOngoingPublicationBean = ongoingPublication;
        }

        if(foundPublishedBean != null)
          sb.append("" + foundPublishedBean.toQueryString());
        else if(foundOngoingPublicationBean != null)
          sb.append("" + foundOngoingPublicationBean.toQueryString());
        else
          sb.append("status=Unknown; serverStartDateTime:" + formatter.formatDate(CmsPropertyHandler.getStartupTime(), "yyyy-MM-dd HH:mm:ss"));
       
        this.getResponse().setContentType("text/plain");
        this.getResponse().getWriter().println("" + sb.toString());
View Full Code Here

Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

              logger.error("Could not read timestamp:" + timestamp);
          }
          }
          if(!skip)
          {
            CacheEvictionBean cacheEvictionBean = new CacheEvictionBean(publicationId, userName, timestamp, className, typeId, objectId, objectName, extraInfo);
            newNotificationList.add(cacheEvictionBean);
            /*
            synchronized(CacheController.notifications)
              {
              CacheController.notifications.add(cacheEvictionBean);
              }
              */
            logger.info("Added a cacheEvictionBean " + cacheEvictionBean.getClassName() + ":" + cacheEvictionBean.getTypeId() + ":" + cacheEvictionBean.getObjectName() + ":" + cacheEvictionBean.getObjectId());
          }
          else
            logger.warn("Skipped a cacheEvictionBean as it's timestamp was earlier than the server start");
           
          i++;
          userName   = this.getRequest().getParameter(i + ".userName");
          timestamp   = this.getRequest().getParameter(i + ".timestamp");
          className   = this.getRequest().getParameter(i + ".className");
          typeId      = this.getRequest().getParameter(i + ".typeId");
          objectId    = this.getRequest().getParameter(i + ".objectId");
          objectName   = this.getRequest().getParameter(i + ".objectName");

          //A very special parameter only used in working environments. Notifies what has changes more precisly
          extraInfo         = new HashMap<String,String>();
          changedAttributeNames   = this.getRequest().getParameter(i + ".changedAttributeNames");
           contentId         = this.getRequest().getParameter(i + ".contentId");
          parentContentId     = this.getRequest().getParameter(i + ".parentContentId");
          contentTypeDefinitionId  = this.getRequest().getParameter(i + ".contentTypeDefinitionId");
          contentIsProtected     = this.getRequest().getParameter(i + ".contentIsProtected");
           siteNodeId         = this.getRequest().getParameter(i + ".siteNodeId");
          parentSiteNodeId    = this.getRequest().getParameter(i + ".parentSiteNodeId");
          repositoryId       = this.getRequest().getParameter(i + ".repositoryId");
//          System.out.println("contentId:" + contentId);
//          System.out.println("parentContentId:" + parentContentId);
//          System.out.println("siteNodeId:" + siteNodeId);
//          System.out.println("parentSiteNodeId:" + parentSiteNodeId);
//          System.out.println("repositoryId:" + repositoryId);
          if(changedAttributeNames != null)
            extraInfo.put("changedAttributeNames", changedAttributeNames);
          if(contentId != null)
            extraInfo.put("contentId", contentId);
          if(parentContentId != null)
            extraInfo.put("parentContentId", parentContentId);
          if(contentTypeDefinitionId != null)
            extraInfo.put("contentTypeDefinitionId", contentTypeDefinitionId);
          if(contentIsProtected != null)
            extraInfo.put("contentIsProtected", contentIsProtected);
          if(siteNodeId != null)
            extraInfo.put("siteNodeId", siteNodeId);
          if(parentSiteNodeId != null)
            extraInfo.put("parentSiteNodeId", parentSiteNodeId);
          if(repositoryId != null)
            extraInfo.put("repositoryId", repositoryId);

        }
       
        if(i == 0)
        {
          userName   = this.getRequest().getParameter("userName");
          timestamp   = this.getRequest().getParameter("timestamp");
          className   = this.getRequest().getParameter("className");
          typeId      = this.getRequest().getParameter("typeId");
          objectId    = this.getRequest().getParameter("objectId");
          objectName   = this.getRequest().getParameter("objectName");
      
          //A very special parameter only used in working environments. Notifies what has changes more precisly
          extraInfo = new HashMap<String,String>();
          changedAttributeNames   = this.getRequest().getParameter("changedAttributeNames");
           contentId         = this.getRequest().getParameter("contentId");
          parentContentId     = this.getRequest().getParameter("parentContentId");
          contentTypeDefinitionId  = this.getRequest().getParameter("contentTypeDefinitionId");
          contentIsProtected     = this.getRequest().getParameter("contentIsProtected");
           siteNodeId         = this.getRequest().getParameter("siteNodeId");
          parentSiteNodeId     = this.getRequest().getParameter("parentSiteNodeId");
          repositoryId       = this.getRequest().getParameter("repositoryId");
//          System.out.println("contentId:" + contentId);
//          System.out.println("parentContentId:" + parentContentId);
//          System.out.println("siteNodeId:" + siteNodeId);
//          System.out.println("parentSiteNodeId:" + parentSiteNodeId);
//          System.out.println("repositoryId:" + repositoryId);
          if(changedAttributeNames != null)
            extraInfo.put("changedAttributeNames", changedAttributeNames);
          if(contentId != null)
            extraInfo.put("contentId", contentId);
          if(parentContentId != null)
            extraInfo.put("parentContentId", parentContentId);
          if(contentTypeDefinitionId != null)
            extraInfo.put("contentTypeDefinitionId", contentTypeDefinitionId);
          if(contentIsProtected != null)
            extraInfo.put("contentIsProtected", contentIsProtected);
          if(siteNodeId != null)
            extraInfo.put("siteNodeId", siteNodeId);
          if(parentSiteNodeId != null)
            extraInfo.put("parentSiteNodeId", parentSiteNodeId);
          if(repositoryId != null)
            extraInfo.put("repositoryId", repositoryId);

          Integer publicationId = -1;
          if(className.indexOf(PublicationImpl.class.getName()) > -1)
            publicationId = Integer.parseInt(objectId);

          boolean skip = false;
          if(timestamp != null && !timestamp.equals(""))
          {
            try
            {
              long ts = Long.parseLong(timestamp);
              if(ts < CmsPropertyHandler.getStartupTime().getTime())
                skip = true;
            }
            catch (Exception e)
            {
              logger.error("Could not read timestamp:" + timestamp);
          }
          }
          if(!skip)
          {
            CacheEvictionBean cacheEvictionBean = new CacheEvictionBean(publicationId, userName, timestamp, className, typeId, objectId, objectName, extraInfo);
            newNotificationList.add(cacheEvictionBean);
            /*
            synchronized(CacheController.notifications)
              {
              CacheController.notifications.add(cacheEvictionBean);
              }
            logger.warn("Added an oldSchool cacheEvictionBean " + cacheEvictionBean.getClassName() + ":" + cacheEvictionBean.getTypeId() + ":" + cacheEvictionBean.getObjectName() + ":" + cacheEvictionBean.getObjectId());
              */
            logger.info("Added a cacheEvictionBean " + cacheEvictionBean.getClassName() + ":" + cacheEvictionBean.getTypeId() + ":" + cacheEvictionBean.getObjectName() + ":" + cacheEvictionBean.getObjectId());
          }
          else
            logger.warn("Skipped a cacheEvictionBean as it's timestamp was earlier than the server start");
  
        }
View Full Code Here

Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

      try
      {
        Iterator cacheEvictionBeansIterator = cacheEvictionBeans.iterator();
        while(cacheEvictionBeansIterator.hasNext())
        {
          CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)cacheEvictionBeansIterator.next();
          String className = cacheEvictionBean.getClassName();
          if(className == null)
            logger.error("No className in CacheEvictionBean");
          if(cacheEvictionBean.getObjectName() == null)
            logger.error("No objectName in CacheEvictionBean");
           
          if(className.equalsIgnoreCase("ServerNodeProperties"))
          {
            if(processedServerNodeProperties || cacheEvictionBean.getObjectName().equals("MySettings"))
            {
              cacheEvictionBeansIterator.remove();
              //logger.info("Removed one ServerNodeProperties update as it will be processed anyway in this eviction cycle");
            }
            else
            {
              processedServerNodeProperties = true;
            }
          }
        }
      }
      catch (Exception e)
      {
        logger.error("Error in selective live publication thread. Could not process eviction beans part 1: " + e.getMessage(), e);
    }
       
    logger.info("cacheEvictionBeans.size:" + cacheEvictionBeans.size() + ":" + RequestAnalyser.getRequestAnalyser().getBlockRequests());
    if(cacheEvictionBeans.size() > 0)
    {
      try
      {   
        Timer t = new Timer();

        logger.info("setting block");
            RequestAnalyser.getRequestAnalyser().setBlockRequests(true);
           
            //logger.info("cacheEvictionBeans:" + cacheEvictionBeans.size());
            boolean accessRightsFlushed = false;
            List<String> processedEntities = new ArrayList<String>();
        Iterator i = cacheEvictionBeans.iterator();
        while(i.hasNext())
        {
            CacheEvictionBean cacheEvictionBean = (CacheEvictionBean)i.next();
           
            boolean processedInterupted = false;
            boolean skipOriginalEntity = false;
            try
            {
              RequestAnalyser.getRequestAnalyser().addOngoingPublications(cacheEvictionBean);
             
              String className = cacheEvictionBean.getClassName();
              String objectId = cacheEvictionBean.getObjectId();
              String objectName = cacheEvictionBean.getObjectName();
            String typeId = cacheEvictionBean.getTypeId();
           
              List<Map<String,String>> allIGCacheCalls = new ArrayList<Map<String,String>>();

            logger.info("className:" + className + " objectId:" + objectId + " objectName: " + objectName + " typeId: " + typeId);
              if(className.indexOf("AccessRight") > -1)
              {
                logger.info("Special handling of access rights..");
                if(!accessRightsFlushed)
                {
                    CacheController.clearCache(AccessRightImpl.class);
                    CacheController.clearCache(AccessRightRoleImpl.class);
                    CacheController.clearCache(AccessRightGroupImpl.class);
                    CacheController.clearCache(AccessRightUserImpl.class);

                  CacheController.clearCache("personalAuthorizationCache");
                  accessRightsFlushed = true;
                }
               
                skipOriginalEntity = true;
               
                try
                {
                  AccessRightVO acVO = AccessRightController.getController().getAccessRightVOWithId(new Integer(objectId));
                  InterceptionPointVO icpVO = InterceptionPointController.getController().getInterceptionPointVOWithId(acVO.getInterceptionPointId());
                  if(!processedEntities.contains("" + icpVO.getCategory() + "_" + acVO.getParameters()))
                  {
                    logger.info("icpVO:" + icpVO.getName());
                    if(icpVO.getName().indexOf("Content.") > -1)
                    {
                      logger.info("Was a content access... let's clear caches for that content.");
                      String idAsString = acVO.getParameters();
                      if(idAsString != null && !idAsString.equals(""))
                        addCacheUpdateDirective("org.infoglue.cms.entities.content.impl.simple.ContentImpl", idAsString, allIGCacheCalls);
                    }
                    else if(icpVO.getName().indexOf("ContentVersion.") > -1)
                    {
                      logger.info("Was a contentversion access... let's clear caches for that content.");
                      String idAsString = acVO.getParameters();
                      if(idAsString != null && !idAsString.equals(""))
                        addCacheUpdateDirective("org.infoglue.cms.entities.content.impl.simple.ContentVersionImpl", idAsString, allIGCacheCalls);
                    }
                    else if(icpVO.getName().indexOf("SiteNode.") > -1)
                    {
                      logger.info("Was a sitenode access... let's clear caches for that content.");
                      String idAsString = acVO.getParameters();
                      if(idAsString != null && !idAsString.equals(""))
                        addCacheUpdateDirective("org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl", idAsString, allIGCacheCalls);
                    }
                  else if(icpVO.getName().indexOf("SiteNodeVersion.") > -1)
                  {
                    logger.info("Was a sitenode version access... let's clear caches for that content.");
                      String idAsString = acVO.getParameters();
                      if(idAsString != null && !idAsString.equals(""))
                        addCacheUpdateDirective("org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl", idAsString, allIGCacheCalls);
                  }
                  else
                  {
                    logger.info("****************************");
                    logger.info("* WHAT TO DO WITH: " + icpVO.getName() + " *");
                    logger.info("****************************");
                  }
                    logger.info("Feeling done with " + "" + icpVO.getCategory() + "_" + acVO.getParameters());
                    processedEntities.add("" + icpVO.getCategory() + "_" + acVO.getParameters());
                  }
                  else
                    logger.info("Allready processed " + icpVO.getCategory() + "_" + acVO.getParameters());
                }
                catch(Exception e2)
                {
                  logger.warn("Error handling access right update: " + e2.getMessage());
                }
              }
             
                boolean isDependsClass = false;
              if(className != null && className.equalsIgnoreCase(PublicationDetailImpl.class.getName()))
                  isDependsClass = true;
       
              if(!typeId.equalsIgnoreCase("" + NotificationMessage.SYSTEM))
              {
                //CacheController.clearCaches(className, objectId, null);
              CacheController.setForcedCacheEvictionMode(true);
              }
                   
              if(!skipOriginalEntity)
                addCacheUpdateDirective(className, objectId, allIGCacheCalls);

              logger.info("Updating className with id:" + className + ":" + objectId);
              if(className != null && !typeId.equalsIgnoreCase("" + NotificationMessage.SYSTEM) && !skipOriginalEntity)
            {
                Class type = Class.forName(className);
     
                if(!isDependsClass &&
                    className.equalsIgnoreCase(SystemUserImpl.class.getName()) ||
                    className.equalsIgnoreCase(RoleImpl.class.getName()) ||
                    className.equalsIgnoreCase(GroupImpl.class.getName()) ||
                    className.equalsIgnoreCase(SmallSystemUserImpl.class.getName()) ||
                    className.equalsIgnoreCase(SmallRoleImpl.class.getName()) ||
                    className.equalsIgnoreCase(SmallGroupImpl.class.getName()) ||
                    className.equalsIgnoreCase(SystemUserRoleImpl.class.getName()) ||
                    className.equalsIgnoreCase(SystemUserGroupImpl.class.getName()))
                {
                    Object[] ids = {objectId};
                    CacheController.clearCache(type, ids);
              }
                else if(!isDependsClass)
                {
                    Object[] ids = {new Integer(objectId)};
                  CacheController.clearCache(type, ids);
                }
     
              //If it's an contentVersion we should delete all images it might have generated from attributes.
              if(Class.forName(className).getName().equals(ContentImpl.class.getName()))
              {
                  logger.info("We clear all small contents as well " + objectId);
                Class typesExtra = SmallContentImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
 
                  logger.info("We clear all small contents as well " + objectId);
                Class typesExtraSmallish = SmallishContentImpl.class;
                Object[] idsExtraSmallish = {new Integer(objectId)};
                CacheController.clearCache(typesExtraSmallish, idsExtraSmallish);
 
                logger.info("We clear all medium contents as well " + objectId);
                Class typesExtraMedium = MediumContentImpl.class;
                Object[] idsExtraMedium = {new Integer(objectId)};
                CacheController.clearCache(typesExtraMedium, idsExtraMedium);
              }
              if(Class.forName(className).getName().equals(ContentVersionImpl.class.getName()))
              {
                  logger.info("We clear all small contents as well " + objectId);
                Class typesExtra = SmallContentVersionImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
 
                  logger.info("We clear all small contents as well " + objectId);
                Class typesExtraSmallest = SmallestContentVersionImpl.class;
                Object[] idsExtraSmallest = {new Integer(objectId)};
                CacheController.clearCache(typesExtraSmallest, idsExtraSmallest);
              }
              else if(Class.forName(className).getName().equals(AvailableServiceBindingImpl.class.getName()))
              {
                  Class typesExtra = SmallAvailableServiceBindingImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(SiteNodeImpl.class.getName()))
              {
                  Class typesExtra = SmallSiteNodeImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(SiteNodeVersionImpl.class.getName()))
              {
                  Class typesExtra = SmallSiteNodeVersionImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(DigitalAssetImpl.class.getName()))
              {
                CacheController.clearCache("digitalAssetCache");
                Class typesExtra = SmallDigitalAssetImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
               
                Class typesExtraMedium = MediumDigitalAssetImpl.class;
                Object[] idsExtraMedium = {new Integer(objectId)};
                CacheController.clearCache(typesExtraMedium, idsExtraMedium);
 
                String disableAssetDeletionInLiveThread = CmsPropertyHandler.getDisableAssetDeletionInLiveThread();
                if(disableAssetDeletionInLiveThread != null && !disableAssetDeletionInLiveThread.equals("true"))
                {
                  logger.info("We should delete all images with digitalAssetId " + objectId);
                  DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer(objectId));
                }
              }
              else if(Class.forName(className).getName().equals(MediumDigitalAssetImpl.class.getName()))
              {
                CacheController.clearCache("digitalAssetCache");
                Class typesExtra = SmallDigitalAssetImpl.class;
                Object[] idsExtra = {new Integer(objectId)};
                CacheController.clearCache(typesExtra, idsExtra);
               
                Class typesExtraMedium = DigitalAssetImpl.class;
                Object[] idsExtraMedium = {new Integer(objectId)};
                CacheController.clearCache(typesExtraMedium, idsExtraMedium);
 
                String disableAssetDeletionInLiveThread = CmsPropertyHandler.getDisableAssetDeletionInLiveThread();
                if(disableAssetDeletionInLiveThread != null && !disableAssetDeletionInLiveThread.equals("true"))
                {
                  logger.info("We should delete all images with digitalAssetId " + objectId);
                  DigitalAssetDeliveryController.getDigitalAssetDeliveryController().deleteDigitalAssets(new Integer(objectId));
                }
              }
              else if(Class.forName(className).getName().equals(SystemUserImpl.class.getName()))
              {
                  Class typesExtra = SmallSystemUserImpl.class;
                Object[] idsExtra = {objectId};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(RoleImpl.class.getName()))
              {
                  Class typesExtra = SmallRoleImpl.class;
                Object[] idsExtra = {objectId};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(GroupImpl.class.getName()))
              {
                  Class typesExtra = SmallGroupImpl.class;
                Object[] idsExtra = {objectId};
                CacheController.clearCache(typesExtra, idsExtra);
              }
              else if(Class.forName(className).getName().equals(PublicationImpl.class.getName()))
              {
                logger.info("**************************************");
                logger.info("*    HERE THE MAGIC SHOULD HAPPEN    *");
                logger.info("**************************************");
               
                PublicationVO publicationVO = PublicationController.getController().getPublicationVO(new Integer(objectId));
                if(publicationVO != null)
                {
                  AssetCleanerThread assetCleaningThread = new AssetCleanerThread();
                  List publicationDetailVOList = PublicationController.getController().getPublicationDetailVOList(new Integer(objectId));
                  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(publicationDetailVO.getEntityClass().indexOf("pageCache") > -1)
                    {
                      logger.info("publicationDetailVO.getEntityClass():" + publicationDetailVO.getEntityClass());
                     
                      if(publicationDetailVO.getEntityClass().indexOf("pageCache:") == 0)
                      {
                        String groupQualifyer = publicationDetailVO.getEntityClass().substring("pageCache:".length());
                        logger.info("This is a application pageCache-clear request... specific:" + groupQualifyer);
                        CacheController.clearCaches(publicationDetailVO.getEntityClass(), "" + publicationDetailVO.getEntityId(), null);
                      }
                      else
                      {
                        CacheController.clearCaches("pageCache", "selectiveCacheUpdateNonApplicable", null);
                      }
                     
                        //CacheController.clearCacheForGroup("pageCacheExtra", "selectiveCacheUpdateNonApplicable");
                      //CacheController.clearCacheForGroup("pageCache", "selectiveCacheUpdateNonApplicable");                     
                    }
                    else if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(ContentVersion.class.getName()))
                    {
                      logger.info("We clear all caches having references to contentVersion: " + publicationDetailVO.getEntityId());
                      try
                      {
                        Integer contentId = ContentVersionController.getContentVersionController().getContentIdForContentVersion(publicationDetailVO.getEntityId());
                        
                          ContentVO previousContentVO = ContentController.getContentController().getContentVOWithId(contentId);
                          Integer previousParentContentId = previousContentVO.getParentContentId();
                          logger.info("previousParentContentId:" + previousParentContentId);
 
                          addCacheUpdateDirective(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), allIGCacheCalls);
                          //CacheController.clearCaches(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), null);
                         
                        CacheController.clearCache(SmallContentVersionImpl.class, new Integer[]{new Integer(publicationDetailVO.getEntityId())});
                        CacheController.clearCache(SmallestContentVersionImpl.class, new Integer[]{new Integer(publicationDetailVO.getEntityId())});
 
                        logger.info("We clear all small contents as well " + contentId);
                        CacheController.clearCache(ContentImpl.class, new Integer[]{contentId});
                        CacheController.clearCache(SmallContentImpl.class, new Integer[]{contentId});
                        CacheController.clearCache(SmallishContentImpl.class, new Integer[]{contentId});
                        CacheController.clearCache(MediumContentImpl.class, new Integer[]{contentId});
                        CacheController.clearCache(SmallSiteNodeVersionImpl.class, new Integer[]{new Integer(objectId)});   
                       
                        logger.info("Handling parents....");
                       
                        ContentVO contentVOAfter = ContentController.getContentController().getContentVOWithId(contentId);
                          Integer currentParentContentId = contentVOAfter.getParentContentId();
                          logger.info("previousParentContentId:" + previousParentContentId);
                          logger.info("currentParentContentId:" + currentParentContentId);
 
                          logger.info("We should also clear the parents...");
                        if(currentParentContentId != null)
                        {
                          logger.info("contentVOAfter - clear the new:" + contentVOAfter.getName() + " / " + currentParentContentId);
                          //CacheController.clearCaches(Content.class.getName(), currentParentContentId.toString(), null);
                          addCacheUpdateDirective(Content.class.getName(), currentParentContentId.toString(), allIGCacheCalls);
                         
                            logger.info("We clear all small siteNodes as well " + currentParentContentId);
                          CacheController.clearCache(ContentImpl.class, new Integer[]{currentParentContentId});
                          CacheController.clearCache(SmallContentImpl.class, new Integer[]{currentParentContentId});
                          CacheController.clearCache(SmallishContentImpl.class, new Integer[]{currentParentContentId});
                          CacheController.clearCache(MediumContentImpl.class, new Integer[]{currentParentContentId});
                        }
 
                        if(currentParentContentId != null && previousParentContentId != null && !previousParentContentId.equals(previousParentContentId))
                        {
                          logger.info("contentVOAfter - clear the new:" + contentVOAfter.getName() + " / " + currentParentContentId);
                          //CacheController.clearCaches(Content.class.getName(), previousParentContentId.toString(), null);
                          addCacheUpdateDirective(Content.class.getName(), previousParentContentId.toString(), allIGCacheCalls);
                         
                            logger.info("We clear all small siteNodes as well " + previousParentContentId);
                          CacheController.clearCache(ContentImpl.class, new Integer[]{previousParentContentId});
                          CacheController.clearCache(SmallContentImpl.class, new Integer[]{previousParentContentId});
                          CacheController.clearCache(SmallishContentImpl.class, new Integer[]{previousParentContentId});
                          CacheController.clearCache(MediumContentImpl.class, new Integer[]{previousParentContentId});
                        }

                        if (publicationDetailVO.getTypeId().equals(PublicationDetailVO.UNPUBLISH_LATEST))
                        {
                          assetCleaningThread.addContentVersion(publicationDetailVO.getEntityId());
                        }
                      }
                      catch(Exception e)
                      {
                        logger.warn("An error occurred handling content version from publication " + publicationVO.getId() + ":" + e.getMessage());
                      }
                    }
                    else if(Class.forName(publicationDetailVO.getEntityClass()).getName().equals(SiteNodeVersion.class.getName()))
                    {
                      System.out.println("SiteNodeVersion update....:" + publicationDetailVO.getEntityId());
                      try
                      {
                        SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(publicationDetailVO.getEntityId());
                        //logger.info("siteNodeVersionVO:" + siteNodeVersionVO.getId());
                        Integer siteNodeId = siteNodeVersionVO.getSiteNodeId();
                       
                        CacheController.clearCache("pageCacheLatestSiteNodeVersions", "" + siteNodeId);
                        String versionKey = "" + siteNodeId + "_" + CmsPropertyHandler.getOperatingMode() + "_siteNodeVersionVO";   
                          CacheController.clearCache("latestSiteNodeVersionCache", versionKey);
                       
                          logger.info("We also clear the meta info content..");
 
                          SiteNodeVO previousSiteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId);
                          Integer previousParentSiteNodeId = previousSiteNodeVO.getParentSiteNodeId();
                          //System.out.println("previousParentSiteNodeId:" + previousParentSiteNodeId);
                          Object previousParentSiteNodeIdCandidate = CacheController.getCachedObject("parentSiteNodeCache", "" + siteNodeId);
                          //System.out.println("previousParentSiteNodeIdCandidate:" + previousParentSiteNodeIdCandidate);
                          if(previousParentSiteNodeIdCandidate != null && !(previousParentSiteNodeIdCandidate instanceof NullObject))
                            previousParentSiteNodeId = ((SiteNodeVO)previousParentSiteNodeIdCandidate).getId();
                          //System.out.println("previousParentSiteNodeId:" + previousParentSiteNodeId);
                           
                          //CacheController.clearCaches(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), null);
                        //if(siteNodeId != null)
                        //  CacheController.clearCaches(SiteNode.class.getName(), siteNodeId.toString(), null);
                         
                          logger.info("We clear all small siteNodes as well " + siteNodeId);
                        CacheController.clearCache(SiteNodeImpl.class, new Integer[]{siteNodeId});
                        CacheController.clearCache(SmallSiteNodeImpl.class, new Integer[]{siteNodeId});
                        CacheController.clearCache(SmallSiteNodeVersionImpl.class, new Integer[]{new Integer(publicationDetailVO.getEntityId())});   
 
                        logger.info("We clear all contents as well " + previousSiteNodeVO.getMetaInfoContentId());
                        Class metaInfoContentExtra = ContentImpl.class;
                        Object[] idsMetaInfoContentExtra = {previousSiteNodeVO.getMetaInfoContentId()};
                        CacheController.clearCache(metaInfoContentExtra, idsMetaInfoContentExtra);
                       
                        logger.info("We clear all small contents as well " + previousSiteNodeVO.getMetaInfoContentId());
                        Class metaInfoContentExtraSmall = SmallContentImpl.class;
                        CacheController.clearCache(metaInfoContentExtraSmall, idsMetaInfoContentExtra);
                       
                        logger.info("We clear all smallish contents as well " + previousSiteNodeVO.getMetaInfoContentId());
                        Class metaInfoContentExtraSmallish = SmallishContentImpl.class;
                        CacheController.clearCache(metaInfoContentExtraSmallish, idsMetaInfoContentExtra);
     
                        logger.info("We clear all medium contents as well " + previousSiteNodeVO.getMetaInfoContentId());
                        Class metaInfoContentExtraMedium = MediumContentImpl.class;
                        CacheController.clearCache(metaInfoContentExtraMedium, idsMetaInfoContentExtra);
                       
                        //CacheController.clearCaches(ContentImpl.class.getName(), previousSiteNodeVO.getMetaInfoContentId().toString(), null);
                        addCacheUpdateDirective(ContentImpl.class.getName(), previousSiteNodeVO.getMetaInfoContentId().toString(), allIGCacheCalls);
     
                        Database db = CastorDatabaseService.getDatabase();
                        db.begin();
                       
                        LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(previousSiteNodeVO.getRepositoryId(), db);
                        ContentVersionVO metaInfoContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(previousSiteNodeVO.getMetaInfoContentId(), masterLanguageVO.getId(), db);
                        addCacheUpdateDirective(ContentVersionImpl.class.getName(), metaInfoContentVersionVO.getId().toString(), allIGCacheCalls);
                       
                        List contentVersionIds = new ArrayList();
                        if(previousSiteNodeVO.getMetaInfoContentId() != null)
                        {
                          List<SmallestContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getSmallestContentVersionVOList(previousSiteNodeVO.getMetaInfoContentId(), db);
                          for(SmallestContentVersionVO cvVO : contentVersionVOList)
                          {
                            contentVersionIds.add(cvVO.getId());
                            logger.info("We clear the meta info contentVersion " + cvVO.getId());
                          }
                        }
                        /*
                        Content content = ContentController.getContentController().getReadOnlyContentWithId(previousSiteNodeVO.getMetaInfoContentId(), db);
                        List contentVersionIds = new ArrayList();
                        Iterator contentVersionIterator = content.getContentVersions().iterator();
                        logger.info("Versions:" + content.getContentVersions().size());
                        while(contentVersionIterator.hasNext())
                        {
                          ContentVersion contentVersion = (ContentVersion)contentVersionIterator.next();
                          contentVersionIds.add(contentVersion.getId());
                          logger.info("We clear the meta info contentVersion " + contentVersion.getId());
                        }
                        */
     
                        db.rollback();
     
                        db.close();
                       
                        Iterator contentVersionIdsIterator = contentVersionIds.iterator();
                        logger.info("Versions:" + contentVersionIds.size());
                        while(contentVersionIdsIterator.hasNext())
                        {
                          Integer contentVersionId = (Integer)contentVersionIdsIterator.next();
                          logger.info("We clear the meta info contentVersion " + contentVersionId);
                          Class metaInfoContentVersionExtra = ContentVersionImpl.class;
                          Object[] idsMetaInfoContentVersionExtra = {contentVersionId};
                          CacheController.clearCache(metaInfoContentVersionExtra, idsMetaInfoContentVersionExtra);
                          //CacheController.clearCaches(ContentVersionImpl.class.getName(), contentVersionId.toString(), null);
                          //addCacheUpdateDirective(ContentVersionImpl.class.getName(), contentVersionId.toString(), allIGCacheCalls);
                        }
                       
                        logger.info("After:" + contentVersionIds.size());
     
                        SiteNodeVersionVO previousSiteNodeVersionVO = SiteNodeVersionController.getController().getPreviousActiveSiteNodeVersionVO(siteNodeVersionVO.getSiteNodeId(), siteNodeVersionVO.getId(), new Integer(CmsPropertyHandler.getOperatingMode()));
                        //logger.info("previousSiteNodeVersionVO:" + previousSiteNodeVersionVO.getId());
 
                        addCacheUpdateDirective(publicationDetailVO.getEntityClass(), publicationDetailVO.getEntityId().toString(), allIGCacheCalls);
                        if(siteNodeId != null)
                        {
                          //logger.info("What really happened.... let's find out");
                          boolean anyRealDifferences = isThereAnyRealDifferencesBetweenSiteNodeVersions(siteNodeVersionVO, previousSiteNodeVersionVO);
                          //logger.info("anyRealDifferences:" + anyRealDifferences);
                          if(anyRealDifferences)
                            addCacheUpdateDirective(SiteNode.class.getName(), siteNodeId.toString(), allIGCacheCalls);
                          else
                          {
                            //logger.info("We'll skip it and assume that this was just a meta info update...");
                          }
                        }
 
                        //Handling access rights...
                        if(siteNodeVersionVO.getIsProtected().intValue() != SiteNodeVersionVO.INHERITED || (previousSiteNodeVersionVO != null && previousSiteNodeVersionVO.getIsProtected().intValue() != SiteNodeVersionVO.INHERITED))
                        {
                              CacheController.clearCache(AccessRightImpl.class);
                              CacheController.clearCache(AccessRightRoleImpl.class);
                              CacheController.clearCache(AccessRightGroupImpl.class);
                              CacheController.clearCache(AccessRightUserImpl.class);
 
                            CacheController.clearCache("personalAuthorizationCache");
                        }
                       
                        logger.info("Handling parents....");
                       
                        SiteNodeVO siteNodeVOAfter = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId);
                          Integer currentParentSiteNodeId = siteNodeVOAfter.getParentSiteNodeId();
                          //System.out.println("previousParentSiteNodeId:" + previousParentSiteNodeId);
                          //System.out.println("currentParentSiteNodeId:" + currentParentSiteNodeId);
 
                          logger.info("We should also clear the parents...");
                        if(currentParentSiteNodeId != null)
                        {
                          if(previousSiteNodeVersionVO == null)
                          {
                            //logger.info("Looks to be first version - let's update parent as well");
                            logger.info("siteNodeVOAfter - clear the new:" + siteNodeVOAfter.getName() + " / " + currentParentSiteNodeId);
                            addCacheUpdateDirective(SiteNode.class.getName(), currentParentSiteNodeId.toString(), allIGCacheCalls);
                          }
                         
                            logger.info("We clear all small siteNodes as well " + currentParentSiteNodeId);
                          CacheController.clearCache(SiteNodeImpl.class, new Integer[]{currentParentSiteNodeId});
                          CacheController.clearCache(SmallSiteNodeImpl.class, new Integer[]{currentParentSiteNodeId});
                        }
 
                        if(currentParentSiteNodeId != null && previousParentSiteNodeId != null && !previousParentSiteNodeId.equals(currentParentSiteNodeId))
                        {
                          System.out.println("siteNodeVOAfter was not the same - lets clear the old:" + siteNodeVOAfter.getName() + " / " + currentParentSiteNodeId);
                          //CacheController.clearCaches(SiteNode.class.getName(), previousParentSiteNodeId.toString(), null);
                          addCacheUpdateDirective(SiteNode.class.getName(), currentParentSiteNodeId.toString(), allIGCacheCalls);
                          addCacheUpdateDirective(SiteNode.class.getName(), previousParentSiteNodeId.toString(), allIGCacheCalls);
                         
                            logger.info("We clear all small siteNodes as well " + previousParentSiteNodeId);
                          CacheController.clearCache(SiteNodeImpl.class, new Integer[]{previousParentSiteNodeId});
                          CacheController.clearCache(SmallSiteNodeImpl.class, new Integer[]{previousParentSiteNodeId});
                        }
                       
                        if(publicationDetailVO.getTypeId().intValue() == PublicationDetailVO.MOVED.intValue())
                            CacheController.clearCache("childSiteNodesCache");

                      }
                      catch (Exception e)
                      {
                        logger.warn("An error occurred handling sitenode version from publication " + publicationVO.getId() + ":" + e.getMessage());
                      }
                    }
                  }

                  assetCleaningThread.startIfNotEmpty();
                }
                else
                {
                  long diff = System.currentTimeMillis() - cacheEvictionBean.getReceivedTimestamp();
                  if(diff < 1000*60)
                  {
                    processedInterupted = true;
                    logger.warn("Could not find publication in database. It may be a replication delay issue - lets try again.");
                    synchronized(CacheController.notifications)
                        {
                        CacheController.notifications.add(cacheEvictionBean);
                        }
                  }
                  else
                  {
                    logger.warn("Could not find publication in database. It may be a replication delay issue but now it's been very long so we have to abort.");
                  }
                }
              }
             
                long elapsedTime = t.getElapsedTime();
                if(elapsedTime > 100)
                  logger.warn("Cleared all castor caches for " + className + ":" + objectId + " took");

              for(Map<String,String> igCacheCall : allIGCacheCalls)
              {
                logger.info("Calling clear caches with:" + igCacheCall.get("className") + ":" + igCacheCall.get("objectId"));
                CacheController.clearCaches(igCacheCall.get("className"), igCacheCall.get("objectId"), null);
               
                  elapsedTime = t.getElapsedTime();
                  if(elapsedTime > 100)
                    logger.warn("Clearing all caches for " + igCacheCall.get("className") + ":" + igCacheCall.get("objectId") + " took");
              }

              if(CmsPropertyHandler.getServerNodeProperty("recacheEntities", true, "false").equals("true"))
                recacheEntities(cacheEvictionBean);
           
            else if(!skipOriginalEntity)
            {
              /*
              logger.info("Was notification message in selective live publication...");
              logger.info("className:" + className);
              logger.info("objectId:" + objectId);
              logger.info("objectName:" + objectName);
              logger.info("typeId:" + typeId);
              */
              if(className.equals("ServerNodeProperties"))
              {
                logger.info("clearing InfoGlueAuthenticationFilter");
                CacheController.clearServerNodeProperty(true);
                logger.info("cleared InfoGlueAuthenticationFilter");
                InfoGlueAuthenticationFilter.initializeProperties();
                logger.info("initialized InfoGlueAuthenticationFilter");
                logger.info("Shortening page stats");
                RequestAnalyser.shortenPageStatistics();
 
                  logger.info("Updating all caches from SelectiveLivePublicationThread as this was a publishing-update\n\n\n");
                  //CacheController.clearCastorCaches();

                  String[] excludedCaches = CacheController.getPublicationPersistentCacheNames();
                logger.info("clearing all except " + excludedCaches + " as we are in publish mode..\n\n\n");                     
                CacheController.clearCaches(null, null, excludedCaches);
                 
                //logger.info("Recaching all caches as this was a publishing-update\n\n\n");
                //CacheController.cacheCentralCastorCaches();
                CacheController.clearCastorCaches();
                logger.info("Cleared all castor caches...");
               
                //logger.info("Finally clearing page cache and other caches as this was a publishing-update\n\n\n");
                logger.info("Finally clearing page cache and some other caches as this was a publishing-update\n\n\n");
                //CacheController.clearCache("ServerNodeProperties");
                //CacheController.clearCache("serverNodePropertiesCache");
               
                  CacheController.clearCache("boundContentCache");
                    //CacheController.clearFileCaches("pageCache");
                PageCacheHelper.getInstance().clearPageCache();
               
                CacheController.clearCache("pageCache");
                CacheController.clearCache("pageCacheExtra");
                CacheController.clearCache("componentCache");
                CacheController.clearCache("NavigationCache");
                CacheController.clearCache("pagePathCache");
                CacheController.clearCache("pageCacheParentSiteNodeCache");
                CacheController.clearCache("pageCacheLatestSiteNodeVersions");
                CacheController.clearCache("pageCacheSiteNodeTypeDefinition");
                try
                {
                  LuceneUsersController.getController().getUserCount(null);
                }
                catch (Exception e)
                {
                  logger.error("Problem recaching users:" + e.getMessage());
                }
              }
              else if(className.equalsIgnoreCase("PortletRegistry"))
                {
                logger.info("clearing portletRegistry");
                CacheController.clearPortlets();
                logger.info("cleared portletRegistry");
                }
              else if(className.indexOf("RepositoryImpl") > -1)
                {
                logger.info("clearing repo affecting stuff");
                CacheController.clearServerNodeProperty(true);

                Class repoClass = RepositoryImpl.class;
                CacheController.clearCache(repoClass);
                CacheController.clearCaches(repoClass.getName(), null, null);

                CacheController.clearCache("repositoryCache");
                CacheController.clearCache("masterRepository");
                CacheController.clearCache("parentRepository");
                CacheController.clearCache("componentPropertyCache");
                    //CacheController.clearFileCaches("pageCache");
                PageCacheHelper.getInstance().clearPageCache();

                    CacheController.clearCache("pageCache");
                CacheController.clearCache("pageCacheExtra");
                CacheController.clearCache("componentCache");
                CacheController.clearCache("NavigationCache");
                CacheController.clearCache("pagePathCache");
                  URIMapperCache.getInstance().clear();
                logger.info("cleared repo affecting stuff");
                }
              else
              {
                logger.info("This was an deviation: " + className);
                Class type = Class.forName(className);
                    Object[] ids = {objectId};
                    CacheController.clearCache(type, ids);
                    CacheController.clearCache(type);
                  CacheController.clearCaches(className, objectId, null);
                 
                  logger.info("Clearing content types and repos");
                  Class ctdClass = ContentTypeDefinitionImpl.class;
                  CacheController.clearCache("contentTypeDefinitionCache");
                CacheController.clearCache(ctdClass);
                CacheController.clearCaches(ctdClass.getName(), null, null);

                Class repoClass = RepositoryImpl.class;
                CacheController.clearCache("repositoryCache");
                CacheController.clearCache("masterRepository");
                CacheController.clearCache(repoClass);
                CacheController.clearCaches(repoClass.getName(), null, null);

                Class categoryClass = CategoryImpl.class;
                CacheController.clearCache("categoryCache");
                CacheController.clearCache(categoryClass);
                CacheController.clearCaches(categoryClass.getName(), null, null);
              }
               
              for(Map<String,String> igCacheCall : allIGCacheCalls)
              {
                if(igCacheCall.get("className") == null || !igCacheCall.get("className").equals("ServerNodeProperties"))
                {
                  logger.info("Calling clear caches with:" + igCacheCall.get("className") + ":" + igCacheCall.get("objectId"));
                  CacheController.clearCaches(igCacheCall.get("className"), igCacheCall.get("objectId"), null);
                }
              }
            }
            }
            catch (Exception e)
            {
              logger.error("An error occurred handling cache eviction bean in SelectiveLivePublicationThread:" + e.getMessage());
              logger.warn("An error occurred handling cache eviction bean in SelectiveLivePublicationThread:" + e.getMessage(), e);
          }
            finally
            {
            //TODO
            CacheEvictionBeanListenerService.getService().notifyListeners(cacheEvictionBean);
 
              RequestAnalyser.getRequestAnalyser().removeOngoingPublications(cacheEvictionBean);
              if(!processedInterupted)
              {
                cacheEvictionBean.setProcessed();
                if(cacheEvictionBean.getPublicationId() > -1 || cacheEvictionBean.getClassName().equals("ServerNodeProperties"))
                  RequestAnalyser.getRequestAnalyser().addPublication(cacheEvictionBean);
              }             
            }
        }
      }
View Full Code Here

Examples of org.infoglue.deliver.applications.databeans.CacheEvictionBean

              }
            }
            else
            {
              Map<String,String> responseMap = httpHelper.toMap(response.trim(), "utf-8");
              CacheEvictionBean bean = CacheEvictionBean.getCacheEvictionBean(responseMap);
              if(bean == null)
                throw new Exception("No information found");
             
              VisualFormatter visualFormatter = new VisualFormatter();
              publicationDetails.add(new String[]{"" + deliverUrl, responseMap.get("status"), "" + visualFormatter.formatDate(bean.getProcessedTimestamp(), "yyyy-MM-dd HH:mm:ss")});
            }
          }
        }
        catch(Exception e)
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.