You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2013/10/22 16:31:51 UTC

svn commit: r1534646 - /sling/trunk/tooling/support/install/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java

Author: rombert
Date: Tue Oct 22 14:31:50 2013
New Revision: 1534646

URL: http://svn.apache.org/r1534646
Log:
SLING-3019 - Provide a mechanism to install a bundle based on a
directory

Code cleanups:

- Use IOUtils.closeQuietly where applicable
- Use logAndWriteError consistently

Modified:
    sling/trunk/tooling/support/install/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java

Modified: sling/trunk/tooling/support/install/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/support/install/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java?rev=1534646&r1=1534645&r2=1534646&view=diff
==============================================================================
--- sling/trunk/tooling/support/install/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java (original)
+++ sling/trunk/tooling/support/install/src/main/java/org/apache/sling/tooling/support/install/impl/InstallServlet.java Tue Oct 22 14:31:50 2013
@@ -212,33 +212,24 @@ public class InstallServlet extends Http
                                 result.render(resp.getWriter());
                                 return;
                             } catch ( final BundleException be ) {
-                                logger.info("Unable to install/update bundle from dir " + dir, be);
-                                result = new InstallationResult(false,
-                                        "Unable to install/update bundle from dir " + dir);
+                                logAndWriteError("Unable to install/update bundle from dir " + dir, be, resp);
                             }
                         } finally {
                             tempFile.delete();
                         }
                     } else {
-                        logger.info("Manifest in {} does not have a symbolic name", dir);
-                        result = new InstallationResult(false, "Manifest in " + dir + " does not have a symbolic name");
+                        logAndWriteError("Manifest in " + dir + " does not have a symbolic name", resp);
                     }
                 } finally {
-                    if ( fis != null ) {
-                        fis.close();
-                    }
+                    IOUtils.closeQuietly(fis);
                 }
             } else {
                 result = new InstallationResult(false, "Dir " + dir + " does not have a manifest");
-                logger.info("Dir {} does not have a manifest", dir);
+                logAndWriteError("Dir " + dir + " does have a manifest", resp);
             }
         } else {
             result = new InstallationResult(false, "Dir " + dir + " does not exist");
-            logger.info("Dir {} does not exist", dir);
-        }
-        resp.setStatus(500);
-        if (result != null) {
-            result.render(resp.getWriter());
+            logAndWriteError("Dir " + dir + " does not exist", resp);
         }
     }