Package com.opensymphony.module.propertyset

Examples of com.opensymphony.module.propertyset.PropertyException


        logger.debug("PropertysetHelper.setData(\"" + key + "\",\"" + value + "\")");
        setData(key, value.getBytes(UTF8_ENCODING));
      }
      catch(UnsupportedEncodingException e)
      {
        throw new PropertyException("Unable to set data for [" + key + "].");
      }
    }
   
  }
View Full Code Here


      logger.debug("PropertysetHelper.getData(\"" + key + "\")=\"" + (value == null ? "NULL" : value) + "\"");
      return value;
    }
    catch(UnsupportedEncodingException e)
    {
      throw new PropertyException("Unable to get data for [" + key + "].");
    }
  }
View Full Code Here

            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)
            {
              //System.out.println("Switching valueMap from:" + valueMap.hashCode() + " --> " + currentValueMap.hashCode());
              type5Map = currentType5Map;
              valueMapType5 = currentValue5Map;
              typeMap5Fallback = new HashMap();
              valueMap5Fallback = new HashMap();

              type10Map = currentType10Map;
              valueMapType10 = currentValue10Map;
              typeMap10Fallback = new HashMap();
              valueMap10Fallback = new HashMap();
            }
           
            rs.close();
            ps.close();

            return list;
        }
        catch (SQLException e)
        {
          logger.error("Problem getting keys due to an SQL exception:" + e.getCause().getMessage(), e);
            throw new PropertyException(e.getMessage());
        }
        catch (PropertyException pe)
        {
          //logger.error("Problem getting keys due to unavailable connection:" + e.getCause().getMessage());
            throw new PropertyException(pe.getMessage());
        }
        catch (Throwable tr)
        {
          logger.error("Problem getting keys:" + tr.getMessage(), tr);
            throw new PropertyException(tr.getMessage());
        }
        /*
        catch (UnsupportedEncodingException ue)
        {
            throw new PropertyException(ue.getMessage());
View Full Code Here

            return type;
        }
        catch (SQLException e)
        {
            throw new PropertyException(e.getMessage());
        }
        finally
        {
            closeConnection(conn);
        }
View Full Code Here

            if(type10Map != null)
              type10Map.remove(key);
        }
        catch (SQLException e)
        {
            throw new PropertyException(e.getMessage());
        }
        finally
        {
            closeConnection(conn);
        }
View Full Code Here

    protected void setImpl(int type, String key, Object value) throws PropertyException
    {
        if (value == null)
        {
            throw new PropertyException("JDBCPropertySet does not allow for null values to be stored");
        }

        Connection conn = null;

        try
        {
          if(this.colItemKey == null || this.globalKey == null)
            {
              try
                {
            reloadConfiguration();
          }
                catch (Exception e1)
          {
            e1.printStackTrace();
          }
            }
         
            conn = getConnection();

            String sql = "UPDATE " + tableName + " SET " + colString + " = ?, " + colDate + " = ?, " + colData + " = ?, " + colFloat + " = ?, " + colNumber + " = ?, " + colItemType + " = ? " + " WHERE " + colGlobalKey + " = ? AND " + colItemKey + " = ?";
            PreparedStatement ps = conn.prepareStatement(sql);
            setValues(ps, type, key, value);

            int rows = ps.executeUpdate();
            ps.close();

            if (rows != 1)
            {
                // ok, this is a new value, insert it
                sql = "INSERT INTO " + tableName + " (" + colString + ", " + colDate + ", " + colData + ", " + colFloat + ", " + colNumber + ", " + colItemType + ", " + colGlobalKey + ", " + colItemKey + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
                ps = conn.prepareStatement(sql);
                setValues(ps, type, key, value);
                ps.executeUpdate();
                ps.close();           
            }
        }
        catch (SQLException e)
        {
            try
            {
        reloadConfiguration();
      }
            catch (Exception e1)
      {
        e1.printStackTrace();
      }
            throw new PropertyException(e.getMessage());
        }
        finally
        {
            closeConnection(conn);
        }
View Full Code Here

            //t.printElapsedTime("Read took + " + type + "=" + o);
        }
        catch (SQLException e)
        {
          logger.error("Problem getting property from database:" + e.getMessage());
          throw new PropertyException(e.getMessage());
        }
        catch (NumberFormatException e)
        {
          logger.error("Problem getting property from database:" + e.getMessage());
          throw new PropertyException(e.getMessage());
        }
        /*
        catch (UnsupportedEncodingException ue)
        {
          throw new PropertyException(ue.getMessage());
View Full Code Here

            ps.setString(1, (String) value);

            break;

        default:
            throw new PropertyException("This type isn't supported!");
        }
       
        if(type != 10 && valueMapType5 == null)
      valueMapType5 = new HashMap();
        if(type != 10 && type5Map == null)
View Full Code Here

                session.save(item);
            }

            session.flush();
        } catch (HibernateException he) {
            throw new PropertyException("Could not save key '" + item.getKey() + "':" + he.getMessage());
        } finally {
            try {
                if (session != null) {
                    if (!session.connection().getAutoCommit()) {
                        session.connection().commit();
View Full Code Here

                session.delete(InfoglueHibernatePropertySetDAOUtils.getItem(session, entityName, entityId, key));
            }

            session.flush();
        } catch (HibernateException e) {
            throw new PropertyException("Could not remove all keys: " + e.getMessage());
        } finally {
            try {
                if (session != null) {
                    if (!session.connection().getAutoCommit()) {
                        session.connection().commit();
View Full Code Here

TOP

Related Classes of com.opensymphony.module.propertyset.PropertyException

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.