Package org.infoglue.deliver.util

Examples of org.infoglue.deliver.util.Timer


          public void run()
          {
            try
            {
              Thread.sleep(1000);
              Timer t = new Timer();
              List<Integer> localComponentIdsList = new ArrayList<Integer>();
              localComponentIdsList.addAll(componentIdsToRecache);
              componentIdsToRecache.clear();
              for(Integer localComponentContentId : localComponentIdsList)
              {
                reIndexComponentContent(localComponentContentId);
              }
              long time = t.getElapsedTime();
              if(time > 100)
                logger.warn("ReIndexComponentsTask took a bit to long:" + time);
            }
            catch (Exception e)
            {
View Full Code Here


    {
      logger.info("There was cached components:" + components.size());
    }
    else
    {
      Timer t = new Timer();
        components = getComponents(allowedComponentNames, disallowedComponentNames, allowedComponentGroupNames, principal, db);
        if(logger.isInfoEnabled())
          t.printElapsedTime("getComponents");
        /*
        Iterator componentsIterator = components.iterator();
      while(componentsIterator.hasNext())
      {
          ContentVO contentVO = (ContentVO)componentsIterator.next();
View Full Code Here

    if(templatesAndPagePartMapPreCached != null && templatesAndPagePartMapPreCached)
    {
      Map<String,List<ContentVO>> templatesAndPagePartMap = (Map<String,List<ContentVO>>)CacheController.getCachedObject("componentContentsCache", cacheKey);
      logger.info("templatesAndPagePartMap: " + templatesAndPagePartMap.size());
     
      Timer t = new Timer();
      logger.info("Returning from cache....:" + allowedComponentNames + ":" + allowedComponentGroups);
      List<ContentVO> results = new ArrayList<ContentVO>();
     
      if(allowedComponentNames == null && allowedComponentGroups == null)
      {
        List<ContentVO> allComponents = templatesAndPagePartMap.get("all");
        if(allComponents != null)
          results.addAll(allComponents);
      }
      else
      {
        if(allowedComponentNames != null && allowedComponentNames.length > 0)
        {
          for(int i=0; i<allowedComponentNames.length; i++)
              {
            logger.info("Adding all matching:" + allowedComponentNames[i]);
            List<ContentVO> contents = templatesAndPagePartMap.get(allowedComponentNames[i]);
            if(contents != null)
              results.addAll(contents);
              }
        }
       
        List<List<ContentVO>> unionList = new ArrayList<List<ContentVO>>();
        if(allowedComponentGroups != null && allowedComponentGroups.length > 0)
        {
              for(int i=0; i<allowedComponentGroups.length; i++)
              {
                String allowedComponentGroup = allowedComponentGroups[i];
                logger.info("allowedComponentGroup:" + allowedComponentGroup);
               
                if(allowedComponentGroup.trim().startsWith("&"))
                {
                  String actualAllowedComponentGroup = allowedComponentGroup.substring(1);
                  logger.info("actualAllowedComponentGroup:" + actualAllowedComponentGroup);
                  List<ContentVO> contentsToIncludeIfInBoth = templatesAndPagePartMap.get(actualAllowedComponentGroup);
                  unionList.add(contentsToIncludeIfInBoth);
                }
                else
                {
                  logger.info("Adding all matching:" + allowedComponentGroup);
                  List<ContentVO> contents = templatesAndPagePartMap.get(allowedComponentGroup);
              if(contents != null)
                results.addAll(contents);
                }
              }
        }
       
        if(unionList != null && unionList.size() > 0)
        {
          Iterator<ContentVO> resultsIterator = results.iterator();
          while(resultsIterator.hasNext())
          {
            ContentVO originalListContent = resultsIterator.next();
            boolean isInAllUnions = true;
            for(List<ContentVO> contentList : unionList)
            {
              if(contentList != null)
              {
                boolean isInUnions = false;
                for(ContentVO unionContent : contentList)
                {
                  if(unionContent.getName().equalsIgnoreCase(originalListContent.getName()))
                    isInUnions = true;
                }
               
                if(!isInUnions)
                  isInAllUnions = false;
              }
            }
           
            if(!isInAllUnions)
              resultsIterator.remove();
          }
        }
      }
     
      if(disallowedComponentNames != null && disallowedComponentNames.length > 0)
      {
            for(int i=0; i<disallowedComponentNames.length; i++)
            {
                String disallowedComponentName = disallowedComponentNames[i];
                for(ContentVO contentVO : results)
                {
                  if(contentVO.getName().equals(disallowedComponentName))
                  {
                    logger.info("Removing disallowed:" + contentVO.getName());
                    results.remove(contentVO);
                    break;
                  }
                }
            }
      }
      if(logger.isInfoEnabled())
        t.printElapsedTime("Collecting from groups took");
     
      List<ContentVO> authorizedComponents = new ArrayList<ContentVO>();
      for(ContentVO contentVO : results)
      {
        boolean hasAccess = AccessRightController.getController().getIsPrincipalAuthorized(db, principal, "Component.Select", "" + contentVO.getId(), false);
        if(hasAccess)
          authorizedComponents.add(contentVO);
      }
      if(logger.isInfoEnabled())
        t.printElapsedTime("Checking access rights for components took");
      return authorizedComponents;
    }
    else
    {
      List<ContentVO> results = ContentControllerProxy.getController().getACContentVOList(principal, arguments, "Component.Select", db);
View Full Code Here

    {
          public void run()
          {
            try
            {
              Timer t = new Timer();
              preCacheComponents(2000);
              t.printElapsedTime("Precached components took");
            }
            catch (Exception e)
            {
          logger.warn("Failed to precache components: " + e.getMessage(), e);
        }
View Full Code Here

          public void run()
          {
            try
            {
              Thread.sleep(1000);
              Timer t = new Timer();
              List<Integer> localComponentIdsList = new ArrayList<Integer>();
              localComponentIdsList.addAll(componentIdsToRecache);
              componentIdsToRecache.clear();
              for(Integer localComponentContentId : localComponentIdsList)
              {
                reIndexComponentContent(localComponentContentId);
              }
              long time = t.getElapsedTime();
              if(time > 100)
                logger.warn("ReIndexComponentsTask took a bit to long:" + time);
            }
            catch (Exception e)
            {
View Full Code Here

      return childrenVOList;
    }
   
    childrenVOList = new ArrayList<SiteNodeVO>();
   
       Timer t = new Timer();
       StringBuffer SQL = new StringBuffer();
      if(CmsPropertyHandler.getUseShortTableNames() != null && CmsPropertyHandler.getUseShortTableNames().equalsIgnoreCase("true"))
      {
         SQL.append("CALL SQL select sn.siNoId, sn.name, sn.publishDateTime, sn.expireDateTime, sn.isBranch, sn.isDeleted, sn.parentSiNoId, sn.metaInfoContentId, sn.repositoryId, sn.siNoTypeDefId, sn.creator, (select count(*) from cmSiNo sn2 where sn2.parentSiNoId = sn.siNoId) AS childCount, snv.siNoVerId, snv.sortOrder, snv.isHidden, snv.stateId, snv.isProtected, snv.versionModifier, snv.modifiedDateTime, 0 AS languageId, '' as attributes from cmSiNo sn, cmSiNoVer snv ");
         SQL.append("where ");
View Full Code Here

    return createSiteNodeMetaInfoContent(db, newSiteNode, metaAttributes, repositoryId, principal, pageTemplateContentId, newContentVersions, checkIfMetaInfoIsBroken, null, null);
  }

    public MediumContentImpl createSiteNodeMetaInfoContent(Database db, SiteNodeVO newSiteNode, Map<String,String> metaAttributes, Integer repositoryId, InfoGluePrincipal principal, Integer pageTemplateContentId, List<ContentVersion> newContentVersions, boolean checkIfMetaInfoIsBroken, ContentVO oldMetaInfoContentVO, String navigationTitleSuffix) throws SystemException, Bug, Exception, ConstraintException
    {
      Timer t = new Timer();
      MediumContentImpl content = null;
       
        String basePath = "Meta info folder";
        String path = "";
       
        //SiteNode parentSiteNode = newSiteNode.getParentSiteNode();
        Integer parentSiteNodeId = newSiteNode.getParentSiteNodeId();
        while(parentSiteNodeId != null)
        {
          SiteNodeVO parentSiteNode = getSmallSiteNodeVOWithId(parentSiteNodeId, db);
            path = "/" + parentSiteNode.getName() + path;
            parentSiteNodeId = parentSiteNode.getParentSiteNodeId();
            //parentSiteNode = parentSiteNode.getParentSiteNode();
        }
        path = basePath + path;
       
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("Getting path", t.getElapsedTime());
       
        LanguageVO masterLanguage       = LanguageController.getController().getMasterLanguage(repositoryId, db);
      
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getLatestSiteNodeVersionVO", t.getElapsedTime());
       
        Integer metaInfoContentTypeDefinitionId = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("Meta info", db).getId();
        Integer availableServiceBindingId = AvailableServiceBindingController.getController().getAvailableServiceBindingVOWithName("Meta information", db).getId();
       
        List serviceDefinitions = AvailableServiceBindingController.getController().getServiceDefinitionVOList(db, availableServiceBindingId);
        if(serviceDefinitions == null || serviceDefinitions.size() == 0)
        {
            ServiceDefinition serviceDefinition = ServiceDefinitionController.getController().getServiceDefinitionWithName("Core content service", db, false);
            String[] values = {serviceDefinition.getId().toString()};
            AvailableServiceBindingController.getController().update(availableServiceBindingId, values, db);
        }
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getAvailableServiceBindingVOWithName", t.getElapsedTime());

        ContentVO rootContent = ContentControllerProxy.getController().getRootContentVO(db, repositoryId, principal.getName(), true);
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getRootContentVO", t.getElapsedTime());

        if(rootContent != null)
        {
            ContentVO parentFolderContent = ContentController.getContentController().getContentVOWithPath(repositoryId, path, true, principal, db);
            RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getContentVOWithPath", t.getElapsedTime());
           
          ContentVO contentVO = new ContentVO();
          contentVO.setCreatorName(principal.getName());
          contentVO.setIsBranch(new Boolean(false));
          contentVO.setName(newSiteNode.getName() + " Metainfo");
          contentVO.setRepositoryId(repositoryId);

          content = ContentControllerProxy.getController().create(db, parentFolderContent.getId(), metaInfoContentTypeDefinitionId, repositoryId, contentVO);
          RequestAnalyser.getRequestAnalyser().registerComponentStatistics("content.create", t.getElapsedTime());
         
          newSiteNode.setMetaInfoContentId(contentVO.getId());
         
          LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(repositoryId, db);

          String componentStructure = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><components></components>";
          if(pageTemplateContentId != null)
          {
            ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(pageTemplateContentId, masterLanguageVO.getId(), db);
           
              componentStructure = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO, "ComponentStructure", false);
         
          Document document = XMLHelper.readDocumentFromByteArray(componentStructure.getBytes("UTF-8"));
          String componentXPath = "//component";
          NodeList componentNodes = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath);
          for(int i=0; i < componentNodes.getLength(); i++)
          {
            Element element = (Element)componentNodes.item(i);
            String componentId = element.getAttribute("id");
            String componentContentId = element.getAttribute("contentId");
           
            ComponentController.getController().checkAndAutoCreateContents(db, newSiteNode.getId(), masterLanguageVO.getId(), masterLanguageVO.getId(), null, new Integer(componentId), document, new Integer(componentContentId), principal);
            componentStructure = XMLHelper.serializeDom(document, new StringBuffer()).toString();
          }
              RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 1", t.getElapsedTime());
          }
         
          List<LanguageVO> languageVOList = RepositoryLanguageController.getController().getLanguageVOListForRepositoryId(repositoryId, db);
          for(LanguageVO languageVO : languageVOList)
          {
            //Create initial content version also... in languageVO
            String versionValue = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_Title"))
              versionValue += "<Title><![CDATA[" + newSiteNode.getName() + "]]></Title>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_NavigationTitle"))
                versionValue += "<NavigationTitle><![CDATA[" + newSiteNode.getName() + "]]></NavigationTitle>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_NiceURIName"))
                versionValue += "<NiceURIName><![CDATA[" + new VisualFormatter().replaceNiceURINonAsciiWithSpecifiedChars(newSiteNode.getName(), CmsPropertyHandler.getNiceURIDefaultReplacementCharacter()) + "]]></NiceURIName>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_Description"))
                versionValue += "<Description><![CDATA[" + newSiteNode.getName() + "]]></Description>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_MetaInfo"))
                versionValue += "<MetaInfo><![CDATA[" + newSiteNode.getName() + "]]></MetaInfo>";
           
            boolean saveVersion = false;
            boolean realValue = false;
            if(metaAttributes != null)
            {
              for(String metaAttributeName : metaAttributes.keySet())
              {
                if(metaAttributeName.startsWith(languageVO.getLanguageCode() + "_"))
                {
                  versionValue += "<" + metaAttributeName.replaceFirst(languageVO.getLanguageCode() + "_", "") + "><![CDATA[" + metaAttributes.get(metaAttributeName) + "]]></" + metaAttributeName.replaceFirst(languageVO.getLanguageCode() + "_", "") + ">";
                  saveVersion = true;
                  realValue = true;
                }
              }
            }
                       
            if(!realValue) //No other values
              versionValue = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes>";
           
            if(languageVO.getId().equals(masterLanguageVO.getId()))
            {
              versionValue += "<ComponentStructure><![CDATA[" + componentStructure + "]]></ComponentStructure>";
              saveVersion = true;
            }
           
            versionValue += "</attributes></article>";
           
            if(saveVersion)
            {
              ContentVersionVO contentVersionVO = new ContentVersionVO();
              contentVersionVO.setVersionComment("Autogenerated version");
              contentVersionVO.setVersionModifier(principal.getName());
              contentVersionVO.setVersionValue(versionValue);
              //ContentVersionController.getContentVersionController().create(contentVO.getId(), masterLanguage.getId(), contentVersionVO, null, db);
              MediumContentVersionImpl contentVersionImpl = ContentVersionController.getContentVersionController().createMedium(contentVO.getId(), languageVO.getId(), contentVersionVO, db);
              if(newContentVersions != null)
                newContentVersions.add(contentVersionImpl);
 
              RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 2", t.getElapsedTime());
            }
          }
         
         
          LanguageVO localMasterLanguageVO = getInitialLanguageVO(db, parentFolderContent.getId(), repositoryId);
          //Also created a version in the local master language for this part of the site if any
          /*
          if(localMasterLanguageVO.getId().intValue() != masterLanguage.getId().intValue())
          {
            String versionValueLocalMaster = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes><Title><![CDATA[" + newSiteNode.getName() + "]]></Title><NavigationTitle><![CDATA[" + newSiteNode.getName() + "]]></NavigationTitle><NiceURIName><![CDATA[" + new VisualFormatter().replaceNiceURINonAsciiWithSpecifiedChars(newSiteNode.getName(), CmsPropertyHandler.getNiceURIDefaultReplacementCharacter()) + "]]></NiceURIName><Description><![CDATA[" + newSiteNode.getName() + "]]></Description><MetaInfo><![CDATA[" + newSiteNode.getName() + "]]></MetaInfo><ComponentStructure><![CDATA[]]></ComponentStructure></attributes></article>";
              ContentVersionVO contentVersionVOLocalMaster = new ContentVersionVO();
            contentVersionVOLocalMaster.setVersionComment("Autogenerated version");
            contentVersionVOLocalMaster.setVersionModifier(principal.getName());
            contentVersionVOLocalMaster.setVersionValue(versionValueLocalMaster);
            //ContentVersionController.getContentVersionController().create(contentVO.getId(), localMasterLanguageVO.getId(), contentVersionVOLocalMaster, null, db);
            MediumContentVersionImpl contentVersionImplLocal = ContentVersionController.getContentVersionController().createMedium(contentVO.getId(), localMasterLanguageVO.getId(), contentVersionVOLocalMaster, db);
            if(newContentVersions != null)
              newContentVersions.add(contentVersionImplLocal);
            RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 3", t.getElapsedTime());
          }
          */

      // If there is an old meta info content this is a copy action and we should take appropriate actions
      if (oldMetaInfoContentVO != null)
      {
        List<ContentVersionVO> contentVersions = ContentVersionController.getContentVersionController().getContentVersionVOList(oldMetaInfoContentVO.getId(), db);
        if (logger.isDebugEnabled())
        {
          StringBuilder sb = new StringBuilder();
          sb.append("Copying ContentVersions to new Meta info. Old Content.id: " + oldMetaInfoContentVO.getContentId());
          sb.append("\n\tNumber of contentVersions: " + contentVersions.size());
          sb.append("\n\tSite master language.id: " + masterLanguage.getId());
          sb.append("\n\tParent folder master language: " + localMasterLanguageVO.getId());
          logger.debug(sb);
        }
        else
        {
          logger.info("Copying ContentVersions to new Meta info. Old Content.id: " + oldMetaInfoContentVO.getContentId());
        }
        for(ContentVersionVO cv : contentVersions)
        {
          logger.debug("cv " + cv.getLanguageId() + ":" + cv.getId());
          if(!cv.getLanguageId().equals(masterLanguage.getId()) && !cv.getLanguageId().equals(localMasterLanguageVO.getId()))
          {
            logger.info("Should create version for content <" + contentVO.getId() + "> with language.id " + cv.getLanguageId());
            String versionValueOtherVersion = cv.getVersionValue();
            ContentVersionVO contentVersionVOLocalMaster = new ContentVersionVO();
            contentVersionVOLocalMaster.setVersionComment("Autogenerated version");
            contentVersionVOLocalMaster.setVersionModifier(principal.getName());
            contentVersionVOLocalMaster.setVersionValue(versionValueOtherVersion);
            MediumContentVersionImpl contentVersionImplLocal = ContentVersionController.getContentVersionController().createMedium(contentVO.getId(), cv.getLanguageId(), contentVersionVOLocalMaster, db);
            if(newContentVersions != null)
              newContentVersions.add(contentVersionImplLocal);
            RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 4", t.getElapsedTime());
          }
        }

        logger.info("Transforming NavigationTitle for copied Meta info. Content.id " + contentVO.getId());
        List<ContentVersionVO> newContentsVersions = ContentVersionController.getContentVersionController().getContentVersionVOList(contentVO.getId(), db);
View Full Code Here

   * This method copies a siteNode after first making a couple of controls that the move is valid.
   */

    public void copySiteNode(SiteNodeVO siteNodeVO, Integer newParentSiteNodeId, InfoGluePrincipal principal, ProcessBean processBean) throws ConstraintException, SystemException
    {
      Timer t = new Timer();
     
      logger.info("siteNodeVO:" + siteNodeVO);
      logger.info("newParentSiteNodeId:" + newParentSiteNodeId);
      logger.info("principal:" + principal);
      Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
            //Validation that checks the entire object
            siteNodeVO.validate();
           
            if(newParentSiteNodeId == null)
            {
              logger.warn("You must specify the new parent-siteNode......");
              throw new ConstraintException("SiteNode.parentSiteNodeId", "3403");
            }
            /*
            if(siteNodeVO.getId().intValue() == newParentSiteNodeId.intValue())
            {
              logger.warn("You cannot have the siteNode as it's own parent......");
              throw new ConstraintException("SiteNode.parentSiteNodeId", "3401");
            }
            */

            SiteNodeVO siteNode = getSiteNodeVOWithId(siteNodeVO.getSiteNodeId(), db);
            SiteNodeVO oldParentSiteNode = getSiteNodeVOWithId(siteNodeVO.getParentSiteNodeId(), db); //siteNode.getParentSiteNode();
            SiteNodeVO newParentSiteNode = getSiteNodeVOWithId(newParentSiteNodeId, db);

            SiteNodeVO tempSiteNode = getSiteNodeVOWithId(newParentSiteNode.getParentSiteNodeId(), db); //siteNode.getParentSiteNode();
            //SiteNode tempSiteNode = newParentSiteNode.getParentSiteNode();
      while(tempSiteNode != null)
      {
        if(tempSiteNode.getId().intValue() == siteNode.getId().intValue())
        {
          logger.warn("You cannot move the node to a child under it......");
                throw new ConstraintException("SiteNode.parentSiteNodeId", "3402");
        }
        tempSiteNode = getSiteNodeVOWithId(tempSiteNode.getParentSiteNodeId(), db); //siteNode.getParentSiteNode();
        //tempSiteNode = tempSiteNode.getParentSiteNode();
     
     
      processBean.updateProcess("Checked for constraints");
     
      Map<Integer,Integer> siteNodeIdsMapping = new HashMap<Integer,Integer>();

      Map<Integer,Integer> contentIdsMapping = new HashMap<Integer,Integer>();
      Set<Integer> siteNodeIdsToCopy = new HashSet<Integer>();
      Set<Integer> contentIdsToCopy = new HashSet<Integer>();
      List<ContentVersion> newCreatedContentVersions = new ArrayList<ContentVersion>();

      String newNameSuffix = getNewNameSuffixForCopy(principal, db, newParentSiteNode);

      copySiteNodeRecursive(siteNode, newParentSiteNode, principal, siteNodeIdsMapping, contentIdsMapping, contentIdsToCopy, newCreatedContentVersions, newNameSuffix, db, processBean);
      //After this all sitenodes main should be copied but then we have to round up some related nodes later
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("copySiteNodeRecursive", t.getElapsedTime());
     
      processBean.updateProcess("Now we search for related contents to copy");
      //Now let's go through all contents
      for(ContentVersion version : newCreatedContentVersions)
          {
        getRelatedEntities(newParentSiteNode, principal, version.getVersionValue(), siteNodeVO.getRepositoryId(), newParentSiteNode.getRepositoryId(), siteNodeIdsMapping, contentIdsMapping, siteNodeIdsToCopy, contentIdsToCopy, newCreatedContentVersions, 0, 3, newNameSuffix, db, processBean);
            //getContentRelationsChain(siteNodesIdsMapping, contentIdsMapping, newParentSiteNode.getRepository().getId(), oldSiteNodeVO.getRepositoryId(), principal, versions, 0, 3, db);
          }
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getRelatedEntities", t.getElapsedTime());
         
      processBean.updateProcess("Copying " + contentIdsToCopy.size() + " contents");

      //After this all related sitenodes should have been created and all related contents accounted for
      copyContents(newParentSiteNode, principal, contentIdsToCopy, siteNodeVO.getRepositoryId(), newParentSiteNode.getRepositoryId(), contentIdsMapping, newCreatedContentVersions, db);
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("copyContents", t.getElapsedTime());

      processBean.updateProcess("Remapping relations");
            rewireBindingsAndRelations(siteNodeIdsMapping, contentIdsMapping, newCreatedContentVersions, db);
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("rewireBindingsAndRelations", t.getElapsedTime());
     
            //If any of the validations or setMethods reported an error, we throw them up now before create.
            ceb.throwIfNotEmpty();
           
            commitTransaction(db);
View Full Code Here

  private void copySiteNodeRecursive(SiteNodeVO siteNode, SiteNodeVO newParentSiteNode, InfoGluePrincipal principal, Map<Integer,Integer> siteNodesIdsMapping, Map<Integer,Integer> contentIdsMapping, Set<Integer> contentIdsToCopy, List<ContentVersion> newCreatedContentVersions, String newNameSuffix, Database db, ProcessBean processBean) throws Exception
    {
       processBean.updateLastDescription("Copied " + siteNodesIdsMapping.size() + "...");

    Timer t = new Timer();
    if(siteNodesIdsMapping.containsKey(siteNode.getId()))
    {
      logger.warn("Returning as this sitenode has allready been copied... no recusion please");
      return;
    }
   
    SiteNodeVO oldSiteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNode.getId(), db);
        ContentVO oldMetaInfoContentVO = ContentController.getContentController().getContentVOWithId(oldSiteNodeVO.getMetaInfoContentId(), db);

        LanguageVO masterLanguage = LanguageController.getController().getMasterLanguage(siteNode.getRepositoryId(), db);
        ContentVersionVO oldCVVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(oldMetaInfoContentVO.getId(), masterLanguage.getId(), db);
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getLatestActiveContentVersionVO", t.getElapsedTime());

    SiteNodeVO newSiteNodeVO = new SiteNodeVO();
    newSiteNodeVO.setName(oldSiteNodeVO.getName() + newNameSuffix);
    newSiteNodeVO.setIsBranch(oldSiteNodeVO.getIsBranch());
        newSiteNodeVO.setCreatorName(oldSiteNodeVO.getCreatorName());
        newSiteNodeVO.setExpireDateTime(oldSiteNodeVO.getExpireDateTime());
        newSiteNodeVO.setIsProtected(oldSiteNodeVO.getIsProtected());
        newSiteNodeVO.setPublishDateTime(oldSiteNodeVO.getPublishDateTime());
        newSiteNodeVO.setStateId(oldSiteNodeVO.getStateId());
   
        SiteNodeVO newSiteNode = SiteNodeControllerProxy.getSiteNodeControllerProxy().acCreate(principal, newParentSiteNode.getId(), siteNode.getSiteNodeTypeDefinitionId(), newParentSiteNode.getRepositoryId(), newSiteNodeVO, db).getValueObject();
       
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("acCreate", t.getElapsedTime());
       
        SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(db, oldSiteNodeVO.getId());
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getLatestActiveSiteNodeVersionVO", t.getElapsedTime());
    if(siteNodeVersionVO != null)
    {
      Integer oldSiteNodeVersionId = siteNodeVersionVO.getId();
     
      SiteNodeVersionVO newSiteNodeVersionVO = new SiteNodeVersionVO();
      newSiteNodeVersionVO.setContentType(siteNodeVersionVO.getContentType());
      newSiteNodeVersionVO.setPageCacheKey(siteNodeVersionVO.getPageCacheKey());
      newSiteNodeVersionVO.setPageCacheTimeout(siteNodeVersionVO.getPageCacheTimeout());
      newSiteNodeVersionVO.setDisableEditOnSight(siteNodeVersionVO.getDisableEditOnSight());
      newSiteNodeVersionVO.setDisableLanguages(siteNodeVersionVO.getDisableLanguages());
      newSiteNodeVersionVO.setDisablePageCache(siteNodeVersionVO.getDisablePageCache());
      newSiteNodeVersionVO.setDisableForceIdentityCheck(siteNodeVersionVO.getDisableForceIdentityCheck());
      newSiteNodeVersionVO.setForceProtocolChange(siteNodeVersionVO.getForceProtocolChange());
      newSiteNodeVersionVO.setIsProtected(siteNodeVersionVO.getIsProtected());
      newSiteNodeVersionVO.setVersionModifier(principal.getName());
      newSiteNodeVersionVO.setStateId(0);
      newSiteNodeVersionVO.setIsActive(true);
      newSiteNodeVersionVO.setModifiedDateTime(siteNodeVersionVO.getModifiedDateTime());
     
      SiteNodeVersionVO siteNodeVersion = SiteNodeVersionController.getController().createSmall(newSiteNode.getId(), principal, newSiteNodeVersionVO, db).getValueObject();
          RequestAnalyser.getRequestAnalyser().registerComponentStatistics("createSmall", t.getElapsedTime());
     
          Map args = new HashMap();
        args.put("globalKey", "infoglue");
        PropertySet ps = PropertySetManager.getInstance("jdbc", args);

        String disabledLanguagesString = ps.getString("siteNode_" + oldSiteNodeVO.getId() + "_disabledLanguages");
        String enabledLanguagesString = ps.getString("siteNode_" + oldSiteNodeVO.getId() + "_enabledLanguages");
        logger.info("disabledLanguagesString:" + disabledLanguagesString);
        logger.info("enabledLanguagesString:" + enabledLanguagesString);
       
        if(disabledLanguagesString != null && !disabledLanguagesString.equals(""))
          ps.setString("siteNode_" + newSiteNode.getId() + "_disabledLanguages", disabledLanguagesString);
        if(enabledLanguagesString != null && !enabledLanguagesString.equals(""))
          ps.setString("siteNode_" + newSiteNode.getId() + "_enabledLanguages", enabledLanguagesString);

        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ps", t.getElapsedTime());

        //Copy all access rights...
        SiteNodeStateController.getController().copyAccessRights("SiteNodeVersion", oldSiteNodeVersionId, siteNodeVersion.getId(), db);
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("copyAccessRights", t.getElapsedTime());
        /*
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.Read");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.Write");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.CreateSiteNode");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.DeleteSiteNode");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.MoveSiteNode");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.SubmitToPublish");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.ChangeAccessRights");
        copyAccessRights(db, oldSiteNodeVersionId.toString(), siteNodeVersion.getId().toString(), "SiteNodeVersion.Publish");
        */
        //t.printElapsedTime("copy access");
    }

    //ContentVersion newCV = null;
    List<ContentVersion> newContentVersions = new ArrayList<ContentVersion>();

    Content newMetaInfoContent = SiteNodeController.getController().createSiteNodeMetaInfoContent(db, newSiteNode, null, newParentSiteNode.getRepositoryId(), principal, null, newContentVersions, false, oldMetaInfoContentVO, newNameSuffix);
    RequestAnalyser.getRequestAnalyser().registerComponentStatistics("createSiteNodeMetaInfoContent", t.getElapsedTime());

        //ContentVersionVO newCV = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(newMetaInfoContent.getId(), masterLanguage.getId(), db);
        //t.printElapsedTime("newCV:" + newCV);
       
      logger.info("Adding content version " + newContentVersions.size());
View Full Code Here

    }
    else
    {
      StringBuffer SQL = new StringBuffer();
     
         Timer t = new Timer();

        if(CmsPropertyHandler.getUseShortTableNames() != null && CmsPropertyHandler.getUseShortTableNames().equalsIgnoreCase("true"))
        {
          SQL.append("CALL SQL select sn.siNoId, sn.name, sn.publishDateTime, sn.expireDateTime, sn.isBranch, sn.isDeleted, sn.parentSiNoId, sn.metaInfoContentId, sn.repositoryId, sn.siNoTypeDefId, sn.creator, (select count(*) from cmSiNo sn2 where sn2.parentSiNoId = sn.siNoId) AS childCount, snv.siNoVerId, snv.sortOrder, snv.isHidden, snv.stateId, snv.isProtected, snv.versionModifier, snv.modifiedDateTime, 0 AS languageId, '' as attributes from cmSiNo sn, cmSiNoVer snv ");
           SQL.append("where ");
           SQL.append("sn.siNoId = $1 ");
           SQL.append("AND snv.siNoId = sn.siNoId ");
           SQL.append("AND snv.siNoVerId = ( ");
           SQL.append("  select max(siNoVerId) from cmSiNoVer snv2 ");
           SQL.append("  WHERE ");
           SQL.append("  snv2.siNoId = snv.siNoId AND ");
           //SQL.append("  snv2.isActive = $2 AND snv2.stateId >= $3 ");
           SQL.append("  snv2.stateId >= $2 ");
           SQL.append("  ) ");
           SQL.append("order by sn.siNoId DESC AS org.infoglue.cms.entities.structure.impl.simple.SmallestSiteNodeImpl");
        }
        else
        {
           SQL.append("CALL SQL select sn.siteNodeId, sn.name, sn.publishDateTime, sn.expireDateTime, sn.isBranch, sn.isDeleted, sn.parentSiteNodeId, sn.metaInfoContentId, sn.repositoryId, sn.siteNodeTypeDefinitionId, sn.creator, (select count(*) from cmSiteNode sn2 where sn2.parentSiteNodeId = sn.siteNodeId) AS childCount, snv.siteNodeVersionId, snv.sortOrder, snv.isHidden, snv.stateId, snv.isProtected, snv.versionModifier, snv.modifiedDateTime, 0 AS languageId, '' as attributes from cmSiteNode sn, cmSiteNodeVersion snv ");
           SQL.append("where ");
           SQL.append("sn.siteNodeId = $1 ");
           SQL.append("AND snv.siteNodeId = sn.siteNodeId ");
           SQL.append("AND snv.siteNodeVersionId = ( ");
           SQL.append("  select max(siteNodeVersionId) from cmSiteNodeVersion snv2 ");
           SQL.append("  WHERE ");
           SQL.append("  snv2.siteNodeId = snv.siteNodeId AND ");
           //SQL.append("  snv2.isActive = $2 AND snv2.stateId >= $3 ");
           SQL.append("  snv2.stateId >= $2 ");
           SQL.append("  ) ");
           SQL.append("order by sn.siteNodeId DESC AS org.infoglue.cms.entities.structure.impl.simple.SmallestSiteNodeImpl");       
        }
       
        //System.out.println("SQL:" + SQL);
        //logger.info("SQL:" + SQL);
        //logger.info("parentSiteNodeId:" + parentSiteNodeId);
        //logger.info("showDeletedItems:" + showDeletedItems);
        OQLQuery oql = db.getOQLQuery(SQL.toString());
      oql.bind(siteNodeId);
      //oql.bind(true);
      oql.bind(new Integer(CmsPropertyHandler.getOperatingMode()));
 
      QueryResults results = oql.execute(Database.READONLY);
      //t.printElapsedTime("Executed query.....");
      if (results.hasMore())
      {
        SiteNode siteNode = (SiteNode)results.next();
        siteNodeVO = siteNode.getValueObject();     
 
        if(!skipCaching)
        {
          String siteNodeCacheKey = "" + siteNode.getValueObject().getId();
          CacheController.cacheObjectInAdvancedCache("siteNodeCache", siteNodeCacheKey, siteNode.getValueObject());
        }
      }
      else
        logger.warn("SiteNode not found: " + siteNodeId);
     
      results.close();
      oql.close();
     
      if(siteNodeVO == null)
      {
        logger.info("Falling back to old forgiving logic for siteNodeId: " + siteNodeId + ". It must be in trouble.");
        siteNodeVO = getSiteNodeVOWithIdIfFailed(siteNodeId, db);
      }
     
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getSmallestSiteNodeVOWithId", t.getElapsedTime());
    }
   
    if(siteNodeVO != null && siteNodeVO.getMetaInfoContentId() != null)
      metaInfoSiteNodeIdMap.put(siteNodeVO.getMetaInfoContentId(), siteNodeVO.getId());
   
View Full Code Here

TOP

Related Classes of org.infoglue.deliver.util.Timer

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.