Package org.infoglue.cms.entities.management

Examples of org.infoglue.cms.entities.management.PageDeliveryMetaDataVO


        deliveryContext.setHttpServletResponse(this.getResponse());
        deliveryContext.setUseFullUrl(Boolean.parseBoolean(CmsPropertyHandler.getUseDNSNameInURI()));
        boolean enableIfModifiedHeaders = CmsPropertyHandler.getEnableIfModifiedHeaders();
       
        boolean skipRender = false;
        PageDeliveryMetaDataVO pdmd = null;

        if (enableIfModifiedHeaders) {
          try
          {
            boolean isIfModifiedLogic = getIsIfModifiedLogicValid(deliveryContext, templateController.getPrincipal(), true);
            logger.info("enableIfModifiedHeaders state is:" + enableIfModifiedHeaders);
            if(isIfModifiedLogic)
            {
              String ifModifiedSince = this.getRequest().getHeader("If-Modified-Since");
              logger.info("ifModifiedSince:" + ifModifiedSince);
              //System.out.println("pageKey:" + pageKey);
              if(ifModifiedSince != null && !ifModifiedSince.equals(""))
              {
                pdmd = PageDeliveryMetaDataController.getController().getPageDeliveryMetaDataVO(dbWrapper.getDatabase(), this.siteNodeId, this.languageId, this.contentId);
                logger.info("pdmd A:" + (pdmd == null ? "null" : pdmd.getId()));
                if(pdmd != null && pdmd.getLastModifiedDateTime() != null)
                {
                  logger.info("pdmd getLastModifiedTimeout:" + pdmd.getLastModifiedTimeout());
                  logger.info("System.currentTimeMillis:" + System.currentTimeMillis());
                  long diff = System.currentTimeMillis() - (pdmd.getLastModifiedTimeout() != null ? pdmd.getLastModifiedTimeout().getTime() : 0);
                  logger.info("diff:" + diff);
                  if(diff < 0 || pdmd.getLastModifiedTimeout() == null)
                  {
                    Date ifModifiedSinceDate = HTTP_DATE_FORMAT.parse( ifModifiedSince );
                    logger.info("pdmd B:" + pdmd.getId() + ":" + pdmd.getLastModifiedDateTime());
                    logger.info("*************\nCompares:" + pdmd.getLastModifiedDateTime() + "=" + ifModifiedSinceDate);
                    logger.info("pdmd.getLastModifiedTimeout():" + pdmd.getLastModifiedTimeout());
                    if(ifModifiedSinceDate.getTime() >= pdmd.getLastModifiedDateTime().getTime() - 1000)
                    {
                      logger.info("Returning NOT_MODIFIED");
                      this.getResponse().setStatus( HttpServletResponse.SC_NOT_MODIFIED );
                      pageTimer.printElapsedTime("Delivered NOT MODIFIED IN", 50);
                      skipRender = true;
                      return NONE;
                    }
                  }
                }
              }
            }
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
       
        logger.info("skipRender:" + skipRender);
        if(!skipRender)
        {
          SiteNodeTypeDefinitionVO siteNodeTypeDefinitionVO = getSiteNodeTypeDefinition(this.siteNodeId, dbWrapper.getDatabase());
             
          try
            {
                String invokerClassName = siteNodeTypeDefinitionVO.getInvokerClassName();
                PageInvoker pageInvoker = (PageInvoker)Class.forName(invokerClassName).newInstance();
                pageInvoker.setParameters(dbWrapper, this.getRequest(), this.getResponse(), templateController, deliveryContext);
                pageInvoker.deliverPage();
 
                boolean isCachedResponse = deliveryContext.getIsCachedResponse();
                logger.info("isCachedResponse:" + isCachedResponse);
               
            boolean isIfModifiedLogic = getIsIfModifiedLogicValid(deliveryContext, templateController.getPrincipal(), false);
            logger.info("isIfModifiedLogic 2:" + isIfModifiedLogic);
            logger.info("deliveryContext.getLastModifiedDateTime():" + deliveryContext.getLastModifiedDateTime());
           
            /*Fetching meta info data*/
            if(isCachedResponse && pdmd == null && isIfModifiedLogic && enableIfModifiedHeaders) {
              logger.info("enableIfModifiedHeaders state is:" + enableIfModifiedHeaders);
              pdmd = PageDeliveryMetaDataController.getController().getPageDeliveryMetaDataVO(dbWrapper.getDatabase(), this.siteNodeId, this.languageId, this.contentId);
            }
           
            if(pdmd != null)
              logger.info("pdmd():" + pdmd.getLastModifiedDateTime());

            if(isIfModifiedLogic && (!isCachedResponse || pdmd == null/* || deliveryContext.getLastModifiedDateTime().after(pdmd.getLastModifiedDateTime())*/))
            {
              Timer t2 = new Timer();
              logger.info("We should register the last modified date now. Add it to the thread which registers it: " + deliveryContext.getLastModifiedDateTime() + ":" + deliveryContext.hashCode());
              try
              {
                PageDeliveryMetaDataVO pageDeliveryMetaDataVO = new PageDeliveryMetaDataVO();

                List<String> entities = deliveryContext.getAllUsedEntitiesAsSet();
               
                List<String> allUsedEntitiesFilteredCopy = new ArrayList<String>();
                for(String s : entities)
                {
                  if(s.startsWith("content_") && s.indexOf("_", 8) == -1)
                  {
                    allUsedEntitiesFilteredCopy.add(s.replaceAll("content_", "c_"));
                    //allUsedEntitiesFilteredCopy.add(s); //getPooledString(s.hashCode()));
                    //System.out.println("Added: " + s);
                  }
                  else if(s.startsWith("siteNode_"))
                    allUsedEntitiesFilteredCopy.add(s.replaceAll("siteNode_", "sn_"));
                  else if(s.startsWith("selectiveCacheUpdateNonApplicable"))
                  {
                    allUsedEntitiesFilteredCopy.clear();
                    allUsedEntitiesFilteredCopy.add(s);
                    pageDeliveryMetaDataVO.setSelectiveCacheUpdateNotApplicable(true);
                  }
                }

                Collection<PageDeliveryMetaDataEntityVO> entitiesCollection = new ArrayList<PageDeliveryMetaDataEntityVO>();
                for(String s : allUsedEntitiesFilteredCopy)
                {
                  if(s.startsWith("c_"))
                  {
                    PageDeliveryMetaDataEntityVO pageDeliveryMetaDataEntityVO = new PageDeliveryMetaDataEntityVO();
                    pageDeliveryMetaDataEntityVO.setContentId(new Integer(s.replaceAll("c_", "")));
                    pageDeliveryMetaDataEntityVO.setPageDeliveryMetaDataId(pageDeliveryMetaDataVO.getId());
                    entitiesCollection.add(pageDeliveryMetaDataEntityVO);
                  }
                  else if(s.startsWith("sn_"))
                  {
                    PageDeliveryMetaDataEntityVO pageDeliveryMetaDataEntityVO = new PageDeliveryMetaDataEntityVO();
                    pageDeliveryMetaDataEntityVO.setSiteNodeId(new Integer(s.replaceAll("sn_", "")));
                    pageDeliveryMetaDataEntityVO.setPageDeliveryMetaDataId(pageDeliveryMetaDataVO.getId());
                    entitiesCollection.add(pageDeliveryMetaDataEntityVO);
                  }
                }

                String allUsedEntitiesAsString = StringUtils.join(allUsedEntitiesFilteredCopy, "|");
                logger.info("allUsedEntitiesAsString:" + allUsedEntitiesAsString);
                //System.out.println("allUsedEntitiesAsString:" + allUsedEntitiesAsString.length());
               
                pageDeliveryMetaDataVO.setSiteNodeId(deliveryContext.getSiteNodeId());
                pageDeliveryMetaDataVO.setLanguageId(deliveryContext.getLanguageId());
                pageDeliveryMetaDataVO.setContentId(deliveryContext.getContentId());
                pageDeliveryMetaDataVO.setLastModifiedDateTime(deliveryContext.getLastModifiedDateTime());
                if(deliveryContext.getPageCacheTimeout() != null && deliveryContext.getPageCacheTimeout() > -1)
                {
                  logger.info("deliveryContext.getPageCacheTimeout(): " + deliveryContext.getPageCacheTimeout());
                  logger.info("Setting page timeout: " + deliveryContext.getPageCacheTimeout()*1000);
                  logger.info("Current time: " + System.currentTimeMillis());
                  Calendar cal = Calendar.getInstance();
                  cal.add(Calendar.SECOND, deliveryContext.getPageCacheTimeout());
                  pageDeliveryMetaDataVO.setLastModifiedTimeout(cal.getTime());
                }
                else
                  logger.info("AAAAAAAAAAAAAAAAAAAAA: " + deliveryContext.getPageCacheTimeout());

                pageDeliveryMetaDataVO.setUsedEntities(allUsedEntitiesAsString);
               
                if (enableIfModifiedHeaders) {
                  PageDeliveryMetaDataController.getController().deletePageDeliveryMetaData(dbWrapper.getDatabase(), pageDeliveryMetaDataVO.getSiteNodeId(), null);
                  PageDeliveryMetaDataController.getController().create(dbWrapper.getDatabase(), pageDeliveryMetaDataVO, entitiesCollection);
                }
               
                String key = "" + pageDeliveryMetaDataVO.getSiteNodeId() + "_" + pageDeliveryMetaDataVO.getLanguageId() + "_" + pageDeliveryMetaDataVO.getContentId();
                  logger.info("key on store:" + key);
                CacheController.cacheObjectInAdvancedCache("pageDeliveryMetaDataCache", key, pageDeliveryMetaDataVO);
              }
              catch (Exception e)
              {
View Full Code Here


    //System.out.println("languageId:" + languageId);
    //System.out.println("contentId:" + contentId);

      String key = "" + siteNodeId + "_" + languageId + "_" + contentId;
      //System.out.println("key on fetch 1:" + key);
    PageDeliveryMetaDataVO pageDeliveryMetaDataVO = (PageDeliveryMetaDataVO)CacheController.getCachedObjectFromAdvancedCache("pageDeliveryMetaDataCache", key);
    //System.out.println("pageDeliveryMetaDataVO:" + pageDeliveryMetaDataVO);
   
    if(pageDeliveryMetaDataVO == null)
    {
      //System.out.println("key on fetch:" + key);
View Full Code Here

   * This method removes a Language from the system and also cleans out all depending repositoryLanguages.
   */
 
    public PageDeliveryMetaDataVO create(PageDeliveryMetaDataVO pageDeliveryMetaDataVO, Collection<PageDeliveryMetaDataEntityVO> entitiesCollection) throws ConstraintException, SystemException, Exception
    {
      PageDeliveryMetaDataVO result = null;
     
    Database db = CastorDatabaseService.getDatabase();
   
    try
    {
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.management.PageDeliveryMetaDataVO

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.