Package org.infoglue.deliver.util

Examples of org.infoglue.deliver.util.Timer


    }
    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");
           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");
           SQL.append("  ) ");
           SQL.append("order by sn.siteNodeId DESC AS org.infoglue.cms.entities.structure.impl.simple.SmallestSiteNodeImpl");       
        }
        //System.out.println("SQL:" + SQL);
        //System.out.println("siteNodeId:" + siteNodeId);
        //logger.info("SQL:" + SQL);
        //logger.info("parentSiteNodeId:" + parentSiteNodeId);
        //logger.info("showDeletedItems:" + showDeletedItems);
        OQLQuery oql = db.getOQLQuery(SQL.toString());
      oql.bind(siteNodeId);
 
      QueryResults results = oql.execute(Database.READONLY);
      //t.printElapsedTime("Executed query.....");
      if (results.hasMore())
      {
        SmallestSiteNodeImpl siteNode = (SmallestSiteNodeImpl)results.next();
        //System.out.println("siteNode:" + siteNode.getSiteNodeVersionId() + ":" + siteNode.getValueObject().getSiteNodeVersionId() + ":" + siteNode.getValueObject().getVersionModifier() + ":" + siteNode.getValueObject().getModifiedDateTime());
        siteNodeVO = siteNode.getValueObject();     
 
        String siteNodeCacheKey = "" + siteNode.getValueObject().getId();
        CacheController.cacheObjectInAdvancedCache("siteNodeCacheWithLatestVersion", siteNodeCacheKey, siteNode.getValueObject(), new String[]{CacheController.getPooledString(3, siteNode.getValueObject().getId())}, true);
      }
     
      results.close();
      oql.close();
     
      if(siteNodeVO == null)
      {
        logger.error("Falling back to old forgiving logic for siteNodeId: " + siteNodeId + ". It must be in trouble.");
        siteNodeVO = getSiteNodeVOWithIdIfFailed(siteNodeId, db);
      }
     
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getSmallestSiteNodeVOWithId", t.getElapsedTime());
    }
   
    return siteNodeVO;
  }
View Full Code Here


    return siteNodeVO;
  }

  public Map<Integer,SiteNodeVO> getSiteNodeVOMap(Integer[] siteNodeIds, Database db) throws SystemException, Bug, Exception
  {
      Timer t = new Timer();
      Map<Integer,SiteNodeVO> siteNodeVOMap = new HashMap<Integer,SiteNodeVO>();
     
      //System.out.println("siteNodeIds to fetch:" + siteNodeIds);

      List<Integer> uncachedSiteNodeIds = new ArrayList<Integer>();
View Full Code Here

    }       
 
 
  public Map<Integer,SiteNodeVO> getSiteNodeVOMapWithNoStateCheck(List<Integer> siteNodeVersionIds, Database db) throws SystemException, Bug, Exception
  {
      Timer t = new Timer();
      Map<Integer,SiteNodeVO> siteNodeVOMap = new HashMap<Integer,SiteNodeVO>();
      if(siteNodeVersionIds == null || siteNodeVersionIds.size() == 0)
        return siteNodeVOMap;

      //System.out.println("siteNodeVersionIds to really fetch:" + siteNodeVersionIds);
View Full Code Here

    
  public List<SiteNodeVersionVO> getSiteNodeVersionVOList(Integer stateId, Integer limit, Database db) throws Exception
  {
    List<SiteNodeVersionVO> childrenVOList = new ArrayList<SiteNodeVersionVO>();
   
       Timer t = new Timer();

       StringBuffer SQL = new StringBuffer();
      if(CmsPropertyHandler.getUseShortTableNames() != null && CmsPropertyHandler.getUseShortTableNames().equalsIgnoreCase("true"))
      {
         SQL.append("CALL SQL select * from (select snv.siNoVerId, snv.stateId, snv.verNumber, snv.modifiedDateTime, snv.verComment, snv.isCheckedOut, snv.isActive, snv.isProtected, snv.disablePageCache, snv.disableEditOnSight, snv.disableLanguages, snv.contentType, snv.pageCacheKey, snv.pageCacheTimeout, snv.disableForceIDCheck, snv.forceProtocolChange, snv.siNoId, snv.versionModifier, snv.stateId, snv.isProtected from cmSiNo sn, cmSiNoVer snv ");
         SQL.append("where ");
         SQL.append("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 = $1 AND snv2.stateId >= $2 ");
         SQL.append("  ) ");
         SQL.append("order by sn.siNoId DESC) where ROWNUM <= $3 AS org.infoglue.cms.entities.structure.impl.simple.SmallSiteNodeVersionImpl");       
      }
      else
      {
         SQL.append("CALL SQL select snv.siteNodeVersionId, snv.stateId, snv.versionNumber, snv.modifiedDateTime, snv.versionComment, snv.isCheckedOut, snv.isActive, snv.isProtected, snv.disablePageCache, snv.disableEditOnSight, snv.disableLanguages, snv.contentType, snv.pageCacheKey, snv.pageCacheTimeout, snv.disableForceIDCheck, snv.forceProtocolChange, snv.siteNodeId, snv.versionModifier, snv.stateId, snv.isProtected from cmSiteNode sn, cmSiteNodeVersion snv ");
         SQL.append("where ");
         SQL.append("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 = $1 AND snv2.stateId >= $2 ");
         SQL.append("  ) ");
         SQL.append("order by sn.siteNodeId DESC LIMIT $3 AS org.infoglue.cms.entities.structure.impl.simple.SmallSiteNodeVersionImpl");       
      }

      //logger.info("SQL:" + SQL);
      //logger.info("parentSiteNodeId:" + parentSiteNodeId);
      //logger.info("showDeletedItems:" + showDeletedItems);
      OQLQuery oql = db.getOQLQuery(SQL.toString());
    oql.bind(true);
    oql.bind(stateId);
    oql.bind(limit);

    QueryResults results = oql.execute(Database.READONLY);
    t.printElapsedTime("Executed query.....");
    while (results.hasMore())
    {
      SiteNodeVersion siteNodeVersion = (SiteNodeVersion)results.next();
      childrenVOList.add(siteNodeVersion.getValueObject());
   
      String key = "" + siteNodeVersion.getValueObject().getSiteNodeId();
      String groupKey1 = CacheController.getPooledString(4, siteNodeVersion.getId());
      String groupKey2 = CacheController.getPooledString(3, siteNodeVersion.getValueObject().getSiteNodeId());

      CacheController.cacheObjectInAdvancedCache("latestSiteNodeVersionCache", key, siteNodeVersion.getValueObject(), new String[]{groupKey1.toString(), groupKey2.toString()}, true);
    }
   
    results.close();
    oql.close();

       t.printElapsedTime("getSiteNodeVersionVOList " + childrenVOList.size() + " took");
      
    return childrenVOList;
  }
View Full Code Here

  {
    Analyzer analyzer = getAnalyzer();
    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_34, analyzer);
    IndexWriter iw = new IndexWriter(directory, config);
   
    Timer t = new Timer();
    addDocuments(iw, UserControllerProxy.getController().getAllUsers());
    t.printElapsedTime("Getting and indexing all users took", 50);
   
    iw.optimize();
    iw.close();
    return idx;
  }
View Full Code Here

   * If the index is not created or older than set interval the index is created.
   */

  public List<InfoGluePrincipal> getFilteredUsers(Integer offset, Integer limit, String sortProperty, String direction, String searchString, boolean populateRolesAndGroups) throws Exception
  {
    Timer t = new Timer();
   
    if(logger.isInfoEnabled())
    {
      logger.info("offset: " + offset);
      logger.info("limit: " + limit);
      logger.info("sortProperty: " + sortProperty);
      logger.info("direction: " + direction);
      logger.info("searchString: " + searchString);     
      logger.info("populateRolesAndGroups: " + populateRolesAndGroups);     
    }

    validateIndex();
    t.printElapsedTime("Validate index took", 50);
   
    List<InfoGluePrincipal> users = new ArrayList<InfoGluePrincipal>();
   
    try
    {
      List<Document> docs;
     
      logger.info("sortProperty:" + sortProperty + ":" + direction);
      if(searchString == null || searchString.equals(""))
        docs = queryDocuments(offset, limit, sortProperty, direction);
      else
        docs = queryDocuments(offset, limit, sortProperty, direction, searchString);
     
      logger.info("docs:" + docs.size());
      for(Document doc : docs)
      {
        String userName = doc.get("userName");
        InfoGluePrincipal user = new InfoGluePrincipal(userName, doc.get("userName"), doc.get("firstName"), doc.get("lastName"), doc.get("email"), doc.get("source"), true, new Date(), new ArrayList(), new ArrayList(), new HashMap(), false, null);
        users.add(user);
      }
    }
    catch (Exception e)
    {
      logger.warn("Error getting filtered users:" + e.getMessage(), e);
    }
   
    logger.info("Users took:" + t.getElapsedTime());
    return users;   
  }
View Full Code Here

   */

  private void addDocuments(IndexWriter iw, List<InfoGluePrincipal> users) throws CorruptIndexException, IOException
  {
    logger.info("Indexing users:" + users.size());
    Timer t = new Timer();
   
    for (InfoGluePrincipal user : users)
    {
      Document doc = new Document();

      // Add user
      String contentToIndex = "" + user.getName().toLowerCase() + " " + user.getFirstName() + " " + user.getLastName() + " " + user.getEmail().toLowerCase() + " " + user.getSource();
     
      doc.add(new Field("contents", new StringReader(contentToIndex)));

      doc.add(new Field("userName", user.getName().toLowerCase(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
      doc.add(new Field("firstName", user.getFirstName(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
      doc.add(new Field("lastName", user.getLastName(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
      doc.add(new Field("email", user.getEmail().toLowerCase(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
      doc.add(new Field("source", user.getSource(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
      doc.add(new NumericField("lastModified", Field.Store.YES, true).setLongValue(user.getModifiedDateTime().getTime()));
     
      for(InfoGlueRole role : user.getRoles())
      {
        if(!role.getName().equals("anonymous"))
          logger.info("role:" + role.getName());
        doc.add(new Field("roles", new StringReader("" + role.getName())));
      }
     
      for(InfoGlueGroup group : user.getGroups())
      {
        if(!group.getName().equals("anonymous"))
          logger.info("group:" + group.getName());
        doc.add(new Field("groups", new StringReader("" + group.getName())));
      }
     
      iw.addDocument(doc);
    }
   
    if(logger.isInfoEnabled())
      t.printElapsedTime("Indexing users took");
  }
View Full Code Here

    thread.start();
  }
 
  private void importFile(File file, String onlyLatestVersions, String standardReplacement, String replacements, ProcessBean processBean) throws Exception
  {
    Timer t = new Timer();
    processBean.setStatus(ProcessBean.RUNNING);
   
    CompressionHelper ch = new CompressionHelper();
    String extractFolder = CmsPropertyHandler.getDigitalAssetUploadPath() + File.separator + "ImportArchive_" + System.currentTimeMillis();
    logger.info("Extracting " + file.getPath() + " to " + extractFolder);
    File importFolder = new File(extractFolder);
    importFolder.mkdir();
    ch.unzip(file, importFolder);
   
    processBean.updateProcess("Unzip of archive took " + (t.getElapsedTime() / 1000) + " seconds");
   
    try
    {
      String encoding = "UTF-8";
     
      Map contentIdMap = new HashMap();
      Map siteNodeIdMap = new HashMap();
      List allContentIds = new ArrayList();

      Map<String,String> replaceMap = new HashMap<String,String>();
      try
      {
        boolean isUTF8 = false;
        boolean hasUnicodeChars = false;
        if(replacements.indexOf((char)65533) > -1)
          isUTF8 = true;
       
        for(int i=0; i<replacements.length(); i++)
        {
          int c = (int)replacements.charAt(i);
          if(c > 255 && c < 65533)
            hasUnicodeChars = true;
        }

        if(!isUTF8 && !hasUnicodeChars)
        {
          String fromEncoding = CmsPropertyHandler.getUploadFromEncoding();
          if(fromEncoding == null)
            fromEncoding = "iso-8859-1";
         
          String toEncoding = CmsPropertyHandler.getUploadToEncoding();
          if(toEncoding == null)
            toEncoding = "utf-8";
         
          if(replacements.indexOf("�") == -1 &&
             replacements.indexOf("�") == -1 &&
             replacements.indexOf("�") == -1 &&
             replacements.indexOf("�") == -1 &&
             replacements.indexOf("�") == -1 &&
             replacements.indexOf("�") == -1)
          {
            replacements = new String(replacements.getBytes(fromEncoding), toEncoding);
          }
        }
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
     
      Properties properties = new Properties();
      try
      {
        properties.load(new ByteArrayInputStream(replacements.getBytes("ISO-8859-1")));
       
        Iterator propertySetIterator = properties.keySet().iterator();
        while(propertySetIterator.hasNext())
        {
          String key = (String)propertySetIterator.next();
          String value = properties.getProperty(key);
          replaceMap.put(key, value);
        }
      } 
      catch(Exception e)
      {
          logger.error("Error loading properties from string. Reason:" + e.getMessage());
        e.printStackTrace();
      }

      logger.info("replaceMap:" + replaceMap);
      importRepository(importFolder, encoding, onlyLatestVersions, false, contentIdMap, siteNodeIdMap, allContentIds, replaceMap, processBean);
     
      processBean.updateProcess("Main import completed in " + (t.getElapsedTime() / 1000) + " seconds");

      // All ODMG database access requires a transaction
      Database db = CastorDatabaseService.getDatabase();

      try
      {
        db.begin();
       
        Iterator allContentIdsIterator = allContentIds.iterator();
        while(allContentIdsIterator.hasNext())
        {
          Integer contentId = (Integer)allContentIdsIterator.next();
       
          Content content = ContentController.getContentController().getContentWithId(contentId, db);
          updateContentVersions(content, contentIdMap, siteNodeIdMap, onlyLatestVersions, replaceMap);
        }
        db.commit();
      }
      catch(Exception e)
      {
        try
        {
          db.rollback();
        }
        catch(Exception e2) { e2.printStackTrace(); }
                logger.error("An error occurred when updating content version for content: " + e.getMessage(), e);         
      }
      finally
      {
        db.close();         
      }
     
      processBean.updateProcess("Update of all imported content versions completed in " + (t.getElapsedTime() / 1000) + " seconds");

      Thread.sleep(3000);
      processBean.setStatus(ProcessBean.FINISHED);
    }
    catch ( Exception e)
View Full Code Here

    return allContentVersionMap;
  }
 
  public void copyRepository(File archiveFolder, File mainExportFile/*, File contentVersionsFile, File contentsFile, File siteNodeVersionsFile, File siteNodesFile*/, String onlyLatestVersions, boolean isCopyAction, Map contentIdMap, Map siteNodeIdMap, List allContentIds, Map replaceMap, String encoding, ProcessBean processBean) throws Exception
  {
    Timer t = new Timer();
   
    Map categoryIdMap = new HashMap();
    Map contentTypeIdMap = new HashMap();
    Map repositoryIdMap = new HashMap();
    Map siteNodeVersionIdMap = new HashMap();
    List allContents = new ArrayList();
    List allSiteNodes = new ArrayList();
    List<SmallDigitalAssetImpl> allSmallAssets = new ArrayList<SmallDigitalAssetImpl>();
    Map<Integer,List<Integer>> assetVersionsMap = new HashMap<Integer,List<Integer>>();
    Map<String, AvailableServiceBinding> readAvailableServiceBindings = new HashMap<String, AvailableServiceBinding>();
    Map<Integer,Language> languages = new HashMap<Integer,Language>();
    Map<Integer,SiteNodeTypeDefinition> siteNodeTypeDefinitions = new HashMap<Integer,SiteNodeTypeDefinition>();
   
    InfoGlueExportImpl master = getInfoGlueExportImpl(mainExportFile, encoding);
    logger.info("master:" + master);
   
    for(Language lang : master.getLanguages())
    {
      languages.put(lang.getId(), lang);
    }
   
    for(SiteNodeTypeDefinition siteNodeTypeDefinition : master.getSiteNodeTypeDefinitions())
    {
      siteNodeTypeDefinitions.put(siteNodeTypeDefinition.getId(), siteNodeTypeDefinition);
    }
   
    importFoundation(master, encoding, isCopyAction, replaceMap, categoryIdMap, repositoryIdMap);

    processBean.updateProcess("Foundation imported in " + (t.getElapsedTime() / 1000) + " seconds");
   
    createContent(archiveFolder, /*contentsFile, contentVersionsFile, */encoding, repositoryIdMap, master.getRepositories(), contentIdMap, contentTypeIdMap, allContents, languages, master.getContentTypeDefinitions(), categoryIdMap, allSmallAssets, assetVersionsMap, onlyLatestVersions, isCopyAction, replaceMap);

    processBean.updateProcess("Content created in " + (t.getElapsedTime() / 1000) + " seconds");
   
    CacheController.clearCastorCaches();
    CacheController.clearCache("contentVersionCache");
    CacheController.clearCache("contentCache");
   
    processStructure(archiveFolder, /*siteNodeVersionsFile, siteNodesFile, */encoding, onlyLatestVersions, contentIdMap, siteNodeIdMap, replaceMap, repositoryIdMap, siteNodeVersionIdMap, allSiteNodes, readAvailableServiceBindings, master.getRepositories(), siteNodeTypeDefinitions);

    processBean.updateProcess("Structure imported in " + (t.getElapsedTime() / 1000) + " seconds");
   
    CacheController.clearCastorCaches();
    CacheController.clearCache("siteNodeVersionCache");
    CacheController.clearCache("siteNodeCache");
   
    Database dbStructure = CastorDatabaseService.getDatabase();
    try
    {
      dbStructure.begin();
     
      for(SmallDigitalAssetImpl asset : allSmallAssets)
      {
        List<ContentVersion> assetRelatedContentVersions = new ArrayList<ContentVersion>();
        List<Integer> versionIdsUsingAsset = assetVersionsMap.get(asset.getId());
        for(Integer cvId : versionIdsUsingAsset)
        {
          ContentVersion cv = ContentVersionController.getContentVersionController().getContentVersionWithId(cvId, dbStructure);
          assetRelatedContentVersions.add(cv);
        }
 
        File assetFile = new File(archiveFolder.getPath() + File.separator + asset.getId() + ".file");
        //logger.info("assetFile:" + assetFile.exists());
        if(assetFile.exists())
        {
          InputStream is = new FileInputStream(assetFile);
          create(asset.getValueObject(), is, assetRelatedContentVersions, dbStructure);
        }
        else
        {
          logger.info("Missing file...:" + assetFile.getPath());
        }
      }

      dbStructure.commit();
    }
    catch (Exception e)
    {
      dbStructure.rollback();
    }
    finally
    {
      dbStructure.close();
    }

    processBean.updateProcess("Assets imported in " + (t.getElapsedTime() / 1000) + " seconds");

    CacheController.clearCastorCaches();
    CacheController.clearCache("contentVersionCache");
    CacheController.clearCache("contentCache");
   
    //List allContentIds = new ArrayList();
    Iterator allContentsIterator = allContents.iterator();
    while(allContentsIterator.hasNext())
    {
      Content content = (Content)allContentsIterator.next();
      allContentIds.add(content.getContentId());
    }

    //TEST
    Map args = new HashMap();
      args.put("globalKey", "infoglue");
      PropertySet ps = PropertySetManager.getInstance("jdbc", args);

    Map<String,String> repositoryProperties = master.getRepositoryProperties();
    Iterator<String> repositoryPropertiesIterator = repositoryProperties.keySet().iterator();
    while(repositoryPropertiesIterator.hasNext())
    {
      String key = repositoryPropertiesIterator.next();
      String value = repositoryProperties.get(key);
      String[] splittedString = key.split("_");
      if(splittedString.length == 3)
      {
        String oldRepId = splittedString[1];
        key = key.replaceAll(oldRepId, "" + repositoryIdMap.get(oldRepId));
       
        if(value != null && !value.equals("null"))
        {
          try
          {
            if(key.indexOf("_WYSIWYGConfig") > -1 || key.indexOf("_StylesXML") > -1 || key.indexOf("_extraProperties") > -1)
              ps.setData(key, value.getBytes("utf-8"));
            else
              ps.setString(key, value);
          }
          catch (Exception e)
          {
            logger.error("Error saving property " + key + ":" + e.getMessage());
          }
        }
      }
    }

    Map<String,String> contentProperties = master.getContentProperties();
    Iterator<String> contentPropertiesIterator = contentProperties.keySet().iterator();
    while(contentPropertiesIterator.hasNext())
    {
      String key = contentPropertiesIterator.next();
      String value = contentProperties.get(key);
      String[] splittedString = key.split("_");
      if(splittedString.length == 3)
      {
        String oldContentId = splittedString[1];
        key = key.replaceAll(oldContentId, (String)contentIdMap.get(oldContentId));
        try
        {
          if(value != null && !value.equals("null"))
            ps.setString(key, value);
        }
        catch (Exception e)
        {
          logger.error("Error saving property " + key + ":" + e.getMessage());
        }
      }
    }

    Map<String,String> siteNodeProperties = master.getSiteNodeProperties();
    Iterator<String> siteNodePropertiesIterator = siteNodeProperties.keySet().iterator();
    while(siteNodePropertiesIterator.hasNext())
    {
      String key = siteNodePropertiesIterator.next();
      String value = siteNodeProperties.get(key);
      String[] splittedString = key.split("_");
      if(splittedString.length == 3)
      {
        String oldSiteNodeId = splittedString[1];
        key = key.replaceAll(oldSiteNodeId, (String)siteNodeIdMap.get(oldSiteNodeId));
        try
        {
          if(value != null && !value.equals("null"))
            ps.setString(key, value);
        }
        catch (Exception e)
        {
          logger.error("Error saving property " + key + ":" + e.getMessage());
        }
      }
    }

    processBean.updateProcess("Properties imported in " + (t.getElapsedTime() / 1000) + " seconds");

    Database dbAccessRight = CastorDatabaseService.getDatabase();
    try
    {
      dbAccessRight.begin();
      Collection<AccessRight> accessRights = master.getAccessRights();
      Iterator<AccessRight> accessRightsIterator = accessRights.iterator();
      while(accessRightsIterator.hasNext())
      {
        AccessRight accessRight = accessRightsIterator.next();
 
        InterceptionPoint interceptionPoint = InterceptionPointController.getController().getInterceptionPointWithName(accessRight.getInterceptionPointName(), dbAccessRight);
        accessRight.setInterceptionPoint(interceptionPoint);
        if(interceptionPoint.getName().indexOf("Content") > -1)
          accessRight.setParameters((String)contentIdMap.get(accessRight.getParameters()));
        else if(interceptionPoint.getName().indexOf("SiteNodeVersion") > -1)
          accessRight.setParameters((String)siteNodeVersionIdMap.get(accessRight.getParameters()));
        else if(interceptionPoint.getName().indexOf("SiteNode") > -1)
          accessRight.setParameters((String)siteNodeIdMap.get(accessRight.getParameters()));
        else if(interceptionPoint.getName().indexOf("Repository") > -1)
          accessRight.setParameters(""+repositoryIdMap.get(accessRight.getParameters()));
 
        dbAccessRight.create(accessRight);
 
        Iterator accessRightRoleIterator = accessRight.getRoles().iterator();
        while(accessRightRoleIterator.hasNext())
        {
          AccessRightRole accessRightRole = (AccessRightRole)accessRightRoleIterator.next();
          accessRightRole.setAccessRight(accessRight);
          dbAccessRight.create(accessRightRole);
        }
 
        Iterator accessRightGroupIterator = accessRight.getGroups().iterator();
        while(accessRightGroupIterator.hasNext())
        {
          AccessRightGroup accessRightGroup = (AccessRightGroup)accessRightGroupIterator.next();
          accessRightGroup.setAccessRight(accessRight);
          dbAccessRight.create(accessRightGroup);
        }
      }
 
      dbAccessRight.commit();
    }
    catch (Exception e)
    {
      dbAccessRight.rollback();
    }
    finally
    {
      dbAccessRight.close();
    }
   
    processBean.updateProcess("Access rights imported in " + (t.getElapsedTime() / 1000) + " seconds");
  }
View Full Code Here

   * This is the main execution point for any webwork action.
   * Lately we added statistics on each action for debugging and optimization purposes.
   */
    public String execute() throws Exception
    {
      Timer t = new Timer();
     
      String result = "";
     
      ThreadMonitor tm = new ThreadMonitor(10000L, request, "Action took to long", false);
        /*
      ThreadMonitor tm = null;
      if(getRequest().getParameter("trackThread") != null && getRequest().getParameter("trackThread").equals("true"))
        tm = new ThreadMonitor(10000L, request, "Action took to long", false);
    */
     
        try
        {
          //This registers what the system needs to know about the port etc to be able to call update cache actions etc.
          CmsPropertyHandler.registerDefaultSchemeAndPort(getRequest());
         
          protectFromCSSAttacks(this.getClass().getName(), this.commandName);
         
          result = isCommand() ? invokeCommand() : doExecute();
          setStandardResponseHeaders();

          long elapsedTime = t.getElapsedTime();
          long memoryDiff = t.getMemoryDifferenceAsMegaBytes();
          if(elapsedTime > 5000 || memoryDiff > 100)
          {
            logger.warn("The " + CmsPropertyHandler.getApplicationName() + " request: " + this.getUnencodedCurrentURIWithParameters() + " took " + elapsedTime + " ms to render and seems to have allocated " + memoryDiff + " MB of memory)");
          }
        }
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.