Package org.infoglue.deliver.util

Examples of org.infoglue.deliver.util.Timer


      * This is a complement to the normal webwork execution which allows for a command-based execution of actions.
      */
   
    private String invokeCommand() throws Exception
    {
      Timer t = new Timer();
     
        //ThreadMonitor tm = null;
      //if(getRequest().getParameter("trackThread") != null && getRequest().getParameter("trackThread").equals("true"))
      //  tm = new ThreadMonitor(10L, request, "Command took to long", false);
      ThreadMonitor tm = new ThreadMonitor(10000L, request, "Command took to long", false);
View Full Code Here


    public Collection getKeys(String prefix, int type) throws PropertyException
    {
      if(wasDatabaseFaulty)
        return new ArrayList();
     
      Timer t = new Timer();

      //System.out.println("isRecacheCall:" + isRecacheCall); //valueMapType5 == null && !allKeysCachedType5
      Map currentType5Map = type5Map;
      Map currentValue5Map = valueMapType5;
      Map currentType10Map = type10Map;
      Map currentValue10Map = valueMapType10;
     
        if (prefix == null)
        {
            prefix = "";
        }
       
        Connection conn = null;

        try
        {
          //System.out.println("Getting keys with prefix:" + prefix + " and type: " + type + " and globalKey:" + globalKey);
            logger.info("Getting keys with prefix:" + prefix + " and type: " + type + " and globalKey:" + globalKey);
            conn = getConnection();
            //t.printElapsedTime("Connection took..");
          if(conn == null)
          {
            System.out.println("braking as connection was not yet ready");
            throw new PropertyException("Problem getting connection");
          }

            PreparedStatement ps = null;
            //String sql = "SELECT " + colItemKey + "," + colItemType + ", " + colString + ", " + colDate + ", " + colData + ", " + colFloat + ", " + colNumber + " FROM " + tableName + " WHERE " + colItemKey + " LIKE ? AND " + colGlobalKey + " = ?";

          String sql = "SELECT " + colItemKey + "," + colItemType + ", " + colString + ", " + colDate + ", " + colData + ", " + colFloat + ", " + colNumber + " FROM " + tableName;
            if(type != 10)
            {
              sql =  "SELECT " + colItemKey + "," + colItemType + ", " + colString + ", " + colDate + ", '' AS " + colData + ", " + colFloat + ", " + colNumber + " FROM " + tableName;
            }
           
            sql += " WHERE ";
            sql += "((" + colItemKey + " NOT LIKE 'content_%' AND ";
          sql += "" + colItemKey + " NOT LIKE 'principal_%' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_WYSIWYGConfig' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_StylesXML' AND  ";
        sql += "" + colItemKey + " NOT LIKE 'repository_%_defaultFolderContentTypeName' AND  ";
        sql += "" + colItemKey + " NOT LIKE 'repository_%_defaultTemplateRepository' AND  ";
        sql += "" + colItemKey + " NOT LIKE 'siteNode_%_enabledLanguages' AND  ";
        sql += "" + colItemKey + " NOT LIKE 'siteNode_%_disabledLanguages') OR  ";
        sql += "(" + colItemKey + " LIKE 'siteNode_%_enabledLanguages' AND string_val <> '') OR ";
        sql += "(" + colItemKey + " LIKE 'siteNode_%_disabledLanguages' AND string_val <> ''))  AND  ";
        sql += "" + colGlobalKey + " = ? ";
           
        //System.out.println("sql:" + sql);
            if(logger.isInfoEnabled())
            {
              logger.info("app:" + CmsPropertyHandler.getApplicationName());
              logger.info("operating mode:" + CmsPropertyHandler.getOperatingMode());
            }
            /*
            if(CmsPropertyHandler.getApplicationName().equalsIgnoreCase("deliver") && CmsPropertyHandler.getOperatingMode().equalsIgnoreCase("3"))
            {
              sql = "SELECT " + colItemKey + "," + colItemType + ", " + colString + ", " + colDate + ", " + colData + ", " + colFloat + ", " + colNumber + " FROM " + tableName;
              sql += " WHERE ";
              sql += "" + colItemKey + " LIKE ? AND ";
              sql += "" + colItemKey + " NOT LIKE 'principal_%_languageCode' AND ";
            sql += "" + colItemKey + " NOT LIKE 'principal_%_defaultToolId' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'content_%_allowedContentTypeNames' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'content_%_defaultContentTypeName' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'content_%_initialLanguageId' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_defaultFolderContentTypeName' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_defaultTemplateRepository' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_parentRepository' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_WYSIWYGConfig' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_StylesXML' AND  ";
          sql += "" + colItemKey + " NOT LIKE 'repository_%_extraProperties' AND  ";
          sql += "" + colGlobalKey + " = ? ";
            }
            */
           
            if(logger.isInfoEnabled())
              logger.info("sql:" + sql);
            //System.out.println("sql:" + sql);
           
            if (type == 0)
            {
              //System.out.println("conn:" + conn);
              //System.out.println("sql:" + sql);
                ps = conn.prepareStatement(sql);
                //ps.setString(1, prefix + "%");
                //ps.setString(2, globalKey);
                ps.setString(1, globalKey);
              //System.out.println("arg1:" + prefix + "%");
                //System.out.println("arg2:" + globalKey);
            }
            else
            {
                sql = sql + " AND " + colItemType + " = ?";
                ps = conn.prepareStatement(sql);
                ps.setString(1, prefix + "%");
                ps.setString(2, globalKey);
                ps.setInt(3, type);
                //System.out.println("arg1:" + prefix + "%");
                //System.out.println("arg2:" + globalKey);
                //System.out.println("arg3:" + type);
            }

            ArrayList list = new ArrayList();
            ResultSet rs = ps.executeQuery();
            logger.info("All rows " + sql);

            int rows = 0;
            while (rs.next())
            {
              rows++;
              String key = rs.getString(colItemKey);
                int typeId = rs.getInt(colItemType);
             
              //System.out.println("key[" + typeId + "]:" + key);
               
              if(logger.isInfoEnabled())
                logger.info("key[" + typeId + "]:" + key);
               
                list.add(key);
               
                if(type == 5 && type5Map == null)
                  type5Map = new HashMap();
                if(type == 5 && typeMap5Fallback == null)
                  typeMap5Fallback = new HashMap();

                if(type == 10 && type10Map == null)
                  type10Map = new HashMap();
                if(type == 10 && typeMap10Fallback == null)
                  typeMap10Fallback = new HashMap();

              currentType5Map = type5Map;
              currentType10Map = type10Map;
              if(isRecacheCall)
              {
                currentType5Map = typeMap5Fallback;
                currentType10Map = typeMap10Fallback;
              }

              if(type == 5)
              {
                synchronized (currentType5Map)
                {
                  currentType5Map.put(key, new Integer(typeId))
                  }
              }
              if(type == 10)
              {
                synchronized (currentType10Map)
                {
                  currentType10Map.put(key, new Integer(typeId))
                  }
              }
             
              Object o = null;
             
                switch (typeId) {
                case PropertySet.BOOLEAN:

                    int boolVal = rs.getInt(colNumber);
                    o = new Boolean(boolVal == 1);

                    break;

                case PropertySet.DATA:
                {
                  //Ugly fix for old type of column in oracle which we used to run LONG RAW. We converted to blob and the code is different
                  String columnTypeName = rs.getMetaData().getColumnTypeName(5);
                  logger.info("columnTypeName: " + columnTypeName);
                  if(this.driverClassName.indexOf("oracle") > -1 && columnTypeName != null && columnTypeName.indexOf("RAW") == -1)
                  {
                    //System.out.println("Getting as blob");
                      Blob blob = rs.getBlob(colData);
                    //System.out.println("blob:" + blob);
                    if(blob != null)
                    {
                      try
                      {
                        InputStream in = blob.getBinaryStream();
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        byte[] buffer = new byte[(int)blob.length()];
                        InputStream is = in;
                          while (is.read(buffer) > 0) {
                            baos.write(buffer);
                          }
                          baos.flush();
                          String s = baos.toString();
                          //System.out.println("S: " + s + "...");
                          o = s.getBytes();
                      }
                      catch (Exception e)
                      {
                        e.printStackTrace();
              }
                    }
                    else
                    {
                      o = null;
                    }
                  }
                  else
                  {
                    //System.out.println("Getting as raw bytes:" + key);
                    o = rs.getBytes(colData);
                  }
                 
                    break;
                }
                case PropertySet.DATE:
                    o = rs.getTimestamp(colDate);

                    break;

                case PropertySet.DOUBLE:
                    o = new Double(rs.getDouble(colFloat));

                    break;

                case PropertySet.INT:
                    o = new Integer(rs.getInt(colNumber));

                    break;

                case PropertySet.LONG:
                    o = new Long(rs.getLong(colNumber));

                    break;

                case PropertySet.STRING:
                    o = rs.getString(colString);

                    break;

                default:
                    logger.info("JDBCPropertySet doesn't support this type yet:" + key + ":" + typeId);
                }

                if(type != 10 && valueMapType5 == null)
                  valueMapType5 = new HashMap();
                if(type != 10 && valueMap5Fallback == null)
                  valueMap5Fallback = new HashMap();

                if(type == 10 && valueMapType10 == null)
                  valueMapType10 = new HashMap();
                if(type == 10 && valueMap10Fallback == null)
                  valueMap10Fallback = new HashMap();

              currentValue5Map = valueMapType5;
              currentValue10Map = valueMapType10;
              if(isRecacheCall)
              {
                currentValue5Map = valueMap5Fallback;
                currentValue10Map = valueMap10Fallback;               
              }
             
              //System.out.println("Caching:" + key + "=" + o + "(type " + type + ")");
              if(type != 10)
              {
                synchronized (currentValue5Map)
                {
                  currentValue5Map.put(key, o);                         
                }
              }
              if(type == 10)
              {
                synchronized (currentValue10Map)
                {
                  currentValue10Map.put(key, o);                         
                }
              }
            }
            logger.warn("All rows in InfoGlueJDBCPropertySet [" + rows + "] took: " + t.getElapsedTime());

            allKeysCachedType5 = true;
            if(type == 10)
              allKeysCachedType10 = true;
            if(isRecacheCall)
View Full Code Here

          {
              closeConnection(conn);
          }
    }
    */
      Timer t = new Timer();
     
      if(logger.isInfoEnabled())
        logger.info("Getting value for key:" + key + ":" + type);

        String sql = "SELECT " + colItemType + ", " + colString + ", " + colDate + ", " + colData + ", " + colFloat + ", " + colNumber + " FROM " + tableName + " WHERE " + colItemKey + " = ? AND " + colGlobalKey + " = ?";
View Full Code Here

   */
 
  public List<CategoryVO> getAvailableCategories(Integer categoryId)
  {
    List<CategoryVO> availableCategories = Collections.EMPTY_LIST;
    Timer t = new Timer();
    try
   
        String protectCategories = CmsPropertyHandler.getProtectCategories();
        if(protectCategories != null && protectCategories.equalsIgnoreCase("true"))
        {
          availableCategories = getCategoryController().getAuthorizedActiveChildren(categoryId, this.getInfoGluePrincipal());
        t.printElapsedTime("getAuthorizedActiveChildren");
}
      else
      {
        availableCategories = getCategoryController().getActiveChildrenCategoryVOList(categoryId);
        t.printElapsedTime("findAllActiveChildren");
      }
    }
    catch(Exception e)
    {
      logger.warn("We could not fetch the list of categories: " + e.getMessage(), e);
View Full Code Here

   * This method returns the latest active content version.
   */
   
  public ContentVersionVO getLatestActiveContentVersionVO(Integer contentId, Integer languageId, Integer stateId, Database db) throws SystemException, Bug, Exception
  {
    Timer t = new Timer();
   
      ContentVersionVO contentVersionVO = null;
     
      String versionKey = "" + contentId + "_" + languageId + "_" + stateId + "_contentVersionVO";

    Object object = CacheController.getCachedObjectFromAdvancedCache("contentVersionCache", versionKey);
    if(object instanceof NullObject)
    {
      logger.info("There was an cached contentVersionVO but it was null:" + object);
    }
    else if(object != null)
    {
      if(object instanceof SmallestContentVersionVO)
      {
        logger.warn("Object was instanceof SmallestContentVersionVO for key:" + versionKey);
        contentVersionVO = (ContentVersionVO)getVOWithId(SmallContentVersionImpl.class, ((SmallestContentVersionVO)object).getId(), db);
        CacheController.cacheObjectInAdvancedCache("contentVersionCache", versionKey, contentVersionVO, new String[]{CacheController.getPooledString(2, contentVersionVO.getId()), CacheController.getPooledString(1, contentVersionVO.getContentId())}, true);
      }
      else
      {
        contentVersionVO = (ContentVersionVO)object;
      }
    }
    else
    {
      OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.content.impl.simple.SmallContentVersionImpl cv WHERE cv.contentId = $1 AND cv.languageId = $2 AND cv.stateId >= $3 AND cv.isActive = $4 ORDER BY cv.contentVersionId desc");
        oql.bind(contentId);
        oql.bind(languageId);
        oql.bind(stateId);
        oql.bind(true);
 
        QueryResults results = oql.execute(Database.READONLY);
       
      if (results.hasMore())
          {
        ContentVersion contentVersion = (ContentVersion)results.next();
            contentVersionVO = contentVersion.getValueObject();
 
        CacheController.cacheObjectInAdvancedCache("contentVersionCache", versionKey, contentVersionVO, new String[]{CacheController.getPooledString(2, contentVersionVO.getId()), CacheController.getPooledString(1, contentVersionVO.getContentId())}, true);
          }
      /*
           ContentVersion contentVersion = getLatestActiveContentVersionReadOnly(contentId, languageId, stateId, db);
             
          if(contentVersion != null)
              contentVersionVO = contentVersion.getValueObject();
        */
    }
   
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getLatestActiveContentVersionVO new", t.getElapsedTime());

    return contentVersionVO;
    }
View Full Code Here

   * This method returns the latest active content version in a certain version.
   */
   
  public ContentVersion getLatestActiveContentVersionReadOnly(Integer contentId, Integer languageId, Integer stateId, Database db) throws SystemException, Bug
  {
    Timer t = new Timer();
   
    ContentVersion contentVersion = null;
     
    Content content = ContentController.getContentController().getReadOnlyMediumContentWithId(contentId, db);
    Collection contentVersions = content.getContentVersions();
    if(logger.isInfoEnabled())
    {
      logger.info("contentId:" + contentId);
        logger.info("languageId:" + languageId);
        logger.info("content:" + content.getName());
      logger.info("contentVersions:" + contentVersions.size());
    }
       
    Iterator i = contentVersions.iterator();
        while(i.hasNext())
    {
      ContentVersion currentContentVersion = (ContentVersion)i.next();
      if(logger.isInfoEnabled())
        logger.info("found one candidate:" + currentContentVersion.getValueObject());
     
      if(contentVersion == null || (currentContentVersion.getId().intValue() > contentVersion.getId().intValue()))
      {
        if(logger.isInfoEnabled())
        {
          logger.info("currentContentVersion:" + currentContentVersion.getIsActive());
          logger.info("currentContentVersion:" + currentContentVersion.getLanguage().getId());
        }
        if(currentContentVersion.getIsActive().booleanValue() &&  currentContentVersion.getLanguage().getId().intValue() == languageId.intValue() && currentContentVersion.getStateId() >= stateId)
          contentVersion = currentContentVersion;
      }
    }
       
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getLatestActiveContentVersionReadOnly", t.getElapsedTime());
       
    return contentVersion;
  }
View Full Code Here

    }
    */
   
    public MediumContentVersionImpl create(Integer contentId, Integer languageId, ContentVersionVO contentVersionVO, Integer oldContentVersionId, boolean allowBrokenAssets, boolean duplicateAssets, Integer excludedAssetId, Database db) throws ConstraintException, SystemException, Exception
    {
      Timer t = new Timer();   
      MediumContentVersionImpl contentVersion = new MediumContentVersionImpl();
    contentVersion.setValueObject(contentVersionVO);
    contentVersion.getValueObject().setLanguageId(languageId);
    contentVersion.getValueObject().setContentId(contentId);
    RequestAnalyser.getRequestAnalyser().registerComponentStatistics("create 2", t.getElapsedTime());
   
    db.create(contentVersion);
    RequestAnalyser.getRequestAnalyser().registerComponentStatistics("create 3.0", t.getElapsedTime());

        //content.getContentVersions().add(contentVersion);

        if(oldContentVersionId != null && oldContentVersionId.intValue() != -1)
        copyDigitalAssets(getMediumContentVersionWithId(oldContentVersionId, db), contentVersion, allowBrokenAssets, duplicateAssets, excludedAssetId, db);
View Full Code Here

    }    
   
    public MediumContentVersionImpl createMedium(MediumContentVersionImpl oldContentVersion, Integer contentId, Integer languageId, ContentVersionVO contentVersionVO, Integer oldContentVersionId, boolean hasAssets, boolean allowBrokenAssets, boolean duplicateAssets, Integer excludedAssetId, Database db) throws ConstraintException, SystemException, Exception
    {
      //Beh�vs verkligen content h�r? M�t tiderna ocks�
      Timer t = new Timer();   
      MediumContentVersionImpl contentVersion = new MediumContentVersionImpl();
    contentVersion.setValueObject(contentVersionVO);
    contentVersion.getValueObject().setLanguageId(languageId);
    contentVersion.getValueObject().setContentId(contentId);
    RequestAnalyser.getRequestAnalyser().registerComponentStatistics("create 2", t.getElapsedTime());
   
    db.create(contentVersion);
    RequestAnalyser.getRequestAnalyser().registerComponentStatistics("create 3.1", t.getElapsedTime());

        if(oldContentVersionId != null && oldContentVersionId.intValue() != -1 && hasAssets)
        copyDigitalAssets(oldContentVersion, contentVersion, allowBrokenAssets, duplicateAssets, excludedAssetId, db);

        return contentVersion;
View Full Code Here

   * @throws Exception
   */

  protected void initialize(String groupName) throws Exception
  {
    Timer t = new Timer();
   
      super.initialize();
    t.printElapsedTime("initialize 1");
   
    logger.info("groupName:" + groupName);

    List contentTypeDefinitionVOList = GroupPropertiesController.getController().getContentTypeDefinitionVOList(groupName);
    if(contentTypeDefinitionVOList != null && contentTypeDefinitionVOList.size() > 0)
      this.setContentTypeDefinitionVO((ContentTypeDefinitionVO)contentTypeDefinitionVOList.get(0));
    t.printElapsedTime("initialize 2");
   
    InfoGlueGroup infoGlueGroup = GroupControllerProxy.getController().getGroup(groupName);
    groupPropertiesVOList = GroupPropertiesController.getController().getGroupPropertiesVOList(groupName, this.getLanguageId());
    if(groupPropertiesVOList != null && groupPropertiesVOList.size() > 0)
    {
      this.groupPropertiesVO = (GroupPropertiesVO)groupPropertiesVOList.get(0);
      this.setContentTypeDefinitionId(this.groupPropertiesVO.getContentTypeDefinitionId());
    }
    else
    {
      this.setContentTypeDefinitionId(this.getContentTypeDefinitionVO().getContentTypeDefinitionId());
    }
    t.printElapsedTime("initialize 3");
   
    logger.info("this.groupPropertiesVO:" + this.groupPropertiesVO);
   
    this.setAttributes(ContentTypeDefinitionController.getController().getContentTypeAttributes(this.getContentTypeDefinitionVO().getSchemaValue(), true, getLanguageCode(), getInfoGluePrincipal(), null))
 
    t.printElapsedTime("initialize 4");
  }
View Full Code Here

   * This method returns a list of the children a siteNode has.
   */
    
  public SmallestContentVersionVO getFirstContentVersionId(Integer languageId, Database db) throws Exception
  {
    Timer t = new Timer();
   
    SmallestContentVersionVO contentVersionVO = null;
     
       StringBuffer SQL = new StringBuffer();

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.