Commits

skanjo  committed d5ffbf6

Moved existing source into new layout.

git-svn-id: http://svn.opensymphony.com/svn/propertyset/branches/maven_build@237bf3cbcdd-1c1a-0410-9a68-d6f521e3fa7b

  • Participants
  • Parent commits 7e9a9c9

Comments (0)

Files changed (6)

File providers/ojb/src/com/opensymphony/module/propertyset/ojb/OJBPropertySet.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.module.propertyset.ojb;
-
-import com.opensymphony.module.propertyset.AbstractPropertySet;
-import com.opensymphony.module.propertyset.PropertyException;
-import com.opensymphony.module.propertyset.PropertySet;
-
-import com.opensymphony.util.Data;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.ojb.broker.PBFactoryException;
-import org.apache.ojb.broker.PersistenceBroker;
-import org.apache.ojb.broker.PersistenceBrokerFactory;
-import org.apache.ojb.broker.query.*;
-
-import java.util.*;
-
-
-/**
- * @author picard
- * Created on 11 sept. 2003
- */
-public class OJBPropertySet extends AbstractPropertySet {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    private static final Log log = LogFactory.getLog(OJBPropertySet.class);
-
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    String globalKey = null;
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public Collection getKeys(String prefix, int type) throws PropertyException {
-        PersistenceBroker broker = null;
-        ArrayList list = new ArrayList();
-
-        try {
-            broker = this.getBroker();
-
-            if (prefix == null) {
-                prefix = "";
-            }
-
-            Criteria criteria = new Criteria();
-            criteria.addEqualTo("globalKey", globalKey);
-            criteria.addLike("itemKey", prefix);
-
-            if (type != 0) {
-                criteria.addEqualTo("itemType", new Integer(type));
-            }
-
-            ReportQueryByCriteria q = QueryFactory.newReportQuery(OJBPropertySetItem.class, criteria);
-            q.setColumns(new String[] {"itemKey"});
-
-            Iterator iter = broker.getReportQueryIteratorByQuery(q);
-
-            while (iter.hasNext()) {
-                Object[] obj = (Object[]) iter.next();
-
-                String itemKey = (String) obj[0];
-
-                list.add(itemKey);
-            }
-        } catch (Exception e) {
-            log.error("An exception occured", e);
-
-            throw new PropertyException(e.getMessage());
-        } finally {
-            broker.close();
-        }
-
-        return list;
-    }
-
-    public int getType(String key) throws PropertyException {
-        PersistenceBroker broker = null;
-        int type = 0;
-
-        try {
-            broker = this.getBroker();
-
-            Criteria criteria = new Criteria();
-            criteria.addEqualTo("globalKey", globalKey);
-            criteria.addLike("itemKey", key);
-
-            ReportQueryByCriteria q = QueryFactory.newReportQuery(OJBPropertySetItem.class, criteria);
-            q.setColumns(new String[] {"itemType"});
-
-            Iterator iter = broker.getReportQueryIteratorByQuery(q);
-
-            if (iter.hasNext()) {
-                Object[] obj = (Object[]) iter.next();
-
-                type = ((Integer) obj[0]).intValue();
-            }
-        } catch (Exception e) {
-            log.error("An exception occured", e);
-
-            throw new PropertyException(e.getMessage());
-        } finally {
-            broker.close();
-        }
-
-        return type;
-    }
-
-    public boolean exists(String key) throws PropertyException {
-        return getType(key) != 0;
-    }
-
-    public void init(Map config, Map args) {
-        // args
-        globalKey = (String) args.get("globalKey");
-    }
-
-    public void remove() throws PropertyException {
-        PersistenceBroker broker = null;
-
-        try {
-            broker = this.getBroker();
-
-            Criteria criteria = new Criteria();
-            criteria.addEqualTo("globalKey", globalKey);
-
-            Query query = new QueryByCriteria(OJBPropertySetItem.class, criteria);
-
-            broker.delete(query);
-        } catch (Exception e) {
-            log.error("An exception occured", e);
-
-            throw new PropertyException(e.getMessage());
-        } finally {
-            broker.close();
-        }
-    }
-
-    public void remove(String key) throws PropertyException {
-        PersistenceBroker broker = null;
-
-        try {
-            broker = this.getBroker();
-
-            Criteria criteria = new Criteria();
-            criteria.addEqualTo("globalKey", globalKey);
-            criteria.addEqualTo("itemKey", key);
-
-            Query query = new QueryByCriteria(OJBPropertySetItem.class, criteria);
-
-            broker.delete(query);
-        } catch (Exception e) {
-            log.error("An exception occured", e);
-
-            throw new PropertyException(e.getMessage());
-        } finally {
-            broker.close();
-        }
-    }
-
-    protected void setImpl(int type, String key, Object value) throws PropertyException {
-        PersistenceBroker broker = null;
-
-        if (value == null) {
-            throw new PropertyException("OJBPropertySet does not allow for null values to be stored");
-        }
-
-        try {
-            broker = this.getBroker();
-
-            OJBPropertySetItem newProperty = new OJBPropertySetItem();
-            newProperty.setItemType(type);
-            newProperty.setGlobalKey(globalKey);
-            newProperty.setItemKey(key);
-
-            switch (type) {
-            case PropertySet.BOOLEAN:
-
-                Boolean boolVal = (Boolean) value;
-                newProperty.setLongValue(boolVal.booleanValue() ? 1 : 0);
-
-                break;
-
-            case PropertySet.DATE:
-                newProperty.setDateValue((Date) value);
-
-                break;
-
-            case PropertySet.DOUBLE:
-
-                Double dblValue = (Double) value;
-                newProperty.setDoubleValue(dblValue.doubleValue());
-
-                break;
-
-            case PropertySet.LONG:
-
-                Long lngValue = (Long) value;
-                newProperty.setLongValue(lngValue.longValue());
-
-                break;
-
-            case PropertySet.INT:
-
-                Integer intValue = (Integer) value;
-                newProperty.setLongValue(intValue.longValue());
-
-                break;
-
-            case PropertySet.STRING:
-                newProperty.setStringValue((String) value);
-
-                break;
-
-            case PropertySet.DATA:
-
-                Data data = (Data) value;
-                newProperty.setByteValue(data.getBytes());
-
-                break;
-
-            default:
-                throw new PropertyException("This type : " + type + ", isn't supported!");
-            }
-
-            broker.store(newProperty);
-        } catch (Exception e) {
-            log.error("An exception occured", e);
-
-            throw new PropertyException(e.getMessage());
-        } finally {
-            broker.close();
-        }
-    }
-
-    protected Object get(int type, String key) throws PropertyException {
-        PersistenceBroker broker = null;
-        Object value = null;
-
-        try {
-            broker = this.getBroker();
-
-            Criteria criteria = new Criteria();
-            criteria.addEqualTo("globalKey", globalKey);
-            criteria.addLike("itemKey", key);
-
-            Query query = new QueryByCriteria(OJBPropertySetItem.class, criteria);
-
-            OJBPropertySetItem item = (OJBPropertySetItem) broker.getObjectByQuery(query);
-
-            switch (type) {
-            case PropertySet.BOOLEAN:
-
-                if (item.getLongValue() == 1) {
-                    value = new Boolean(true);
-                } else {
-                    value = new Boolean(false);
-                }
-
-                break;
-
-            case PropertySet.DATE:
-                value = item.getDateValue();
-
-                break;
-
-            case PropertySet.DOUBLE:
-                value = new Double(item.getDoubleValue());
-
-                break;
-
-            case PropertySet.LONG:
-                value = new Long(item.getLongValue());
-
-                break;
-
-            case PropertySet.INT:
-                value = new Integer((int) item.longValue);
-
-                break;
-
-            case PropertySet.STRING:
-                value = item.getStringValue();
-
-                break;
-
-            case PropertySet.DATA:
-                value = item.getByteValue();
-
-                break;
-
-            default:
-                throw new PropertyException("Type " + type + " is not supported");
-            }
-        } catch (Exception e) {
-            log.error("Could not get value for key " + key + " of type " + type, e);
-            throw new PropertyException(e.getMessage());
-        } finally {
-            broker.close();
-        }
-
-        return value;
-    }
-
-    // get an instance.
-    private PersistenceBroker getBroker() throws PBFactoryException {
-        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
-
-        return broker;
-    }
-}

File providers/ojb/src/com/opensymphony/module/propertyset/ojb/OJBPropertySetItem.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package com.opensymphony.module.propertyset.ojb;
-
-import java.io.Serializable;
-
-import java.util.Date;
-
-
-/**
- * @author picard
- */
-public class OJBPropertySetItem implements Serializable {
-    //~ Instance fields ////////////////////////////////////////////////////////
-
-    Date dateValue;
-    String globalKey;
-    String itemKey;
-    String stringValue;
-    byte[] byteValue;
-    double doubleValue;
-    int itemType;
-    long longValue;
-
-    //~ Constructors ///////////////////////////////////////////////////////////
-
-    public OJBPropertySetItem() {
-    }
-
-    //~ Methods ////////////////////////////////////////////////////////////////
-
-    public void setByteValue(byte[] bs) {
-        byteValue = bs;
-    }
-
-    public byte[] getByteValue() {
-        return byteValue;
-    }
-
-    public void setDateValue(Date date) {
-        dateValue = date;
-    }
-
-    public Date getDateValue() {
-        return dateValue;
-    }
-
-    /**
-     * @param d
-     */
-    public void setDoubleValue(double d) {
-        doubleValue = d;
-    }
-
-    public double getDoubleValue() {
-        return doubleValue;
-    }
-
-    public void setGlobalKey(String string) {
-        globalKey = string;
-    }
-
-    public String getGlobalKey() {
-        return globalKey;
-    }
-
-    public void setItemKey(String string) {
-        itemKey = string;
-    }
-
-    public String getItemKey() {
-        return itemKey;
-    }
-
-    public void setItemType(int i) {
-        itemType = i;
-    }
-
-    public int getItemType() {
-        return itemType;
-    }
-
-    public void setLongValue(long l) {
-        longValue = l;
-    }
-
-    public long getLongValue() {
-        return longValue;
-    }
-
-    public void setStringValue(String string) {
-        stringValue = string;
-    }
-
-    public String getStringValue() {
-        return stringValue;
-    }
-}

File providers/ojb/src/com/opensymphony/module/propertyset/ojb/PropertySet.xml

-<!--
-Definitions for OJBWorkflowEntry
-Put this file in the classpath and modify the repository.xml file to use this file (see OJB doc),
-this represent the mapping between OJB classes and osworkflow database on SQLServer,
-but it can be easily adapted to other database servers.
-
-Contributed by J�r�me Picard
- -->
-
-<!-- Definitions for OJBPropertySetItem -->
-<class-descriptor class="com.opensymphony.module.propertyset.ojb.OJBPropertySetItem" table="OS_PROPERTYENTRY">
-  <field-descriptor id="1" name="globalKey" column="GLOBAL_KEY" jdbc-type="VARCHAR" primarykey="true"/>
-  <field-descriptor id="2" name="itemKey" column="ITEM_KEY" jdbc-type="VARCHAR" primarykey="true"/>
-  <field-descriptor id="3" name="itemType" column="ITEM_TYPE" jdbc-type="INTEGER"/>
-  <field-descriptor id="4" name="stringValue" column="STRING_VALUE" jdbc-type="VARCHAR"/>
-  <field-descriptor id="5" name="dateValue" column="DATE_VALUE" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
-  <field-descriptor id="6" name="doubleValue" column="FLOAT_VALUE" jdbc-type="DOUBLE"/>
-  <field-descriptor id="7" name="longValue" column="NUMBER_VALUE" jdbc-type="BIGINT"/>
-  <field-descriptor id="8" name="byteValue" column="DATA_VALUE" jdbc-type="VARBINARY"/>
-  <attribute attribute-name="cacheable" attribute-value="false"/>
-</class-descriptor>

File providers/ojb/src/main/java/com/opensymphony/module/propertyset/ojb/OJBPropertySet.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.module.propertyset.ojb;
+
+import com.opensymphony.module.propertyset.AbstractPropertySet;
+import com.opensymphony.module.propertyset.PropertyException;
+import com.opensymphony.module.propertyset.PropertySet;
+
+import com.opensymphony.util.Data;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.ojb.broker.PBFactoryException;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.PersistenceBrokerFactory;
+import org.apache.ojb.broker.query.*;
+
+import java.util.*;
+
+
+/**
+ * @author picard
+ * Created on 11 sept. 2003
+ */
+public class OJBPropertySet extends AbstractPropertySet {
+    //~ Static fields/initializers /////////////////////////////////////////////
+
+    private static final Log log = LogFactory.getLog(OJBPropertySet.class);
+
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    String globalKey = null;
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public Collection getKeys(String prefix, int type) throws PropertyException {
+        PersistenceBroker broker = null;
+        ArrayList list = new ArrayList();
+
+        try {
+            broker = this.getBroker();
+
+            if (prefix == null) {
+                prefix = "";
+            }
+
+            Criteria criteria = new Criteria();
+            criteria.addEqualTo("globalKey", globalKey);
+            criteria.addLike("itemKey", prefix);
+
+            if (type != 0) {
+                criteria.addEqualTo("itemType", new Integer(type));
+            }
+
+            ReportQueryByCriteria q = QueryFactory.newReportQuery(OJBPropertySetItem.class, criteria);
+            q.setColumns(new String[] {"itemKey"});
+
+            Iterator iter = broker.getReportQueryIteratorByQuery(q);
+
+            while (iter.hasNext()) {
+                Object[] obj = (Object[]) iter.next();
+
+                String itemKey = (String) obj[0];
+
+                list.add(itemKey);
+            }
+        } catch (Exception e) {
+            log.error("An exception occured", e);
+
+            throw new PropertyException(e.getMessage());
+        } finally {
+            broker.close();
+        }
+
+        return list;
+    }
+
+    public int getType(String key) throws PropertyException {
+        PersistenceBroker broker = null;
+        int type = 0;
+
+        try {
+            broker = this.getBroker();
+
+            Criteria criteria = new Criteria();
+            criteria.addEqualTo("globalKey", globalKey);
+            criteria.addLike("itemKey", key);
+
+            ReportQueryByCriteria q = QueryFactory.newReportQuery(OJBPropertySetItem.class, criteria);
+            q.setColumns(new String[] {"itemType"});
+
+            Iterator iter = broker.getReportQueryIteratorByQuery(q);
+
+            if (iter.hasNext()) {
+                Object[] obj = (Object[]) iter.next();
+
+                type = ((Integer) obj[0]).intValue();
+            }
+        } catch (Exception e) {
+            log.error("An exception occured", e);
+
+            throw new PropertyException(e.getMessage());
+        } finally {
+            broker.close();
+        }
+
+        return type;
+    }
+
+    public boolean exists(String key) throws PropertyException {
+        return getType(key) != 0;
+    }
+
+    public void init(Map config, Map args) {
+        // args
+        globalKey = (String) args.get("globalKey");
+    }
+
+    public void remove() throws PropertyException {
+        PersistenceBroker broker = null;
+
+        try {
+            broker = this.getBroker();
+
+            Criteria criteria = new Criteria();
+            criteria.addEqualTo("globalKey", globalKey);
+
+            Query query = new QueryByCriteria(OJBPropertySetItem.class, criteria);
+
+            broker.delete(query);
+        } catch (Exception e) {
+            log.error("An exception occured", e);
+
+            throw new PropertyException(e.getMessage());
+        } finally {
+            broker.close();
+        }
+    }
+
+    public void remove(String key) throws PropertyException {
+        PersistenceBroker broker = null;
+
+        try {
+            broker = this.getBroker();
+
+            Criteria criteria = new Criteria();
+            criteria.addEqualTo("globalKey", globalKey);
+            criteria.addEqualTo("itemKey", key);
+
+            Query query = new QueryByCriteria(OJBPropertySetItem.class, criteria);
+
+            broker.delete(query);
+        } catch (Exception e) {
+            log.error("An exception occured", e);
+
+            throw new PropertyException(e.getMessage());
+        } finally {
+            broker.close();
+        }
+    }
+
+    protected void setImpl(int type, String key, Object value) throws PropertyException {
+        PersistenceBroker broker = null;
+
+        if (value == null) {
+            throw new PropertyException("OJBPropertySet does not allow for null values to be stored");
+        }
+
+        try {
+            broker = this.getBroker();
+
+            OJBPropertySetItem newProperty = new OJBPropertySetItem();
+            newProperty.setItemType(type);
+            newProperty.setGlobalKey(globalKey);
+            newProperty.setItemKey(key);
+
+            switch (type) {
+            case PropertySet.BOOLEAN:
+
+                Boolean boolVal = (Boolean) value;
+                newProperty.setLongValue(boolVal.booleanValue() ? 1 : 0);
+
+                break;
+
+            case PropertySet.DATE:
+                newProperty.setDateValue((Date) value);
+
+                break;
+
+            case PropertySet.DOUBLE:
+
+                Double dblValue = (Double) value;
+                newProperty.setDoubleValue(dblValue.doubleValue());
+
+                break;
+
+            case PropertySet.LONG:
+
+                Long lngValue = (Long) value;
+                newProperty.setLongValue(lngValue.longValue());
+
+                break;
+
+            case PropertySet.INT:
+
+                Integer intValue = (Integer) value;
+                newProperty.setLongValue(intValue.longValue());
+
+                break;
+
+            case PropertySet.STRING:
+                newProperty.setStringValue((String) value);
+
+                break;
+
+            case PropertySet.DATA:
+
+                Data data = (Data) value;
+                newProperty.setByteValue(data.getBytes());
+
+                break;
+
+            default:
+                throw new PropertyException("This type : " + type + ", isn't supported!");
+            }
+
+            broker.store(newProperty);
+        } catch (Exception e) {
+            log.error("An exception occured", e);
+
+            throw new PropertyException(e.getMessage());
+        } finally {
+            broker.close();
+        }
+    }
+
+    protected Object get(int type, String key) throws PropertyException {
+        PersistenceBroker broker = null;
+        Object value = null;
+
+        try {
+            broker = this.getBroker();
+
+            Criteria criteria = new Criteria();
+            criteria.addEqualTo("globalKey", globalKey);
+            criteria.addLike("itemKey", key);
+
+            Query query = new QueryByCriteria(OJBPropertySetItem.class, criteria);
+
+            OJBPropertySetItem item = (OJBPropertySetItem) broker.getObjectByQuery(query);
+
+            switch (type) {
+            case PropertySet.BOOLEAN:
+
+                if (item.getLongValue() == 1) {
+                    value = new Boolean(true);
+                } else {
+                    value = new Boolean(false);
+                }
+
+                break;
+
+            case PropertySet.DATE:
+                value = item.getDateValue();
+
+                break;
+
+            case PropertySet.DOUBLE:
+                value = new Double(item.getDoubleValue());
+
+                break;
+
+            case PropertySet.LONG:
+                value = new Long(item.getLongValue());
+
+                break;
+
+            case PropertySet.INT:
+                value = new Integer((int) item.longValue);
+
+                break;
+
+            case PropertySet.STRING:
+                value = item.getStringValue();
+
+                break;
+
+            case PropertySet.DATA:
+                value = item.getByteValue();
+
+                break;
+
+            default:
+                throw new PropertyException("Type " + type + " is not supported");
+            }
+        } catch (Exception e) {
+            log.error("Could not get value for key " + key + " of type " + type, e);
+            throw new PropertyException(e.getMessage());
+        } finally {
+            broker.close();
+        }
+
+        return value;
+    }
+
+    // get an instance.
+    private PersistenceBroker getBroker() throws PBFactoryException {
+        PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+
+        return broker;
+    }
+}

File providers/ojb/src/main/java/com/opensymphony/module/propertyset/ojb/OJBPropertySetItem.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.module.propertyset.ojb;
+
+import java.io.Serializable;
+
+import java.util.Date;
+
+
+/**
+ * @author picard
+ */
+public class OJBPropertySetItem implements Serializable {
+    //~ Instance fields ////////////////////////////////////////////////////////
+
+    Date dateValue;
+    String globalKey;
+    String itemKey;
+    String stringValue;
+    byte[] byteValue;
+    double doubleValue;
+    int itemType;
+    long longValue;
+
+    //~ Constructors ///////////////////////////////////////////////////////////
+
+    public OJBPropertySetItem() {
+    }
+
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public void setByteValue(byte[] bs) {
+        byteValue = bs;
+    }
+
+    public byte[] getByteValue() {
+        return byteValue;
+    }
+
+    public void setDateValue(Date date) {
+        dateValue = date;
+    }
+
+    public Date getDateValue() {
+        return dateValue;
+    }
+
+    /**
+     * @param d
+     */
+    public void setDoubleValue(double d) {
+        doubleValue = d;
+    }
+
+    public double getDoubleValue() {
+        return doubleValue;
+    }
+
+    public void setGlobalKey(String string) {
+        globalKey = string;
+    }
+
+    public String getGlobalKey() {
+        return globalKey;
+    }
+
+    public void setItemKey(String string) {
+        itemKey = string;
+    }
+
+    public String getItemKey() {
+        return itemKey;
+    }
+
+    public void setItemType(int i) {
+        itemType = i;
+    }
+
+    public int getItemType() {
+        return itemType;
+    }
+
+    public void setLongValue(long l) {
+        longValue = l;
+    }
+
+    public long getLongValue() {
+        return longValue;
+    }
+
+    public void setStringValue(String string) {
+        stringValue = string;
+    }
+
+    public String getStringValue() {
+        return stringValue;
+    }
+}

File providers/ojb/src/main/java/com/opensymphony/module/propertyset/ojb/PropertySet.xml

+<!--
+Definitions for OJBWorkflowEntry
+Put this file in the classpath and modify the repository.xml file to use this file (see OJB doc),
+this represent the mapping between OJB classes and osworkflow database on SQLServer,
+but it can be easily adapted to other database servers.
+
+Contributed by J�r�me Picard
+ -->
+
+<!-- Definitions for OJBPropertySetItem -->
+<class-descriptor class="com.opensymphony.module.propertyset.ojb.OJBPropertySetItem" table="OS_PROPERTYENTRY">
+  <field-descriptor id="1" name="globalKey" column="GLOBAL_KEY" jdbc-type="VARCHAR" primarykey="true"/>
+  <field-descriptor id="2" name="itemKey" column="ITEM_KEY" jdbc-type="VARCHAR" primarykey="true"/>
+  <field-descriptor id="3" name="itemType" column="ITEM_TYPE" jdbc-type="INTEGER"/>
+  <field-descriptor id="4" name="stringValue" column="STRING_VALUE" jdbc-type="VARCHAR"/>
+  <field-descriptor id="5" name="dateValue" column="DATE_VALUE" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
+  <field-descriptor id="6" name="doubleValue" column="FLOAT_VALUE" jdbc-type="DOUBLE"/>
+  <field-descriptor id="7" name="longValue" column="NUMBER_VALUE" jdbc-type="BIGINT"/>
+  <field-descriptor id="8" name="byteValue" column="DATA_VALUE" jdbc-type="VARBINARY"/>
+  <attribute attribute-name="cacheable" attribute-value="false"/>
+</class-descriptor>