jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1401331 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ oak-jcr/src/main/java/org/apac...
Date Tue, 23 Oct 2012 16:02:22 GMT
Author: angela
Date: Tue Oct 23 16:02:22 2012
New Revision: 1401331

URL: http://svn.apache.org/viewvc?rev=1401331&view=rev
Log:
OAK-392 : Review ContentSession#createBlob

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/BlobFactory.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/BlobFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/BlobFactory.java?rev=1401331&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/BlobFactory.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/BlobFactory.java
Tue Oct 23 16:02:22 2012
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.api;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * BlobFactory... TODO
+ */
+public interface BlobFactory {
+
+    /**
+     * Create a {@link Blob} from the given input stream. The input stream
+     * is closed after this method returns.
+     * @param inputStream  The input stream for the {@code Blob}
+     * @return  The {@code Blob} representing {@code inputStream}
+     * @throws java.io.IOException  If an error occurs while reading from the stream
+     */
+    Blob createBlob(InputStream inputStream) throws IOException;
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java?rev=1401331&r1=1401330&r2=1401331&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/ContentSession.java
Tue Oct 23 16:02:22 2012
@@ -17,9 +17,6 @@
 package org.apache.jackrabbit.oak.api;
 
 import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-
 import javax.annotation.Nonnull;
 
 /**
@@ -84,13 +81,4 @@ public interface ContentSession extends 
      */
     @Nonnull
     Root getLatestRoot();
-
-    /**
-     * Create a {@link Blob} from the given input stream. The input stream
-     * is closed after this method returns.
-     * @param inputStream  The input stream for the {@code Blob}
-     * @return  The {@code Blob} representing {@code inputStream}
-     * @throws IOException  If an error occurs while reading from the stream
-     */
-    Blob createBlob(InputStream inputStream) throws IOException;
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java?rev=1401331&r1=1401330&r2=1401331&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java Tue
Oct 23 16:02:22 2012
@@ -132,4 +132,11 @@ public interface Root {
     @Nonnull
     SessionQueryEngine getQueryEngine();
 
+    /**
+     * Returns the blob factory. TODO: specify life-cycle of that factory....
+     *
+     * @return the blob factory.
+     */
+    @Nonnull
+    BlobFactory getBlobFactory();
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java?rev=1401331&r1=1401330&r2=1401331&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
Tue Oct 23 16:02:22 2012
@@ -17,14 +17,11 @@
 package org.apache.jackrabbit.oak.core;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Set;
-
 import javax.annotation.Nonnull;
 import javax.security.auth.login.LoginException;
 
 import org.apache.jackrabbit.oak.api.AuthInfo;
-import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.spi.commit.ConflictHandler;
@@ -103,12 +100,6 @@ class ContentSessionImpl implements Cont
         return root;
     }
 
-    @Override
-    public Blob createBlob(InputStream inputStream) throws IOException {
-        checkLive();
-        return store.createBlob(inputStream);
-    }
-
     //-----------------------------------------------------------< Closable >---
     @Override
     public synchronized void close() throws IOException {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1401331&r1=1401330&r2=1401331&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Tue Oct 23 16:02:22 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -26,6 +28,8 @@ import java.util.List;
 import javax.annotation.Nonnull;
 import javax.security.auth.Subject;
 
+import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.api.BlobFactory;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.SessionQueryEngine;
@@ -280,6 +284,18 @@ public class RootImpl implements Root {
         return new SessionQueryEngineImpl(store, indexProvider);
     }
 
+    @Nonnull
+    @Override
+    public BlobFactory getBlobFactory() {
+        return new BlobFactory() {
+            @Override
+            public Blob createBlob(InputStream inputStream) throws IOException {
+                checkLive();
+                return store.createBlob(inputStream);
+            }
+        };
+    }
+
     //-----------------------------------------------------------< internal >---
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java?rev=1401331&r1=1401330&r2=1401331&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueFactoryImpl.java
Tue Oct 23 16:02:22 2012
@@ -23,7 +23,6 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Calendar;
 import java.util.List;
-
 import javax.jcr.Binary;
 import javax.jcr.Node;
 import javax.jcr.PropertyType;
@@ -34,7 +33,7 @@ import javax.jcr.ValueFormatException;
 
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.Blob;
-import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.api.BlobFactory;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
@@ -57,7 +56,7 @@ import org.slf4j.LoggerFactory;
 public class ValueFactoryImpl implements ValueFactory {
     private static final Logger log = LoggerFactory.getLogger(ValueFactoryImpl.class);
 
-    private final ContentSession contentSession;
+    private final BlobFactory blobFactory;
     private final NamePathMapper namePathMapper;
 
     /**
@@ -66,8 +65,8 @@ public class ValueFactoryImpl implements
      * @param namePathMapper The name/path mapping used for converting JCR names/paths to
      * the internal representation.
      */
-    public ValueFactoryImpl(ContentSession session, NamePathMapper namePathMapper) {
-        this.contentSession = session;
+    public ValueFactoryImpl(BlobFactory blobFactory, NamePathMapper namePathMapper) {
+        this.blobFactory = blobFactory;
         this.namePathMapper = namePathMapper;
     }
 
@@ -265,7 +264,7 @@ public class ValueFactoryImpl implements
     }
 
     private ValueImpl createBinaryValue(InputStream value) throws IOException {
-        Blob blob = contentSession.createBlob(value);
+        Blob blob = blobFactory.createBlob(value);
         return new ValueImpl(BinaryPropertyState.binaryProperty("", blob), namePathMapper);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java?rev=1401331&r1=1401330&r2=1401331&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionDelegate.java
Tue Oct 23 16:02:22 2012
@@ -97,7 +97,7 @@ public class SessionDelegate {
         this.session = new SessionImpl(this);
         this.idManager = new IdentifierManager(root);
         this.namePathMapper = new NamePathMapperImpl(new SessionNameMapper(this), idManager);
-        this.valueFactory = new ValueFactoryImpl(contentSession, namePathMapper);
+        this.valueFactory = new ValueFactoryImpl(root.getBlobFactory(), namePathMapper);
     }
 
     /**



Mime
View raw message