incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r980666 - in /sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl: SuspendableOutputStream.java nodestream/NodeInputStream.java nodestream/NodeOutputStream.java servlets/JobInfoServlet.java
Date Fri, 30 Jul 2010 07:16:16 GMT
Author: cziegeler
Date: Fri Jul 30 07:16:16 2010
New Revision: 980666

URL: http://svn.apache.org/viewvc?rev=980666&view=rev
Log:
Avoid Java 6 constructor

Modified:
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeInputStream.java
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeOutputStream.java
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobInfoServlet.java

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java?rev=980666&r1=980665&r2=980666&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
Fri Jul 30 07:16:16 2010
@@ -92,8 +92,8 @@ public class SuspendableOutputStream ext
                         wait();
                     }
                 } catch (InterruptedException e) {
-                    throw new IOException(
-                            "InterruptedException in checkWritePermission()", e);
+                    throw (IOException)new IOException(
+                            "InterruptedException in checkWritePermission()").initCause(e);
                 }
             }
         }
@@ -153,7 +153,7 @@ public class SuspendableOutputStream ext
 
     /**
      * Not implemented
-     * 
+     *
      * @throws UnsupportedOperationException
      */
     public String getPath() {

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeInputStream.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeInputStream.java?rev=980666&r1=980665&r2=980666&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeInputStream.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeInputStream.java
Fri Jul 30 07:16:16 2010
@@ -29,35 +29,35 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** Reads data stored by a {@link NodeOutputStream}
- *  and rebuilds a continuous stream out of the 
+ *  and rebuilds a continuous stream out of the
  *  multiple Properties that it creates.
  */
 public class NodeInputStream extends InputStream {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
-    
+
     /** The Node under which we read our data */
     private final Node node;
-    
+
     /** Computes path for stream storage */
     private final NodeStreamPath streamPath;
-    
+
     /** Current stream that we are reading */
     private InputStream currentStream;
-    
+
     public NodeInputStream(Node n) throws IOException {
         node = n;
         streamPath = new NodeStreamPath();
         selectNextStream();
     }
-    
+
     /** Select next property to read from and open its stream */
     private void selectNextStream() throws IOException {
         streamPath.selectNextPath();
         final String propertyPath = streamPath.getNodePath() + "/" + NodeStreamPath.PROPERTY_NAME;
         try {
             if(node.hasProperty(propertyPath)) {
-                final Property p = node.getProperty(propertyPath); 
+                final Property p = node.getProperty(propertyPath);
                 currentStream = p.getStream();
                 log.debug("Switched to the InputStream of Property {}", p.getPath());
             } else {
@@ -65,10 +65,10 @@ public class NodeInputStream extends Inp
                 log.debug("Property {} not found, end of stream", node.getPath() + "/" +
propertyPath);
             }
         } catch(RepositoryException re) {
-            throw new IOException("RepositoryException in selectNextProperty()", re);
+            throw (IOException)new IOException("RepositoryException in selectNextProperty()").initCause(re);
         }
     }
-    
+
     @Override
     public int available() throws IOException {
         return currentStream == null ? 0 : currentStream.available();

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeOutputStream.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeOutputStream.java?rev=980666&r1=980665&r2=980666&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeOutputStream.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/nodestream/NodeOutputStream.java
Fri Jul 30 07:16:16 2010
@@ -32,14 +32,14 @@ import org.slf4j.LoggerFactory;
 
 
 /** An OutputStream stored in properties under
- *  a JCR node. The content is persisted on 
+ *  a JCR node. The content is persisted on
  *  each flush() call, using sequentially-named
  *  properties so that {@link NodeInputStream} can
  *  reconstruct the stream from permanent storage.
- *  flush() is also called automatically every 
+ *  flush() is also called automatically every
  *  BUFFER_SWITCH_SIZE bytes, to keep our memory
- *  requirements low.    
- *  
+ *  requirements low.
+ *
  *  Meant to be used when running background servlets:
  *  we want to save their output in a way that
  *  survives system restart.
@@ -50,24 +50,24 @@ public class NodeOutputStream extends Ou
 
     /** Node type for our stream nodes */
     public static final String STREAM_NODE_TYPE = "nt:unstructured";
-    
+
     /** The Node under which we write our data */
     private final Node node;
-    
+
     /** Computes path for stream storage */
     private final NodeStreamPath streamPath;
-    
+
     /** Buffer to hold data before writing it to a Property */
     private final ByteArrayOutputStream buffer = new ByteArrayOutputStream(BUFFER_SIZE);
-    
+
     public static final int BUFFER_SIZE = 32768;
     public static final int BUFFER_SWITCH_SIZE = BUFFER_SIZE * 100 / 90;
-    
+
     public NodeOutputStream(Node n) {
         node = n;
         streamPath = new NodeStreamPath();
     }
-    
+
     /** Calls flush to persist our stream, before closing */
     @Override
     public void close() throws IOException {
@@ -80,30 +80,30 @@ public class NodeOutputStream extends Ou
      */
     @Override
     public void flush() throws IOException {
-        
+
         streamPath.selectNextPath();
-        
+
         try {
             if(!node.getSession().isLive()) {
                 log.warn("Session closed, unable to flush stream");
             } else {
                 // Create node that will store the stream
                 final String streamNodePath = node.getPath() + "/" + streamPath.getNodePath();
-                final Node streamNode = new DeepNodeCreator().deepCreateNode(streamNodePath,

+                final Node streamNode = new DeepNodeCreator().deepCreateNode(streamNodePath,
                         node.getSession(), STREAM_NODE_TYPE);
-                
-                streamNode.setProperty(NodeStreamPath.PROPERTY_NAME, 
+
+                streamNode.setProperty(NodeStreamPath.PROPERTY_NAME,
                         new ByteArrayInputStream(buffer.toByteArray()));
-                log.debug("Saved {} bytes to Property {}", buffer.size(), 
+                log.debug("Saved {} bytes to Property {}", buffer.size(),
                         streamNode.getProperty(NodeStreamPath.PROPERTY_NAME).getPath());
                 node.save();
                 buffer.reset();
             }
         } catch(RepositoryException re) {
-            throw new IOException("RepositoryException in flush()", re);
+            throw (IOException)new IOException("RepositoryException in flush()").initCause(re);
         }
     }
-    
+
     private void flushIfNeeded() throws IOException {
         if(buffer.size() >= BUFFER_SWITCH_SIZE) {
             log.debug("Buffer size {} reached switch level {}, flushing", buffer.size(),
BUFFER_SWITCH_SIZE);

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobInfoServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobInfoServlet.java?rev=980666&r1=980665&r2=980666&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobInfoServlet.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobInfoServlet.java
Fri Jul 30 07:16:16 2010
@@ -51,7 +51,7 @@ public class JobInfoServlet extends Slin
 
     public static final String DEFAULT_ENCODING = "UTF-8";
     public static final String DEFAULT_EXT = "txt";
-    
+
     private static final Map<String, Renderer> renderers;
     static {
         renderers = new HashMap<String, Renderer>();
@@ -59,21 +59,21 @@ public class JobInfoServlet extends Slin
         renderers.put("html", new HtmlRenderer());
         renderers.put("json", new JsonRenderer());
     }
-    
+
     @Reference
     private JobStorage jobStorage;
-    
+
     static interface Renderer {
         void render(PrintWriter pw, String streamPath, String streamResource) throws IOException;
     }
-    
+
     private static class TextRenderer implements Renderer {
         public void render(PrintWriter pw, String streamPath, String streamResource) {
             pw.println("Background execution: job output available at ");
             pw.println(streamPath);
         }
     }
-    
+
     private static class HtmlRenderer implements Renderer {
         public void render(PrintWriter pw, String streamPath, String streamResource) {
             pw.println("<html><head><title>Background job</title>");
@@ -85,7 +85,7 @@ public class JobInfoServlet extends Slin
             pw.println("</body>");
         }
     }
-    
+
     private static class JsonRenderer implements Renderer {
         public void render(PrintWriter pw, String streamPath, String streamResource) throws
IOException {
             JSONWriter w = new JSONWriter(pw);
@@ -97,23 +97,23 @@ public class JobInfoServlet extends Slin
                 w.value(streamPath);
                 w.endObject();
             } catch (JSONException e) {
-                throw new IOException("JSONException in " + getClass().getSimpleName(), e);
+                throw (IOException)new IOException("JSONException in " + getClass().getSimpleName()).initCause(e);
             }
         }
     }
-    
+
     @Override
     protected void doGet(SlingHttpServletRequest request,
             SlingHttpServletResponse response) throws ServletException,
             IOException {
-        final JobData j = jobStorage.getJobData(request.getResource().adaptTo(Node.class));

+        final JobData j = jobStorage.getJobData(request.getResource().adaptTo(Node.class));
         String jobExt = j.getProperty(JobData.PROP_EXTENSION);
         if(jobExt == null || jobExt.length() == 0) {
             jobExt = "";
         } else {
             jobExt = "." + jobExt;
         }
-        final String streamResource = request.getResource().getPath() + "/stream" + jobExt;

+        final String streamResource = request.getResource().getPath() + "/stream" + jobExt;
         final String streamPath = request.getContextPath() + streamResource;
         final String ext = request.getRequestPathInfo().getExtension();
         Renderer r = renderers.get(ext);



Mime
View raw message