jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r792142 [7/35] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabb...
Date Wed, 08 Jul 2009 13:57:46 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/PropertyDefinitionImpl.java Wed Jul  8 13:57:13 2009
@@ -22,8 +22,11 @@
 import javax.jcr.nodetype.PropertyDefinition;
 
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +52,7 @@
      * @param propDef    property definition
      * @param ntMgr      node type manager
      * @param resolver   name resolver
-     * @param valueFactory
+     * @param valueFactory the value factory
      */
     PropertyDefinitionImpl(PropDef propDef, NodeTypeManagerImpl ntMgr,
                            NamePathResolver resolver, ValueFactory valueFactory) {
@@ -102,13 +105,19 @@
      * {@inheritDoc}
      */
     public String[] getValueConstraints() {
-        ValueConstraint[] constraints = ((PropDef) itemDef).getValueConstraints();
+        QValueConstraint[] constraints = ((PropDef) itemDef).getValueConstraints();
         if (constraints == null || constraints.length == 0) {
             return new String[0];
         }
         String[] vca = new String[constraints.length];
         for (int i = 0; i < constraints.length; i++) {
-            vca[i] = constraints[i].getDefinition(resolver);
+            try {
+                ValueConstraint vc = ValueConstraint.create(((PropDef) itemDef).getRequiredType(), constraints[i].getString());
+                vca[i] = vc.getDefinition(resolver);
+            } catch (InvalidConstraintException e) {
+                log.warn("Error during conversion of value constraint.", e);
+                vca[i] = constraints[i].getString();
+            }
         }
         return vca;
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java Wed Jul  8 13:57:13 2009
@@ -30,7 +30,6 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.nodetype.ValueConstraint;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -38,6 +37,7 @@
 import org.apache.jackrabbit.core.virtual.AbstractVISProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.uuid.UUID;
 
@@ -229,10 +229,10 @@
             defValsType = defVals[0].getType();
         }
         pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
-        ValueConstraint[] vc = propDef.getValueConstraints();
+        QValueConstraint[] vc = propDef.getValueConstraints();
         InternalValue[] vals = new InternalValue[vc.length];
         for (int i = 0; i < vc.length; i++) {
-            vals[i] = InternalValue.create(vc[i].getDefinition());
+            vals[i] = InternalValue.create(vc[i].getString());
         }
         pState.setPropertyValues(NameConstants.JCR_VALUECONSTRAINTS, PropertyType.STRING, vals);
         return pState;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeReader.java Wed Jul  8 13:57:13 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.nodetype.xml;
 
-import org.apache.jackrabbit.core.nodetype.InvalidConstraintException;
 import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
 import org.apache.jackrabbit.core.nodetype.ItemDef;
 import org.apache.jackrabbit.core.nodetype.NodeDef;
@@ -24,20 +23,27 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.PropDef;
 import org.apache.jackrabbit.core.nodetype.PropDefImpl;
-import org.apache.jackrabbit.core.nodetype.ValueConstraint;
 import org.apache.jackrabbit.core.util.DOMWalker;
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.core.value.InternalValueFactory;
 import org.apache.jackrabbit.spi.commons.conversion.NameException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
+import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.value.ValueHelper;
-import org.apache.jackrabbit.value.ValueFactoryImpl;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceException;
+import javax.jcr.ValueFactory;
+import javax.jcr.Value;
 import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.version.OnParentVersionAction;
 import java.io.IOException;
@@ -87,6 +93,10 @@
     /** The name, path resolver. */
     private final NamePathResolver resolver;
 
+    private final ValueFactory valueFactory;
+
+    private final QValueFactory qValueFactory = InternalValueFactory.getInstance();
+
     /**
      * Creates a node type definition file reader.
      *
@@ -98,11 +108,13 @@
         namespaces = walker.getNamespaces();
         NamespaceResolver nsResolver = new AdditionalNamespaceResolver(namespaces);
         resolver = new DefaultNamePathResolver(nsResolver);
+        valueFactory = new ValueFactoryQImpl(qValueFactory, resolver);
     }
 
     /**
      * Returns the namespaces declared in the node type definition
      * file.
+     * @return the namespaces
      */
     public Properties getNamespaces() {
         return namespaces;
@@ -116,14 +128,15 @@
      * @throws InvalidNodeTypeDefException if a definition is invalid
      * @throws NameException               if a definition contains an
      *                                     illegal name
+     * @throws NamespaceException if a namespace is not defined
      */
     public NodeTypeDef[] getNodeTypeDefs()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
-        List defs = new ArrayList();
+        List<NodeTypeDef> defs = new ArrayList<NodeTypeDef>();
         while (walker.iterateElements(Constants.NODETYPE_ELEMENT)) {
             defs.add(getNodeTypeDef());
         }
-        return (NodeTypeDef[]) defs.toArray(new NodeTypeDef[defs.size()]);
+        return defs.toArray(new NodeTypeDef[defs.size()]);
     }
 
     /**
@@ -133,6 +146,7 @@
      * @throws InvalidNodeTypeDefException if the definition is invalid
      * @throws NameException               if the definition contains an
      *                                     illegal name
+     * @throws NamespaceException if a namespace is not defined
      */
     private NodeTypeDef getNodeTypeDef()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
@@ -141,17 +155,15 @@
         type.setName(resolver.getQName(
                 walker.getAttribute(Constants.NAME_ATTRIBUTE)));
         type.setMixin(Boolean.valueOf(
-                walker.getAttribute(Constants.ISMIXIN_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.ISMIXIN_ATTRIBUTE)));
         type.setOrderableChildNodes(Boolean.valueOf(
-                walker.getAttribute(Constants.HASORDERABLECHILDNODES_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.HASORDERABLECHILDNODES_ATTRIBUTE)));
         type.setAbstract(Boolean.valueOf(
-                walker.getAttribute(Constants.ISABSTRACT_ATTRIBUTE))
-                .booleanValue());
-        type.setQueryable(Boolean.valueOf(
-                walker.getAttribute(Constants.ISQUERYABLE_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.ISABSTRACT_ATTRIBUTE)));
+        if (walker.getAttribute(Constants.ISQUERYABLE_ATTRIBUTE) != null) {
+            type.setQueryable(Boolean.valueOf(
+                    walker.getAttribute(Constants.ISQUERYABLE_ATTRIBUTE)));
+        }
         String primaryItemName =
             walker.getAttribute(Constants.PRIMARYITEMNAME_ATTRIBUTE);
         if (primaryItemName != null && primaryItemName.length() > 0) {
@@ -161,35 +173,32 @@
 
         // supertype declarations
         if (walker.enterElement(Constants.SUPERTYPES_ELEMENT)) {
-            List supertypes = new ArrayList();
+            List<Name> supertypes = new ArrayList<Name>();
             while (walker.iterateElements(Constants.SUPERTYPE_ELEMENT)) {
                 supertypes.add(
                         resolver.getQName(walker.getContent()));
             }
-            type.setSupertypes((Name[])
-                    supertypes.toArray(new Name[supertypes.size()]));
+            type.setSupertypes(supertypes.toArray(new Name[supertypes.size()]));
             walker.leaveElement();
         }
 
         // property definitions
-        List properties = new ArrayList();
+        List<PropDef> properties = new ArrayList<PropDef>();
         while (walker.iterateElements(Constants.PROPERTYDEFINITION_ELEMENT)) {
             PropDefImpl def = getPropDef();
             def.setDeclaringNodeType(type.getName());
             properties.add(def);
         }
-        type.setPropertyDefs((PropDef[])
-                properties.toArray(new PropDef[properties.size()]));
+        type.setPropertyDefs(properties.toArray(new PropDef[properties.size()]));
 
         // child node definitions
-        List nodes = new ArrayList();
+        List<NodeDef> nodes = new ArrayList<NodeDef>();
         while (walker.iterateElements(Constants.CHILDNODEDEFINITION_ELEMENT)) {
             NodeDefImpl def = getChildNodeDef();
             def.setDeclaringNodeType(type.getName());
             nodes.add(def);
         }
-        type.setChildNodeDefs((NodeDef[])
-                nodes.toArray(new NodeDef[nodes.size()]));
+        type.setChildNodeDefs(nodes.toArray(new NodeDef[nodes.size()]));
 
         return type;
     }
@@ -201,6 +210,7 @@
      * @throws InvalidNodeTypeDefException if the definition is invalid
      * @throws NameException               if the definition contains an
      *                                     illegal name
+     * @throws NamespaceException if a namespace is not defined
      */
     private PropDefImpl getPropDef()
             throws InvalidNodeTypeDefException, NameException, NamespaceException {
@@ -225,20 +235,17 @@
         def.setOnParentVersion(OnParentVersionAction.valueFromName(
                 walker.getAttribute(Constants.ONPARENTVERSION_ATTRIBUTE)));
         def.setMultiple(Boolean.valueOf(
-                walker.getAttribute(Constants.MULTIPLE_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.MULTIPLE_ATTRIBUTE)));
         def.setFullTextSearchable(Boolean.valueOf(
-                walker.getAttribute(Constants.ISFULLTEXTSEARCHABLE_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.ISFULLTEXTSEARCHABLE_ATTRIBUTE)));
         def.setQueryOrderable(Boolean.valueOf(
-                walker.getAttribute(Constants.ISQUERYORDERABLE_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.ISQUERYORDERABLE_ATTRIBUTE)));
         String s = walker.getAttribute(Constants.AVAILABLEQUERYOPERATORS_ATTRIBUTE);
         if (s != null && s.length() > 0) {
             String[] ops = s.split(" ");
-            List queryOps = new ArrayList();
-            for (int i = 0; i < ops.length; i++) {
-                String op = ops[i].trim();
+            List<String> queryOps = new ArrayList<String>();
+            for (String op1 : ops) {
+                String op = op1.trim();
                 if (op.equals(Constants.EQ_ENTITY)) {
                     queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO);
                 } else if (op.equals(Constants.NE_ENTITY)) {
@@ -257,7 +264,7 @@
                     throw new InvalidNodeTypeDefException("'" + op + "' is not a valid query operator");
                 }
             }
-            def.setAvailableQueryOperators((String[]) queryOps.toArray(new String[queryOps.size()]));
+            def.setAvailableQueryOperators(queryOps.toArray(new String[queryOps.size()]));
 
         }
         def.setRequiredType(PropertyType.valueFromName(
@@ -265,7 +272,7 @@
 
         // value constraints
         if (walker.enterElement(Constants.VALUECONSTRAINTS_ELEMENT)) {
-            List constraints = new ArrayList();
+            List<QValueConstraint> constraints = new ArrayList<QValueConstraint>();
             int type = def.getRequiredType();
             while (walker.iterateElements(Constants.VALUECONSTRAINT_ELEMENT)) {
                 String constraint = walker.getContent();
@@ -277,14 +284,14 @@
                             "Invalid value constraint " + constraint, e);
                 }
             }
-            def.setValueConstraints((ValueConstraint[]) constraints.toArray(
-                    new ValueConstraint[constraints.size()]));
+            def.setValueConstraints(constraints.toArray(
+                    new QValueConstraint[constraints.size()]));
             walker.leaveElement();
         }
 
         // default values
         if (walker.enterElement(Constants.DEFAULTVALUES_ELEMENT)) {
-            List values = new ArrayList();
+            List<InternalValue> values = new ArrayList<InternalValue>();
             int type = def.getRequiredType();
             if (type == PropertyType.UNDEFINED) {
                 type = PropertyType.STRING;
@@ -292,15 +299,14 @@
             while (walker.iterateElements(Constants.DEFAULTVALUE_ELEMENT)) {
                 String value = walker.getContent();
                 try {
-                    values.add(InternalValue.create(ValueHelper.convert(
-                            value, type, ValueFactoryImpl.getInstance()), resolver));
+                    Value v = ValueHelper.convert(value, type, valueFactory);
+                    values.add((InternalValue) ValueFormat.getQValue(v, resolver, qValueFactory));
                 } catch (RepositoryException e) {
                     throw new InvalidNodeTypeDefException(
                             "Unable to create default value: " + value, e);
                 }
             }
-            def.setDefaultValues((InternalValue[])
-                    values.toArray(new InternalValue[values.size()]));
+            def.setDefaultValues(values.toArray(new InternalValue[values.size()]));
             walker.leaveElement();
         }
 
@@ -312,6 +318,7 @@
      *
      * @return child node definition
      * @throws NameException if the definition contains an illegal name
+     * @throws NamespaceException if a namespace is not defined
      */
     private NodeDefImpl getChildNodeDef() throws NameException, NamespaceException {
         NodeDefImpl def = new NodeDefImpl();
@@ -335,8 +342,7 @@
         def.setOnParentVersion(OnParentVersionAction.valueFromName(
                 walker.getAttribute(Constants.ONPARENTVERSION_ATTRIBUTE)));
         def.setAllowsSameNameSiblings(Boolean.valueOf(
-                walker.getAttribute(Constants.SAMENAMESIBLINGS_ATTRIBUTE))
-                .booleanValue());
+                walker.getAttribute(Constants.SAMENAMESIBLINGS_ATTRIBUTE)));
 
         // default primary type
         String type =
@@ -347,12 +353,11 @@
 
         // required primary types
         if (walker.enterElement(Constants.REQUIREDPRIMARYTYPES_ELEMENT)) {
-            List types = new ArrayList();
+            List<Name> types = new ArrayList<Name>();
             while (walker.iterateElements(Constants.REQUIREDPRIMARYTYPE_ELEMENT)) {
                 types.add(resolver.getQName(walker.getContent()));
             }
-            def.setRequiredPrimaryTypes(
-                    (Name[]) types.toArray(new Name[types.size()]));
+            def.setRequiredPrimaryTypes(types.toArray(new Name[types.size()]));
             walker.leaveElement();
         } else {
             /* Default to nt:base?

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/xml/NodeTypeWriter.java Wed Jul  8 13:57:13 2009
@@ -19,14 +19,17 @@
 import org.apache.jackrabbit.core.nodetype.NodeDef;
 import org.apache.jackrabbit.core.nodetype.NodeTypeDef;
 import org.apache.jackrabbit.core.nodetype.PropDef;
-import org.apache.jackrabbit.core.nodetype.ValueConstraint;
 import org.apache.jackrabbit.core.util.DOMBuilder;
 import org.apache.jackrabbit.core.value.InternalValue;
+import org.apache.jackrabbit.core.value.InternalValueFactory;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.query.qom.Operator;
+import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueConstraint;
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.PropertyType;
@@ -64,8 +67,8 @@
             throws IOException, RepositoryException {
         try {
             NodeTypeWriter writer = new NodeTypeWriter(registry);
-            for (int i = 0; i < types.length; i++) {
-                writer.addNodeTypeDef(types[i]);
+            for (NodeTypeDef type : types) {
+                writer.addNodeTypeDef(type);
             }
             writer.write(xml);
         } catch (ParserConfigurationException e) {
@@ -84,6 +87,8 @@
     /** The namespace resolver. */
     private final NamePathResolver resolver;
 
+    private final ValueFactoryQImpl factory;
+
     /**
      * Creates a node type definition file writer. The given namespace
      * registry is used for the XML namespace bindings.
@@ -99,15 +104,16 @@
         builder = new DOMBuilder(Constants.NODETYPES_ELEMENT);
 
         String[] prefixes = registry.getPrefixes();
-        for (int i = 0; i < prefixes.length; i++) {
-            if (!"".equals(prefixes[i])) {
-                String uri = registry.getURI(prefixes[i]);
-                builder.setAttribute("xmlns:" + prefixes[i], uri);
+        for (String prefix : prefixes) {
+            if (!"".equals(prefix)) {
+                String uri = registry.getURI(prefix);
+                builder.setAttribute("xmlns:" + prefix, uri);
             }
         }
 
         NamespaceResolver nsResolver = new AdditionalNamespaceResolver(registry);
         resolver = new DefaultNamePathResolver(nsResolver);
+        factory = new ValueFactoryQImpl(InternalValueFactory.getInstance(), resolver);
     }
 
     /**
@@ -150,24 +156,24 @@
         Name[] supertypes = def.getSupertypes();
         if (supertypes.length > 0) {
             builder.startElement(Constants.SUPERTYPES_ELEMENT);
-            for (int i = 0; i < supertypes.length; i++) {
+            for (Name supertype : supertypes) {
                 builder.addContentElement(
                         Constants.SUPERTYPE_ELEMENT,
-                        resolver.getJCRName(supertypes[i]));
+                        resolver.getJCRName(supertype));
             }
             builder.endElement();
         }
 
         // property definitions
         PropDef[] properties = def.getPropertyDefs();
-        for (int i = 0; i < properties.length; i++) {
-            addPropDef(properties[i]);
+        for (PropDef property : properties) {
+            addPropDef(property);
         }
 
         // child node definitions
         NodeDef[] nodes = def.getChildNodeDefs();
-        for (int i = 0; i < nodes.length; i++) {
-            addChildNodeDef(nodes[i]);
+        for (NodeDef node : nodes) {
+            addChildNodeDef(node);
         }
 
         builder.endElement();
@@ -241,13 +247,15 @@
                 PropertyType.nameFromValue(def.getRequiredType()));
 
         // value constraints
-        ValueConstraint[] constraints = def.getValueConstraints();
+        QValueConstraint[] constraints = def.getValueConstraints();
         if (constraints != null && constraints.length > 0) {
             builder.startElement(Constants.VALUECONSTRAINTS_ELEMENT);
-            for (int i = 0; i < constraints.length; i++) {
+            for (QValueConstraint constraint : constraints) {
+                ValueConstraint vc = ValueConstraint.create(
+                        def.getRequiredType(), constraint.getString());
                 builder.addContentElement(
                         Constants.VALUECONSTRAINT_ELEMENT,
-                        constraints[i].getDefinition(resolver));
+                        vc.getDefinition(resolver));
             }
             builder.endElement();
         }
@@ -256,10 +264,10 @@
         InternalValue[] defaults = def.getDefaultValues();
         if (defaults != null && defaults.length > 0) {
             builder.startElement(Constants.DEFAULTVALUES_ELEMENT);
-            for (int i = 0; i < defaults.length; i++) {
+            for (InternalValue v : defaults) {
                 builder.addContentElement(
                         Constants.DEFAULTVALUE_ELEMENT,
-                        defaults[i].toJCRValue(resolver).getString());
+                        factory.createValue(v).getString());
             }
             builder.endElement();
         }
@@ -306,10 +314,10 @@
         // required primary types
         Name[] requiredTypes = def.getRequiredPrimaryTypes();
         builder.startElement(Constants.REQUIREDPRIMARYTYPES_ELEMENT);
-        for (int i = 0; i < requiredTypes.length; i++) {
+        for (Name requiredType : requiredTypes) {
             builder.addContentElement(
                     Constants.REQUIREDPRIMARYTYPE_ELEMENT,
-                    resolver.getJCRName(requiredTypes[i]));
+                    resolver.getJCRName(requiredType));
         }
         builder.endElement();
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/DispatchAction.java Wed Jul  8 13:57:13 2009
@@ -34,13 +34,13 @@
      * <code>EventStates</code> are dispatched to these
      * <code>EventConsumer</code>s.
      */
-    private final Collection eventConsumers;
+    private final Collection<EventConsumer> eventConsumers;
 
     /**
      * Creates a new <code>DispatchAction</code> struct with
      * <code>eventStates</code> and <code>eventConsumers</code>.
      */
-    DispatchAction(EventStateCollection eventStates, Collection eventConsumers) {
+    DispatchAction(EventStateCollection eventStates, Collection<EventConsumer> eventConsumers) {
         this.eventStates = eventStates;
         this.eventConsumers = eventConsumers;
     }
@@ -60,7 +60,7 @@
      *
      * @return a <code>Collection</code> of {@link EventConsumer}s.
      */
-    Collection getEventConsumers() {
+    Collection<EventConsumer> getEventConsumers() {
         return eventConsumers;
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventConsumer.java Wed Jul  8 13:57:13 2009
@@ -74,7 +74,7 @@
      * <code>ItemId</code>s of denied <code>ItemState</code>s. The map uses the
      * <code>EventStateCollection</code> as the key to reference a deny Set.
      */
-    private final Map accessDenied = Collections.synchronizedMap(new WeakHashMap());
+    private final Map<EventStateCollection, Set<ItemId>> accessDenied = Collections.synchronizedMap(new WeakHashMap<EventStateCollection, Set<ItemId>>());
 
     /**
      * cached hash code value
@@ -137,10 +137,10 @@
      * @param events the collection of {@link EventState}s.
      */
     void prepareEvents(EventStateCollection events) {
-        Iterator it = events.iterator();
-        Set denied = null;
+        Iterator<EventState> it = events.iterator();
+        Set<ItemId> denied = null;
         while (it.hasNext()) {
-            EventState state = (EventState) it.next();
+            EventState state = it.next();
             if (state.getType() == Event.NODE_REMOVED
                     || state.getType() == Event.PROPERTY_REMOVED) {
 
@@ -160,7 +160,7 @@
                 }
                 if (!granted) {
                     if (denied == null) {
-                        denied = new HashSet();
+                        denied = new HashSet<ItemId>();
                     }
                     denied.add(targetId);
                 }
@@ -178,15 +178,15 @@
      * @param events       the collection of {@link EventState}s.
      * @param deletedItems Iterator of deleted <code>ItemState</code>s.
      */
-    void prepareDeleted(EventStateCollection events, Iterator deletedItems) {
-        Set denied = null;
-        Set deletedIds = new HashSet();
+    void prepareDeleted(EventStateCollection events, Iterator<ItemState> deletedItems) {
+        Set<ItemId> denied = null;
+        Set<ItemId> deletedIds = new HashSet<ItemId>();
         while (deletedItems.hasNext()) {
-            deletedIds.add(((ItemState) deletedItems.next()).getId());
+            deletedIds.add((deletedItems.next()).getId());
         }
 
-        for (Iterator it = events.iterator(); it.hasNext();) {
-            EventState evState = (EventState) it.next();
+        for (Iterator<EventState> it = events.iterator(); it.hasNext();) {
+            EventState evState = it.next();
             ItemId targetId = evState.getTargetId();
             if (deletedIds.contains(targetId)) {
                 // check read permission
@@ -198,7 +198,7 @@
                 }
                 if (!granted) {
                     if (denied == null) {
-                        denied = new HashSet();
+                        denied = new HashSet<ItemId>();
                     }
                     denied.add(targetId);
                 }
@@ -217,17 +217,17 @@
      */
     void consumeEvents(EventStateCollection events) throws RepositoryException {
         // Set of ItemIds of denied ItemStates
-        Set denied = (Set) accessDenied.remove(events);
+        Set<ItemId> denied = accessDenied.remove(events);
         // check permissions
-        for (Iterator it = events.iterator(); it.hasNext() && session.isLive();) {
-            EventState state = (EventState) it.next();
+        for (Iterator<EventState> it = events.iterator(); it.hasNext() && session.isLive();) {
+            EventState state = it.next();
             if (state.getType() == Event.NODE_ADDED
                     || state.getType() == Event.PROPERTY_ADDED
                     || state.getType() == Event.PROPERTY_CHANGED) {
                 ItemId targetId = state.getTargetId();
                 if (!canRead(state)) {
                     if (denied == null) {
-                        denied = new HashSet();
+                        denied = new HashSet<ItemId>();
                     }
                     denied.add(targetId);
                 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java Wed Jul  8 13:57:13 2009
@@ -148,7 +148,7 @@
             InternalValue value = (InternalValue) entry.getValue();
             String strValue = null;
             if (value != null) {
-                strValue = ValueFormat.getJCRValue(value, session, session.getValueFactory()).getString();
+                strValue = ValueFormat.getJCRString(value, session);
             }
             info.put(entry.getKey(), strValue);
         }
@@ -158,9 +158,9 @@
     //-----------------------------------------------------------< EventImpl >
 
     /**
-     * Returns the qualified path of this event.
+     * Returns the <code>Path</code> of this event.
      *
-     * @return qualified path
+     * @return path
      * @throws RepositoryException if the path can't be constructed
      */
     public Path getQPath() throws RepositoryException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventJournalImpl.java Wed Jul  8 13:57:13 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.observation;
 
-import java.util.Calendar;
 import java.util.List;
 import java.util.LinkedList;
 import java.util.NoSuchElementException;
@@ -177,11 +176,6 @@
         return next;
     }
 
-    public Calendar getDate() {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2086");
-    }
-
     //------------------------< RangeIterator >---------------------------------
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventStateCollection.java Wed Jul  8 13:57:13 2009
@@ -71,7 +71,7 @@
     /**
      * List of events
      */
-    private final List events = new ArrayList();
+    private final List<EventState> events = new ArrayList<EventState>();
 
     /**
      * Event dispatcher.
@@ -161,8 +161,8 @@
 
         // 1. modified items
 
-        for (Iterator it = changes.modifiedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
+        for (Iterator<ItemState> it = changes.modifiedStates(); it.hasNext();) {
+            ItemState state = it.next();
             if (state.isNode()) {
                 // node changed
                 // covers the following cases:
@@ -195,7 +195,7 @@
                     NodeId newParentId = n.getParentId();
                     if (newParentId != null && !oldParentId.equals(newParentId) &&
                             !n.isShareable()) {
-                        
+
                         // node moved
                         // generate node removed & node added event
                         NodeState oldParent;
@@ -208,7 +208,7 @@
                         }
 
                         NodeTypeImpl oldParentNodeType = getNodeType(oldParent, session);
-                        Set mixins = oldParent.getMixinTypeNames();
+                        Set<Name> mixins = oldParent.getMixinTypeNames();
                         Path newPath = getPath(n.getNodeId(), hmgr);
                         Path oldPath = getZombiePath(n.getNodeId(), hmgr);
                         events.add(EventState.childNodeRemoved(oldParentId,
@@ -248,8 +248,7 @@
                         if (parent != null) {
                             // check if node has been renamed
                             ChildNodeEntry moved = null;
-                            for (Iterator removedNodes = parent.getRemovedChildNodeEntries().iterator(); removedNodes.hasNext();) {
-                                ChildNodeEntry child = (ChildNodeEntry) removedNodes.next();
+                            for (ChildNodeEntry child : parent.getRemovedChildNodeEntries()) {
                                 if (child.getId().equals(n.getNodeId())) {
                                     // found node re-added with different name
                                     moved = child;
@@ -257,7 +256,7 @@
                             }
                             if (moved != null) {
                                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                                Set mixins = parent.getMixinTypeNames();
+                                Set<Name> mixins = parent.getMixinTypeNames();
                                 Path newPath = getPath(state.getId(), hmgr);
                                 Path parentPath = getParent(newPath);
                                 Path oldPath;
@@ -294,14 +293,13 @@
                 }
 
                 // check if child nodes of modified node state have been reordered
-                List reordered = n.getReorderedChildNodeEntries();
+                List<ChildNodeEntry> reordered = n.getReorderedChildNodeEntries();
                 NodeTypeImpl nodeType = getNodeType(n, session);
-                Set mixins = n.getMixinTypeNames();
+                Set<Name> mixins = n.getMixinTypeNames();
                 if (reordered.size() > 0) {
                     // create a node removed and a node added event for every
                     // reorder
-                    for (Iterator ro = reordered.iterator(); ro.hasNext();) {
-                        ChildNodeEntry child = (ChildNodeEntry) ro.next();
+                    for (ChildNodeEntry child : reordered) {
                         Path.Element addedElem = getPathElement(child);
                         Path parentPath = getPath(n.getNodeId(), hmgr);
                         // get removed index
@@ -320,13 +318,13 @@
                                 parentPath, child.getId(), addedElem,
                                 nodeType.getQName(), mixins, session));
 
-                        List cne = n.getChildNodeEntries();
+                        List<ChildNodeEntry> cne = n.getChildNodeEntries();
                         // index of the child node entry before which this
                         // child node entry was reordered
                         int idx = cne.indexOf(child) + 1;
                         Path.Element beforeElem = null;
                         if (idx < cne.size()) {
-                            beforeElem = getPathElement((ChildNodeEntry) cne.get(idx));
+                            beforeElem = getPathElement(cne.get(idx));
                         }
 
                         events.add(EventState.nodeReordered(n.getNodeId(),
@@ -343,7 +341,7 @@
                 Path path = getPath(state.getId(), hmgr);
                 NodeState parent = (NodeState) stateMgr.getItemState(state.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
+                Set<Name> mixins = parent.getMixinTypeNames();
                 events.add(EventState.propertyChanged(state.getParentId(),
                         getParent(path), path.getNameElement(),
                         nodeType.getQName(), mixins, session));
@@ -352,14 +350,14 @@
 
         // 2. removed items
 
-        for (Iterator it = changes.deletedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
+        for (Iterator<ItemState> it = changes.deletedStates(); it.hasNext();) {
+            ItemState state = it.next();
             if (state.isNode()) {
                 // node deleted
                 NodeState n = (NodeState) state;
                 NodeState parent = (NodeState) stateMgr.getItemState(n.getParentId());
                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
+                Set<Name> mixins = parent.getMixinTypeNames();
                 Path path = getZombiePath(state.getId(), hmgr);
                 events.add(EventState.childNodeRemoved(n.getParentId(),
                         getParent(path),
@@ -378,7 +376,7 @@
                     NodeState n = (NodeState) changes.get(state.getParentId());
                     // node state exists -> only property removed
                     NodeTypeImpl nodeType = getNodeType(n, session);
-                    Set mixins = n.getMixinTypeNames();
+                    Set<Name> mixins = n.getMixinTypeNames();
                     Path path = getZombiePath(state.getId(), hmgr);
                     events.add(EventState.propertyRemoved(state.getParentId(),
                             getParent(path),
@@ -394,8 +392,8 @@
 
         // 3. added items
 
-        for (Iterator it = changes.addedStates(); it.hasNext();) {
-            ItemState state = (ItemState) it.next();
+        for (Iterator<ItemState> it = changes.addedStates(); it.hasNext();) {
+            ItemState state = it.next();
             if (state.isNode()) {
                 // node created
                 NodeState n = (NodeState) state;
@@ -403,7 +401,7 @@
                 // the parent of an added item is always modified or new
                 NodeState parent = (NodeState) changes.get(parentId);
                 NodeTypeImpl nodeType = getNodeType(parent, session);
-                Set mixins = parent.getMixinTypeNames();
+                Set<Name> mixins = parent.getMixinTypeNames();
                 Path path = getPath(n.getNodeId(), hmgr);
                 events.add(EventState.childNodeAdded(parentId,
                         getParent(path),
@@ -419,7 +417,7 @@
                 // property created / set
                 NodeState n = (NodeState) changes.get(state.getParentId());
                 NodeTypeImpl nodeType = getNodeType(n, session);
-                Set mixins = n.getMixinTypeNames();
+                Set<Name> mixins = n.getMixinTypeNames();
                 Path path = getPath(state.getId(), hmgr);
                 events.add(EventState.propertyAdded(state.getParentId(),
                         getParent(path),
@@ -436,7 +434,7 @@
      *
      * @param c
      */
-    public void addAll(Collection c) {
+    public void addAll(Collection<EventState> c) {
         events.addAll(c);
     }
 
@@ -495,7 +493,7 @@
      *
      * @return an iterator over {@link EventState} instance.
      */
-    Iterator iterator() {
+    Iterator<EventState> iterator() {
         return events.iterator();
     }
 
@@ -503,7 +501,7 @@
      * Return the list of events.
      * @return list of events
      */
-    public List getEvents() {
+    public List<EventState> getEvents() {
         return Collections.unmodifiableList(events);
     }
 
@@ -540,8 +538,7 @@
             throws ItemStateException {
         if (n.isShareable()) {
             // check if a share was added or removed
-            for (Iterator added = n.getAddedShares().iterator(); added.hasNext(); ) {
-                NodeId parentId = (NodeId) added.next();
+            for (NodeId parentId : n.getAddedShares()) {
                 // ignore primary parent id
                 if (n.getParentId().equals(parentId)) {
                     continue;
@@ -565,8 +562,7 @@
                 es.setShareableNode(true);
                 events.add(es);
             }
-            for (Iterator removed = n.getRemovedShares().iterator(); removed.hasNext(); ) {
-                NodeId parentId = (NodeId) removed.next();
+            for (NodeId parentId : n.getRemovedShares()) {
                 // if this shareable node is removed, only create events for
                 // parent ids that are not primary
                 if (n.getParentId().equals(parentId)) {
@@ -765,15 +761,15 @@
     }
 
     /**
-     * Get the longest common path of all event state paths. 
-     * 
+     * Get the longest common path of all event state paths.
+     *
      * @return the longest common path
      */
     public String getCommonPath() {
         String common = null;
         try {
             for (int i = 0; i < events.size(); i++) {
-                EventState state = (EventState) events.get(i);
+                EventState state = events.get(i);
                 String s = session.getJCRPath(state.getParentPath());
                 if (common == null) {
                     common = s;

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/FilteredEventIterator.java Wed Jul  8 13:57:13 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.observation;
 
-import java.util.Calendar;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.Set;
@@ -60,7 +59,7 @@
     /**
      * Current position
      */
-    private long pos = 0;
+    private long pos;
 
     /**
      * The timestamp when the events occured.
@@ -126,11 +125,6 @@
         }
     }
 
-    public Calendar getDate() {
-        // TODO
-        throw new RuntimeException("Not implemented yet, see JCR-2086");
-    }
-
     /**
      * Always returns <code>-1</code>.
      *

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationDispatcher.java Wed Jul  8 13:57:13 2009
@@ -48,22 +48,22 @@
     /**
      * Currently active <code>EventConsumer</code>s for notification.
      */
-    private Set activeConsumers = new HashSet();
+    private Set<EventConsumer> activeConsumers = new HashSet<EventConsumer>();
 
     /**
      * Currently active synchronous <code>EventConsumer</code>s for notification.
      */
-    private Set synchronousConsumers = new HashSet();
+    private Set<EventConsumer> synchronousConsumers = new HashSet<EventConsumer>();
 
     /**
      * Set of <code>EventConsumer</code>s for read only Set access
      */
-    private Set readOnlyConsumers;
+    private Set<EventConsumer> readOnlyConsumers;
 
     /**
      * Set of synchronous <code>EventConsumer</code>s for read only Set access.
      */
-    private Set synchronousReadOnlyConsumers;
+    private Set<EventConsumer> synchronousReadOnlyConsumers;
 
     /**
      * synchronization monitor for listener changes
@@ -111,19 +111,19 @@
      *
      * @return <code>Set</code> of <code>EventConsumer</code>s.
      */
-    Set getAsynchronousConsumers() {
+    Set<EventConsumer> getAsynchronousConsumers() {
         synchronized (consumerChange) {
             if (readOnlyConsumers == null) {
-                readOnlyConsumers = Collections.unmodifiableSet(new HashSet(activeConsumers));
+                readOnlyConsumers = Collections.unmodifiableSet(new HashSet<EventConsumer>(activeConsumers));
             }
             return readOnlyConsumers;
         }
     }
 
-    Set getSynchronousConsumers() {
+    Set<EventConsumer> getSynchronousConsumers() {
         synchronized (consumerChange) {
             if (synchronousReadOnlyConsumers == null) {
-                synchronousReadOnlyConsumers = Collections.unmodifiableSet(new HashSet(synchronousConsumers));
+                synchronousReadOnlyConsumers = Collections.unmodifiableSet(new HashSet<EventConsumer>(synchronousConsumers));
             }
             return synchronousReadOnlyConsumers;
         }
@@ -139,8 +139,8 @@
 
             log.debug("got EventStateCollection");
             log.debug("event delivery to " + action.getEventConsumers().size() + " consumers started...");
-            for (Iterator it = action.getEventConsumers().iterator(); it.hasNext();) {
-                EventConsumer c = (EventConsumer) it.next();
+            for (Iterator<EventConsumer> it = action.getEventConsumers().iterator(); it.hasNext();) {
+                EventConsumer c = it.next();
                 try {
                     c.consumeEvents(action.getEventStates());
                 } catch (Throwable t) {
@@ -161,11 +161,10 @@
      * prepare the events for dispatching.
      */
     void prepareEvents(EventStateCollection events) {
-        Set consumers = new HashSet();
+        Set<EventConsumer> consumers = new HashSet<EventConsumer>();
         consumers.addAll(getSynchronousConsumers());
         consumers.addAll(getAsynchronousConsumers());
-        for (Iterator it = consumers.iterator(); it.hasNext();) {
-            EventConsumer c = (EventConsumer) it.next();
+        for (EventConsumer c : consumers) {
             c.prepareEvents(events);
         }
     }
@@ -174,11 +173,10 @@
      * {@inheritDoc}
      */
     void prepareDeleted(EventStateCollection events, ChangeLog changes) {
-        Set consumers = new HashSet();
+        Set<EventConsumer> consumers = new HashSet<EventConsumer>();
         consumers.addAll(getSynchronousConsumers());
         consumers.addAll(getAsynchronousConsumers());
-        for (Iterator it = consumers.iterator(); it.hasNext();) {
-            EventConsumer c = (EventConsumer) it.next();
+        for (EventConsumer c : consumers) {
             c.prepareDeleted(events, changes.deletedStates());
         }
     }
@@ -191,12 +189,11 @@
      */
     void dispatchEvents(EventStateCollection events) {
         // notify synchronous listeners
-        Set synchronous = getSynchronousConsumers();
+        Set<EventConsumer> synchronous = getSynchronousConsumers();
         if (log.isDebugEnabled()) {
             log.debug("notifying " + synchronous.size() + " synchronous listeners.");
         }
-        for (Iterator it = synchronous.iterator(); it.hasNext();) {
-            EventConsumer c = (EventConsumer) it.next();
+        for (EventConsumer c : synchronous) {
             try {
                 c.consumeEvents(events);
             } catch (Throwable t) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java Wed Jul  8 13:57:13 2009
@@ -244,6 +244,7 @@
      * @throws UnsupportedRepositoryOperationException if this repository does
      *          not support an event journal (cluster journal disabled).
      * @throws RepositoryException if another error occurs.
+     * @see ObservationManager#getEventJournal(int, String, boolean, String[], String[])
      */
     public EventJournal getEventJournal(
             int eventTypes, String absPath, boolean isDeep,

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java Wed Jul  8 13:57:13 2009
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.core.value.InternalValue;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.nodetype.NodeDefId;
 import org.apache.jackrabbit.core.nodetype.PropDefId;
@@ -608,76 +607,76 @@
             InternalValue val = values[i];
             switch (state.getType()) {
                 case PropertyType.BINARY:
-                    BLOBFileValue blobVal = val.getBLOBFileValue();
-                    if (InternalValue.USE_DATA_STORE && dataStore != null) {
-                        if (blobVal.isSmall()) {
-                            writeSmallBinary(out, blobVal, state, i);
-                        } else {
-                            out.writeInt(BINARY_IN_DATA_STORE);
-                            try {
+                    try {
+                        long size = val.getLength();
+                        if (dataStore != null) {
+                            int maxMemorySize = dataStore.getMinRecordLength() - 1;
+                            if (size < maxMemorySize) {
+                                writeSmallBinary(out, val, state, i);
+                            } else {
+                                out.writeInt(BINARY_IN_DATA_STORE);
                                 val.store(dataStore);
-                            } catch (RepositoryException e) {
-                                String msg = "Error while storing blob. id="
-                                    + state.getId() + " idx=" + i + " size=" + val.getBLOBFileValue().getLength();
-                                log.error(msg, e);
-                                throw new IOException(msg);
+                                out.writeUTF(val.toString());
                             }
-                            out.writeUTF(val.toString());
+                            break;
                         }
-                        break;
-                    }
-                    // special handling required for binary value:
-                    // spool binary value to file in blob store
-                    long size = blobVal.getLength();
-                    if (size < 0) {
-                        log.warn("Blob has negative size. Potential loss of data. "
-                                + "id={} idx={}", state.getId(), String.valueOf(i));
-                        out.writeInt(0);
-                        values[i] = InternalValue.create(new byte[0]);
-                        blobVal.discard();
-                    } else if (size > minBlobSize) {
-                        out.writeInt(BINARY_IN_BLOB_STORE);
-                        String blobId = state.getBlobId(i);
-                        if (blobId == null) {
-                            try {
-                                InputStream in = blobVal.getStream();
+                        // special handling required for binary value:
+                        // spool binary value to file in blob store
+                        if (size < 0) {
+                            log.warn("Blob has negative size. Potential loss of data. "
+                                    + "id={} idx={}", state.getId(), String.valueOf(i));
+                            out.writeInt(0);
+                            values[i] = InternalValue.create(new byte[0]);
+                            val.discard();
+                        } else if (size > minBlobSize) {
+                            out.writeInt(BINARY_IN_BLOB_STORE);
+                            String blobId = state.getBlobId(i);
+                            if (blobId == null) {
                                 try {
-                                    blobId = blobStore.createId(state.getId(), i);
-                                    blobStore.put(blobId, in, size);
-                                    state.setBlobId(blobId, i);
-                                } finally {
-                                    IOUtils.closeQuietly(in);
+                                    InputStream in = val.getStream();
+                                    try {
+                                        blobId = blobStore.createId(state.getId(), i);
+                                        blobStore.put(blobId, in, size);
+                                        state.setBlobId(blobId, i);
+                                    } finally {
+                                        IOUtils.closeQuietly(in);
+                                    }
+                                } catch (Exception e) {
+                                    String msg = "Error while storing blob. id="
+                                            + state.getId() + " idx=" + i + " size=" + size;
+                                    log.error(msg, e);
+                                    throw new IOException(msg);
                                 }
-                            } catch (Exception e) {
-                                String msg = "Error while storing blob. id="
-                                        + state.getId() + " idx=" + i + " size=" + size;
-                                log.error(msg, e);
-                                throw new IOException(msg);
-                            }
-                            try {
-                                // replace value instance with value
-                                // backed by resource in blob store and delete temp file
-                                if (blobStore instanceof ResourceBasedBLOBStore) {
-                                    values[i] = InternalValue.create(((ResourceBasedBLOBStore) blobStore).getResource(blobId));
-                                } else {
-                                    values[i] = InternalValue.create(blobStore.get(blobId));
+                                try {
+                                    // replace value instance with value
+                                    // backed by resource in blob store and delete temp file
+                                    if (blobStore instanceof ResourceBasedBLOBStore) {
+                                        values[i] = InternalValue.create(((ResourceBasedBLOBStore) blobStore).getResource(blobId));
+                                    } else {
+                                        values[i] = InternalValue.create(blobStore.get(blobId));
+                                    }
+                                } catch (Exception e) {
+                                    log.error("Error while reloading blob. truncating. id="
+                                            + state.getId() + " idx=" + i + " size=" + size, e);
+                                    values[i] = InternalValue.create(new byte[0]);
                                 }
-                            } catch (Exception e) {
-                                log.error("Error while reloading blob. truncating. id="
-                                        + state.getId() + " idx=" + i + " size=" + size, e);
-                                values[i] = InternalValue.create(new byte[0]);
+                                val.discard();
                             }
-                            blobVal.discard();
+                            // store id of blob as property value
+                            out.writeUTF(blobId);   // value
+                        } else {
+                            // delete evt. blob
+                            byte[] data = writeSmallBinary(out, val, state, i);
+                            // replace value instance with value
+                            // backed by resource in blob store and delete temp file
+                            values[i] = InternalValue.create(data);
+                            val.discard();
                         }
-                        // store id of blob as property value
-                        out.writeUTF(blobId);   // value
-                    } else {
-                        // delete evt. blob
-                        byte[] data = writeSmallBinary(out, blobVal, state, i);
-                        // replace value instance with value
-                        // backed by resource in blob store and delete temp file
-                        values[i] = InternalValue.create(data);
-                        blobVal.discard();
+                    } catch (RepositoryException e) {
+                        String msg = "Error while storing blob. id="
+                            + state.getId() + " idx=" + i + " value=" + val;
+                        log.error(msg, e);
+                        throw new IOException(msg);
                     }
                     break;
                 case PropertyType.DOUBLE:
@@ -713,7 +712,12 @@
                     }
                     break;
                 case PropertyType.NAME:
-                    writeQName(out, val.getQName());
+                    try {
+                        writeQName(out, val.getName());
+                    } catch (RepositoryException e) {
+                        // should never occur
+                        throw new IOException("Unexpected error while writing NAME value.");
+                    }
                     break;
                 case PropertyType.WEAKREFERENCE:
                 case PropertyType.REFERENCE:
@@ -739,25 +743,25 @@
      * @return the data
      * @throws IOException if the data could not be read
      */
-    private byte[] writeSmallBinary(DataOutputStream out, BLOBFileValue blobVal, NodePropBundle.PropertyEntry state, int i) throws IOException {
-        int size = (int) blobVal.getLength();
-        out.writeInt(size);
-        byte[] data = new byte[size];
+    private byte[] writeSmallBinary(DataOutputStream out, InternalValue value, NodePropBundle.PropertyEntry state, int i) throws IOException {
         try {
+            int size = (int) value.getLength();
+            out.writeInt(size);
+            byte[] data = new byte[size];
             DataInputStream in =
-                new DataInputStream(blobVal.getStream());
+                new DataInputStream(value.getStream());
             try {
                 in.readFully(data);
             } finally {
                 IOUtils.closeQuietly(in);
             }
+            out.write(data, 0, data.length);
+            return data;
         } catch (Exception e) {
             String msg = "Error while storing blob. id="
-                    + state.getId() + " idx=" + i + " size=" + size;
+                    + state.getId() + " idx=" + i + " value=" + value;
             log.error(msg, e);
             throw new IOException(msg);
         }
-        out.write(data, 0, data.length);
-        return data;
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java Wed Jul  8 13:57:13 2009
@@ -34,7 +34,6 @@
 import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
@@ -534,9 +533,7 @@
                 InternalValue val = values[i];
                 if (val != null) {
                     if (val.getType() == PropertyType.BINARY) {
-                        BLOBFileValue blobVal = val.getBLOBFileValue();
-                        // delete internal resource representation of BLOB value
-                        blobVal.delete(true);
+                        val.deleteBinaryResource();
                         // also remove from BLOBStore
                         String blobId = blobStore.createId(state.getPropertyId(), i);
                         try {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/mem/InMemPersistenceManager.java Wed Jul  8 13:57:13 2009
@@ -34,13 +34,11 @@
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore;
 import org.apache.jackrabbit.core.persistence.util.Serializer;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.PropertyType;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.ByteArrayInputStream;
@@ -49,7 +47,6 @@
 import java.io.DataOutputStream;
 import java.io.File;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
@@ -74,8 +71,8 @@
 
     protected boolean initialized;
 
-    protected Map stateStore;
-    protected Map refsStore;
+    protected Map<ItemId, byte[]> stateStore;
+    protected Map<NodeReferencesId, byte[]> refsStore;
 
     // initial size of buffer used to serialize objects
     protected static final int INITIAL_BUFFER_SIZE = 1024;
@@ -151,15 +148,15 @@
         StringBuffer sb = new StringBuffer();
         char[] chars = parentUUID.toCharArray();
         int cnt = 0;
-        for (int i = 0; i < chars.length; i++) {
-            if (chars[i] == '-') {
+        for (char ch : chars) {
+            if (ch == '-') {
                 continue;
             }
             //if (cnt > 0 && cnt % 4 == 0) {
             if (cnt == 2 || cnt == 4) {
                 sb.append(FileSystem.SEPARATOR_CHAR);
             }
-            sb.append(chars[i]);
+            sb.append(ch);
             cnt++;
         }
         sb.append(FileSystem.SEPARATOR_CHAR);
@@ -217,7 +214,7 @@
             int n = in.readInt();   // number of entries
             while (n-- > 0) {
                 String s = in.readUTF();    // target id
-                NodeReferencesId id = (NodeReferencesId) NodeReferencesId.valueOf(s);
+                NodeReferencesId id = NodeReferencesId.valueOf(s);
                 int length = in.readInt();  // data length
                 byte[] data = new byte[length];
                 in.readFully(data);  // data
@@ -245,16 +242,14 @@
 
             out.writeInt(stateStore.size());    // number of entries
             // entries
-            Iterator iterKeys = stateStore.keySet().iterator();
-            while (iterKeys.hasNext()) {
-                ItemId id = (ItemId) iterKeys.next();
+            for (ItemId id : stateStore.keySet()) {
                 if (id.denotesNode()) {
                     out.writeByte(NODE_ENTRY);  // entry type
                 } else {
                     out.writeByte(PROP_ENTRY);  // entry type
                 }
                 out.writeUTF(id.toString());    // id
-                byte[] data = (byte[]) stateStore.get(id);
+                byte[] data = stateStore.get(id);
                 out.writeInt(data.length);  // data length
                 out.write(data);    // data
             }
@@ -271,11 +266,9 @@
         try {
             out.writeInt(refsStore.size()); // number of entries
             // entries
-            Iterator iterKeys = refsStore.keySet().iterator();
-            while (iterKeys.hasNext()) {
-                NodeReferencesId id = (NodeReferencesId) iterKeys.next();
+            for (NodeReferencesId id : refsStore.keySet()) {
                 out.writeUTF(id.toString());    // target id
-                byte[] data = (byte[]) refsStore.get(id);
+                byte[] data = refsStore.get(id);
                 out.writeInt(data.length);  // data length
                 out.write(data);    // data
             }
@@ -293,8 +286,8 @@
             throw new IllegalStateException("already initialized");
         }
 
-        stateStore = new HashMap(initialCapacity, loadFactor);
-        refsStore = new HashMap(initialCapacity, loadFactor);
+        stateStore = new HashMap<ItemId, byte[]>(initialCapacity, loadFactor);
+        refsStore = new HashMap<NodeReferencesId, byte[]>(initialCapacity, loadFactor);
 
         wspFS = context.getFileSystem();
 
@@ -332,12 +325,12 @@
                 // clear out blob store
                 try {
                     String[] folders = blobFS.listFolders("/");
-                    for (int i = 0; i < folders.length; i++) {
-                        blobFS.deleteFolder(folders[i]);
+                    for (String folder: folders) {
+                        blobFS.deleteFolder(folder);
                     }
                     String[] files = blobFS.listFiles("/");
-                    for (int i = 0; i < files.length; i++) {
-                        blobFS.deleteFile(files[i]);
+                    for (String file : files) {
+                        blobFS.deleteFile(file);
                     }
                 } catch (Exception e) {
                     // ignore
@@ -368,7 +361,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        byte[] data = (byte[]) stateStore.get(id);
+        byte[] data = stateStore.get(id);
         if (data == null) {
             throw new NoSuchItemStateException(id.toString());
         }
@@ -395,7 +388,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        byte[] data = (byte[]) stateStore.get(id);
+        byte[] data = stateStore.get(id);
         if (data == null) {
             throw new NoSuchItemStateException(id.toString());
         }
@@ -485,14 +478,9 @@
         // delete binary values (stored as files)
         InternalValue[] values = state.getValues();
         if (values != null) {
-            for (int i = 0; i < values.length; i++) {
-                InternalValue val = values[i];
+            for (InternalValue val : values) {
                 if (val != null) {
-                    if (val.getType() == PropertyType.BINARY) {
-                        BLOBFileValue blobVal = val.getBLOBFileValue();
-                        // delete blob file and prune empty parent folders
-                        blobVal.delete(true);
-                    }
+                    val.deleteBinaryResource();
                 }
             }
         }
@@ -511,7 +499,7 @@
             throw new IllegalStateException("not initialized");
         }
 
-        byte[] data = (byte[]) refsStore.get(id);
+        byte[] data = refsStore.get(id);
         if (data == null) {
             throw new NoSuchItemStateException(id.toString());
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/obj/ObjectPersistenceManager.java Wed Jul  8 13:57:13 2009
@@ -34,12 +34,10 @@
 import org.apache.jackrabbit.core.state.NodeReferencesId;
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.PropertyType;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -410,11 +408,7 @@
             for (int i = 0; i < values.length; i++) {
                 InternalValue val = values[i];
                 if (val != null) {
-                    if (val.getType() == PropertyType.BINARY) {
-                        BLOBFileValue blobVal = val.getBLOBFileValue();
-                        // delete blob file and prune empty parent folders
-                        blobVal.delete(true);
-                    }
+                    val.deleteBinaryResource();
                 }
             }
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BLOBStore.java Wed Jul  8 13:57:13 2009
@@ -24,6 +24,8 @@
  * <code>BLOBStore</code> represents an abstract store for binary property
  * values (BLOBs).
  *
+ * @deprecated the DataStore should be used instead
+ *
  * @see ResourceBasedBLOBStore
  */
 public interface BLOBStore {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/FileSystemBLOBStore.java Wed Jul  8 13:57:13 2009
@@ -28,6 +28,8 @@
 /**
  * <code>FileSystemBLOBStore</code> is a <code>ResourceBasedBLOBStore</code>
  * implementation that stores BLOB data in a <code>FileSystem</code>.
+ *
+ * @deprecated the FileDataStore should be used instead
  */
 public class FileSystemBLOBStore implements ResourceBasedBLOBStore {
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/ResourceBasedBLOBStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/ResourceBasedBLOBStore.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/ResourceBasedBLOBStore.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/ResourceBasedBLOBStore.java Wed Jul  8 13:57:13 2009
@@ -21,6 +21,8 @@
 /**
  * <code>ResourceBasedBLOBStore</code> extends the <code>BLOBStore</code>
  * interface with the method {@link #getResource(String)}
+ *
+ * @deprecated the DataStore should be used instead
  */
 public interface ResourceBasedBLOBStore extends BLOBStore {
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java Wed Jul  8 13:57:13 2009
@@ -26,7 +26,6 @@
 import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.uuid.UUID;
@@ -97,14 +96,14 @@
         c = state.getPropertyNames();
         out.writeInt(c.size()); // count
         for (Iterator<Name> iter = c.iterator(); iter.hasNext();) {
-            Name propName = (Name) iter.next();
+            Name propName = iter.next();
             out.writeUTF(propName.toString());   // name
         }
         // child nodes (list of name/uuid pairs)
         Collection<ChildNodeEntry> collChildren = state.getChildNodeEntries();
         out.writeInt(collChildren.size()); // count
         for (Iterator<ChildNodeEntry> iter = collChildren.iterator(); iter.hasNext();) {
-            ChildNodeEntry entry = (ChildNodeEntry) iter.next();
+            ChildNodeEntry entry = iter.next();
             out.writeUTF(entry.getName().toString());   // name
             out.write(entry.getId().getUUID().getRawBytes());    // uuid
         }
@@ -196,11 +195,10 @@
             if (state.getType() == PropertyType.BINARY) {
                 // special handling required for binary value:
                 // put binary value in BLOB store
-                BLOBFileValue blobVal = val.getBLOBFileValue();
-                InputStream in = blobVal.getStream();
+                InputStream in = val.getStream();
                 String blobId = blobStore.createId(state.getPropertyId(), i);
                 try {
-                    blobStore.put(blobId, in, blobVal.getLength());
+                    blobStore.put(blobId, in, val.getLength());
                 } finally {
                     IOUtils.closeQuietly(in);
                 }
@@ -223,7 +221,7 @@
                         IOUtils.closeQuietly(in);
                     }
                 }
-                blobVal.discard();
+                val.discard();
             } else {
                 /**
                  * because writeUTF(String) has a size limit of 65k,

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java Wed Jul  8 13:57:13 2009
@@ -39,7 +39,6 @@
 import org.apache.jackrabbit.core.persistence.util.FileSystemBLOBStore;
 import org.apache.jackrabbit.core.persistence.util.ResourceBasedBLOBStore;
 import org.apache.jackrabbit.core.util.DOMWalker;
-import org.apache.jackrabbit.core.value.BLOBFileValue;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NameFactory;
@@ -672,11 +671,10 @@
                             if (type == PropertyType.BINARY) {
                                 // special handling required for binary value:
                                 // put binary value in BLOB store
-                                BLOBFileValue blobVal = val.getBLOBFileValue();
-                                InputStream in = blobVal.getStream();
+                                InputStream in = val.getStream();
                                 String blobId = blobStore.createId(state.getPropertyId(), i);
                                 try {
-                                    blobStore.put(blobId, in, blobVal.getLength());
+                                    blobStore.put(blobId, in, val.getLength());
                                 } finally {
                                     IOUtils.closeQuietly(in);
                                 }
@@ -703,7 +701,7 @@
                                         }
                                     }
                                 }
-                                blobVal.discard();
+                                val.discard();
                             } else {
                                 writer.write(Text.encodeIllegalXMLCharacters(val.toString()));
                             }
@@ -760,11 +758,7 @@
             for (int i = 0; i < values.length; i++) {
                 InternalValue val = values[i];
                 if (val != null) {
-                    if (val.getType() == PropertyType.BINARY) {
-                        BLOBFileValue blobVal = val.getBLOBFileValue();
-                        // delete blob file and prune empty parent folders
-                        blobVal.delete(true);
-                    }
+                    val.deleteBinaryResource();
                 }
             }
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/AbstractQueryImpl.java Wed Jul  8 13:57:13 2009
@@ -17,13 +17,11 @@
 package org.apache.jackrabbit.core.query;
 
 import javax.jcr.Node;
-import javax.jcr.RepositoryException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
 
 /**
  * Defines common initialization methods for all query implementations.
@@ -38,6 +36,8 @@
      * @param handler   the query handler of the search index.
      * @param statement the query statement.
      * @param language  the syntax of the query statement.
+     * @param node      a nt:query node where the query was read from or
+     *                  <code>null</code> if it is not a stored query.
      * @throws InvalidQueryException if the query statement is invalid according
      *                               to the specified <code>language</code>.
      */
@@ -45,39 +45,6 @@
                               ItemManager itemMgr,
                               QueryHandler handler,
                               String statement,
-                              String language) throws InvalidQueryException;
-
-    /**
-     * Initializes a query instance from a nt:query node.
-     *
-     * @param session the session of the user executing this query.
-     * @param itemMgr the item manager of the session executing this query.
-     * @param handler the query handler of the search index.
-     * @param node    a node of type <code>nt:query</code>.
-     * @throws InvalidQueryException If <code>node</code> is not a valid persisted query
-     *                               (that is, a node of type <code>nt:query</code>).
-     * @throws RepositoryException   if another error occurs
-     */
-    public abstract void init(SessionImpl session,
-                              ItemManager itemMgr,
-                              QueryHandler handler,
-                              Node node)
-            throws InvalidQueryException, RepositoryException;
-
-    /**
-     * Initializes a query instance from a query object model.
-     *
-     * @param session  the session of the user executing this query.
-     * @param itemMgr  the item manager of the session executing this query.
-     * @param handler  the query handler of the search index.
-     * @param qomTree  the query object model tree.
-     * @param language the original query syntax from where the JQOM was
-     *                 created.
-     * @throws RepositoryException if another error occurs
-     */
-    public abstract void init(SessionImpl session,
-                              ItemManager itemMgr,
-                              QueryHandler handler,
-                              QueryObjectModelTree qomTree,
-                              String language) throws RepositoryException;
+                              String language,
+                              Node node) throws InvalidQueryException;
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java?rev=792142&r1=792141&r2=792142&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandler.java Wed Jul  8 13:57:13 2009
@@ -131,5 +131,17 @@
      * @return the name of the query class to use.
      */
     String getQueryClass();
-    
+
+    /**
+     * Returns the ids of the nodes that refer to the node with <code>id</code>
+     * by weak references.
+     *
+     * @param id the id of the target node.
+     * @return the ids of the referring nodes.
+     * @throws RepositoryException if an error occurs.
+     * @throws IOException         if an error occurs while reading from the
+     *                             index.
+     */
+    public Iterable<NodeId> getWeaklyReferringNodes(NodeId id)
+            throws RepositoryException, IOException;
 }



Mime
View raw message