jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r785545 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jackrabbit-jcr2s...
Date Wed, 17 Jun 2009 10:40:34 GMT
Author: angela
Date: Wed Jun 17 10:40:34 2009
New Revision: 785545

URL: http://svn.apache.org/viewvc?rev=785545&view=rev
Log:
JCR-2152: ValueFormat should provide method getJCRString

-> replace usage of ValueFormat#getJCRValue where only String is used.


Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/FilteredEventIterator.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
Wed Jun 17 10:40:34 2009
@@ -189,8 +189,8 @@
         switch (value.getType()) {
             case PropertyType.NAME:
             case PropertyType.PATH:
-                Value jcrValue = ValueFormat.getJCRValue(value, session, session.getValueFactory());
-                length = jcrValue.getString().length();
+                String str = ValueFormat.getJCRString(value, session);
+                length = str.length();
                 break;
             default:
                 length = value.getLength();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
Wed Jun 17 10:40:34 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);
         }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
Wed Jun 17 10:40:34 2009
@@ -431,8 +431,8 @@
         switch (value.getType()) {
             case PropertyType.NAME:
             case PropertyType.PATH:
-                Value jcrValue = ValueFormat.getJCRValue(value, session.getNamePathResolver(),
session.getJcrValueFactory());
-                length = jcrValue.getString().length();
+                String jcrString = ValueFormat.getJCRString(value, session.getNamePathResolver());
+                length = jcrString.length();
                 break;
             default:
                 length = value.getLength();

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java
Wed Jun 17 10:40:34 2009
@@ -585,6 +585,6 @@
      * @throws RepositoryException
      */
     protected ObservationManager createObservationManager(NamePathResolver resolver, NodeTypeRegistry
ntRegistry) throws RepositoryException {
-        return new ObservationManagerImpl(wspManager, resolver, ntRegistry, session.getValueFactory());
+        return new ObservationManagerImpl(wspManager, resolver, ntRegistry);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/EventImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/EventImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/EventImpl.java
Wed Jun 17 10:40:34 2009
@@ -32,7 +32,6 @@
 import org.slf4j.Logger;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.ValueFactory;
 import javax.jcr.observation.Event;
 
 /**
@@ -52,11 +51,6 @@
     private final NamePathResolver resolver;
 
     /**
-     * The value factory of the session that created this event iterator.
-     */
-    private final ValueFactory valueFactory;
-
-    /**
      * The IdFactory
      */
     private final IdFactory idFactory;
@@ -77,14 +71,12 @@
      *
      * @param event   the underlying SPI <code>Event</code>.
      * @param resolver
-     * @param valueFactory
      * @param idFactory
      */
     EventImpl(org.apache.jackrabbit.spi.Event event,
-              NamePathResolver resolver, ValueFactory valueFactory, IdFactory idFactory)
{
+              NamePathResolver resolver, IdFactory idFactory) {
         this.event = event;
         this.resolver = resolver;
-        this.valueFactory = valueFactory;
         this.idFactory = idFactory;
     }
 
@@ -134,7 +126,7 @@
             QValue value = infos.get(key);
             String strValue = null;
             if (value != null) {
-                strValue = ValueFormat.getJCRValue(value, resolver, valueFactory).getString();
+                strValue = ValueFormat.getJCRString(value, resolver);
             }
             jcrInfo.put(resolver.getJCRName(key), strValue);
         }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/FilteredEventIterator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/FilteredEventIterator.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/FilteredEventIterator.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/FilteredEventIterator.java
Wed Jun 17 10:40:34 2009
@@ -21,7 +21,6 @@
 
 import javax.jcr.observation.Event;
 import javax.jcr.observation.EventIterator;
-import javax.jcr.ValueFactory;
 
 import org.apache.jackrabbit.spi.EventBundle;
 import org.apache.jackrabbit.spi.EventFilter;
@@ -61,11 +60,6 @@
     private final NamePathResolver resolver;
 
     /**
-     * The value factory of the session that created this event iterator.
-     */
-    private final ValueFactory valueFactory;
-
-    /**
      * The IdFactory
      */
     private final IdFactory idFactory;
@@ -88,19 +82,16 @@
      * @param filter     only event that pass the filter will be dispatched to
  *                   the event listener.
      * @param resolver
-     * @param valueFactory
      * @param idFactory
      */
     public FilteredEventIterator(EventBundle events,
                                  EventFilter filter,
                                  NamePathResolver resolver,
-                                 ValueFactory valueFactory,
                                  IdFactory idFactory) {
         this.actualEvents = events.getEvents();
         this.filter = filter;
         this.isLocal = events.isLocal();
         this.resolver = resolver;
-        this.valueFactory = valueFactory;
         this.idFactory = idFactory;
         fetchNext();
     }
@@ -187,7 +178,7 @@
         next = null;
         while (next == null && actualEvents.hasNext()) {
             event = (org.apache.jackrabbit.spi.Event) actualEvents.next();
-            next = filter.accept(event, isLocal) ? new EventImpl(event, resolver, valueFactory,
idFactory) : null;
+            next = filter.accept(event, isLocal) ? new EventImpl(event, resolver, idFactory)
: null;
         }
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/observation/ObservationManagerImpl.java
Wed Jun 17 10:40:34 2009
@@ -25,7 +25,6 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.ValueFactory;
 import javax.jcr.observation.EventJournal;
 import javax.jcr.observation.EventListener;
 import javax.jcr.observation.EventListenerIterator;
@@ -65,12 +64,6 @@
     private final NamePathResolver resolver;
 
     /**
-     * The ValueFactory associated with the session this observation
-     * manager belongs to.
-     */
-    private final ValueFactory valueFactory;
-
-    /**
      * The <code>NodeTypeRegistry</code> of the session.
      */
     private final NodeTypeRegistry ntRegistry;
@@ -93,11 +86,10 @@
      * @param valueFactory
      */
     public ObservationManagerImpl(WorkspaceManager wspManager, NamePathResolver resolver,
-                                  NodeTypeRegistry ntRegistry, ValueFactory valueFactory)
{
+                                  NodeTypeRegistry ntRegistry) {
         this.wspManager = wspManager;
         this.resolver = resolver;
         this.ntRegistry = ntRegistry;
-        this.valueFactory = valueFactory;
     }
 
     /**
@@ -221,7 +213,7 @@
             Map.Entry entry = (Map.Entry) it.next();
             EventListener listener = (EventListener) entry.getKey();
             EventFilter filter = (EventFilter) entry.getValue();
-            FilteredEventIterator eventIter = new FilteredEventIterator(eventBundle, filter,
resolver, valueFactory, wspManager.getIdFactory());
+            FilteredEventIterator eventIter = new FilteredEventIterator(eventBundle, filter,
resolver, wspManager.getIdFactory());
             if (eventIter.hasNext()) {
                 try {
                     listener.onEvent(eventIter);

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefWriter.java
Wed Jun 17 10:40:34 2009
@@ -55,6 +55,8 @@
  */
 public class CompactNodeTypeDefWriter {
 
+    // TODO: valueFactory not needed any more -> remove from constructor and write calls...
+
     /**
      * the indention string
      */
@@ -71,11 +73,6 @@
     private final NamePathResolver npResolver;
 
     /**
-     * the current value factory
-     */
-    private final ValueFactory valueFactory;
-
-    /**
      * the underlying writer
      */
     private Writer out;
@@ -116,7 +113,6 @@
             ValueFactory valueFactory, boolean includeNS) {
         this.resolver = r;
         this.npResolver = npResolver;
-        this.valueFactory = valueFactory;
         if (includeNS) {
             this.out = new StringWriter();
             this.nsWriter = out;
@@ -332,7 +328,7 @@
 
             try {
                 QValue qv = QValueFactoryImpl.getInstance().create(vc, type);
-                vc = ValueFormat.getJCRValue(qv, npResolver, valueFactory).getString();
+                vc = ValueFormat.getJCRString(qv, npResolver);
             }
             catch (RepositoryException e) {
                 // ignore -> return unconverted constraint

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/value/ValueFormatTest.java
Wed Jun 17 10:40:34 2009
@@ -28,6 +28,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.QValue;
@@ -125,4 +126,25 @@
         assertEquals(qv, ValueFormat.getQValue(v, resolver, qvFactory));
         assertEquals(qv, ValueFormat.getQValue(reference, PropertyType.WEAKREFERENCE, resolver,
qvFactory));        
     }
+
+    public void testGetJCRString() throws RepositoryException, URISyntaxException {
+        List<QValue> qvs = new ArrayList();
+
+        String reference = UUID.randomUUID().toString();
+        qvs.add(qvFactory.create(reference, PropertyType.WEAKREFERENCE));
+        qvs.add(qvFactory.create(reference, PropertyType.REFERENCE));
+        qvs.add(qvFactory.create("anyString", PropertyType.STRING));
+        qvs.add(qvFactory.create(true));
+        qvs.add(qvFactory.create(12345));
+        qvs.add(qvFactory.create(12345.7889));
+        qvs.add(qvFactory.create(new URI("http://jackrabbit.apache.org")));
+        qvs.add(qvFactory.create(new BigDecimal(Double.MIN_VALUE)));
+        qvs.add(qvFactory.create(new byte[] {'a','b','c'}));
+        qvs.add(qvFactory.create(NameConstants.JCR_ACTIVITIES));
+        qvs.add(ValueFormat.getQValue("/a/b/c", PropertyType.PATH, resolver, qvFactory));
+
+        for (QValue qv : qvs) {
+            assertEquals(ValueFormat.getJCRValue(qv, resolver, vFactory).getString(), ValueFormat.getJCRString(qv,
resolver));
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=785545&r1=785544&r2=785545&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Wed Jun 17 10:40:34 2009
@@ -2448,15 +2448,15 @@
                 switch (type) {
                     case PropertyType.NAME:
                     case PropertyType.PATH:
-                        Value v = ValueFormat.getJCRValue(value, resolver, valueFactory);
-                        ent = new StringRequestEntity(v.getString(), contentType, "UTF-8");
+                        String str = ValueFormat.getJCRString(value, resolver);
+                        ent = new StringRequestEntity(str, contentType, "UTF-8");
                         break;
                     case PropertyType.BINARY:
                         in = value.getStream();
                         ent = new InputStreamRequestEntity(in, contentType);
                         break;
                     default:
-                        String str = value.getString();
+                        str = value.getString();
                         ent = new StringRequestEntity(str, contentType, "UTF-8");
                         break;
                 }



Mime
View raw message