syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1617252 - in /syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer: containers/Tomcat.java processes/ArchetypeProcess.java processes/PersistenceProcess.java utilities/FileSystemUtils.java
Date Mon, 11 Aug 2014 10:57:02 GMT
Author: massi
Date: Mon Aug 11 10:57:02 2014
New Revision: 1617252

URL: http://svn.apache.org/r1617252
Log:
Few bare code improvements

Modified:
    syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
    syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
    syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
    syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java

Modified: syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java?rev=1617252&r1=1617251&r2=1617252&view=diff
==============================================================================
--- syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
(original)
+++ syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/containers/Tomcat.java
Mon Aug 11 10:57:02 2014
@@ -21,11 +21,12 @@ package org.apache.syncope.installer.con
 import com.izforge.izpack.panels.process.AbstractUIProcessHandler;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
-import org.apache.syncope.installer.utilities.FileSystemUtils;
 import org.apache.syncope.installer.utilities.HttpUtils;
 
 public class Tomcat extends AbstractContainer {
 
+    private static final boolean IS_WIN = System.getProperty("os.name").toLowerCase().contains("win");
+
     private static final String DEPLOY_SYNCOPE_CORE_QUERY = "/manager/text/deploy?path=/syncope&war=file:";
 
     private static final String DEPLOY_SYNCOPE_CONSOLE_QUERY = "/manager/text/deploy?path=/syncope-console&war=file:";
@@ -33,7 +34,7 @@ public class Tomcat extends AbstractCont
     private final String installPath;
 
     private final String artifactId;
-    
+
     private final HttpUtils httpUtils;
 
     public Tomcat(final boolean tomcatSsl, final String tomcatHost, final String tomcatPort,
@@ -46,7 +47,7 @@ public class Tomcat extends AbstractCont
 
     public boolean deployCore() {
         int status;
-        if (FileSystemUtils.IS_WIN) {
+        if (IS_WIN) {
             status = httpUtils.getWithBasicAuth(DEPLOY_SYNCOPE_CORE_QUERY
                     + pathEncoded(String.format(WIN_CORE_RELATIVE_PATH, installPath, artifactId)));
         } else {
@@ -58,7 +59,7 @@ public class Tomcat extends AbstractCont
 
     public boolean deployConsole() {
         int status;
-        if (FileSystemUtils.IS_WIN) {
+        if (IS_WIN) {
             status = httpUtils.getWithBasicAuth(DEPLOY_SYNCOPE_CONSOLE_QUERY
                     + pathEncoded(String.format(WIN_CONSOLE_RELATIVE_PATH, installPath, artifactId)));
         } else {

Modified: syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java?rev=1617252&r1=1617251&r2=1617252&view=diff
==============================================================================
--- syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
(original)
+++ syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/ArchetypeProcess.java
Mon Aug 11 10:57:02 2014
@@ -42,12 +42,8 @@ public class ArchetypeProcess {
         final String syncopeAdminPassword = args[10];
 
         final FileSystemUtils fileSystemUtils = new FileSystemUtils(handler);
-        if (!new File(installPath).exists()) {
-            fileSystemUtils.createDirectory(installPath, null);
-            InstallLog.initialize(installPath, handler);
-        } else {
-            InstallLog.initialize(installPath, handler);
-        }
+        fileSystemUtils.createDirectory(installPath);
+        InstallLog.initialize(installPath, handler);
 
         final MavenUtils mavenUtils = new MavenUtils(mavenDir, handler);
         mavenUtils.archetypeGenerate(
@@ -55,9 +51,9 @@ public class ArchetypeProcess {
 
         fileSystemUtils.writeToFile(new File(installPath + "/" + artifactId + Pom.PATH),
                 String.format(Pom.FILE, syncopeVersion, syncopeVersion, groupId, artifactId));
-        fileSystemUtils.createDirectory(confDirectory, null);
-        fileSystemUtils.createDirectory(logsDirectory, null);
-        fileSystemUtils.createDirectory(bundlesDirectory, null);
+        fileSystemUtils.createDirectory(confDirectory);
+        fileSystemUtils.createDirectory(logsDirectory);
+        fileSystemUtils.createDirectory(bundlesDirectory);
         mavenUtils.createPackage(installPath + "/" + artifactId, confDirectory, logsDirectory,
bundlesDirectory);
     }
 

Modified: syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java?rev=1617252&r1=1617251&r2=1617252&view=diff
==============================================================================
--- syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
(original)
+++ syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/processes/PersistenceProcess.java
Mon Aug 11 10:57:02 2014
@@ -61,7 +61,7 @@ public class PersistenceProcess {
 
         handler.logOutput("Configure persistence file according to " + dbSelected + " properties",
true);
         InstallLog.getInstance().info("Configure persistence file according to " + dbSelected
+ " properties");
-        
+
         switch (dbSelected) {
             case POSTGRES:
                 persistenceProperties.append(String.format(
@@ -95,7 +95,9 @@ public class PersistenceProcess {
     }
 
     private void writeOrmFile(final FileSystemUtils fileSystemUtils, final String content)
{
-        fileSystemUtils.createDirectory(installPath + "/" + artifactId + OrmXml.PATH_DIR,
null);
-        fileSystemUtils.writeToFile(new File(installPath + "/" + artifactId + OrmXml.PATH_COMPLETE),
content);
+        fileSystemUtils.createDirectory(
+                installPath + File.separator + artifactId + OrmXml.PATH_DIR);
+        fileSystemUtils.writeToFile(
+                new File(installPath + File.separator + artifactId + OrmXml.PATH_COMPLETE),
content);
     }
 }

Modified: syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java?rev=1617252&r1=1617251&r2=1617252&view=diff
==============================================================================
--- syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
(original)
+++ syncope/branches/1_2_X/installer/src/main/java/org/apache/syncope/installer/utilities/FileSystemUtils.java
Mon Aug 11 10:57:02 2014
@@ -30,25 +30,17 @@ import java.io.PrintWriter;
 
 public class FileSystemUtils {
 
-    public static final boolean IS_WIN = System.getProperty("os.name").toLowerCase().contains("win");
-
-    private static final String UNIX_CREATE_DIRECTORY = "mkdir -p %s";
-
-    private static final String WIN_CREATE_DIRECTORY = "mkdir %s";
-
     private final AbstractUIProcessHandler handler;
 
     public FileSystemUtils(final AbstractUIProcessHandler handler) {
         this.handler = handler;
     }
 
-    public void createDirectory(final String directoryPath, final String path) {
-        if (IS_WIN) {
-            exec(String.format(WIN_CREATE_DIRECTORY, directoryPath), path);
-        } else {
-            exec(String.format(UNIX_CREATE_DIRECTORY, directoryPath), path);
+    public void createDirectory(final String directoryPath) {
+        final File directory = new File(directoryPath);
+        if (!directory.exists()) {
+            directory.mkdirs();
         }
-
     }
 
     public void exec(final String cmd, final String path) {



Mime
View raw message