X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FServerManagerFactory.java;h=65190614c4dc52612decf0fda5bdca32d9b0e8a4;hp=c34f9ef8019ec285bc68585467dcf81fc4c67791;hb=591f4572f18d20a08a797a8e5c4a8dfc1b3320c1;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java index c34f9ef80..65190614c 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java @@ -22,18 +22,22 @@ import java.net.URLDecoder; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.apache.log4j.Logger; import org.simantics.db.DatabaseUserAgent; import org.simantics.db.Driver; import org.simantics.db.Manager; import org.simantics.db.exception.DatabaseException; -import org.simantics.utils.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ServerManagerFactory { - public static ServerManager create(String databaseId, String address) throws IOException, DatabaseException { - Driver driver = Manager.getDriver(databaseId); - System.out.println("ServerManagerFactory.create called with databaseId=" + databaseId + " and driver is " + driver.toString()); - DatabaseUserAgent agent = Manager.getUserAgent(databaseId); + private static final Logger LOGGER = LoggerFactory.getLogger(ServerManagerFactory.class); + + public static ServerManager create(String databaseDriverId, String address) throws IOException, DatabaseException { + Driver driver = Manager.getDriver(databaseDriverId); + if (driver == null) + throw new IllegalArgumentException("Database driver with ID " + databaseDriverId + " could not be found!"); + LOGGER.info("ServerManagerFactory.create called with id {}, driver is {}.", databaseDriverId, driver); + DatabaseUserAgent agent = Manager.getUserAgent(databaseDriverId); if (agent != null) driver.setDatabaseUserAgent(address, agent); return new ServerManager(driver); @@ -83,7 +87,7 @@ public class ServerManagerFactory { } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { - throw new RuntimeException(e); + throw new RuntimeException(e.getCause()); } } @@ -164,7 +168,6 @@ public class ServerManagerFactory { * @throws IOException */ private static void extractZip(InputStream zipInput, File dst) throws IOException { - Logger myLogger = Logger.getLogger(FileUtils.class); byte[] buf = new byte[8192]; ZipInputStream zis = new ZipInputStream(zipInput); ZipEntry entry; @@ -173,7 +176,7 @@ public class ServerManagerFactory { while (entry != null) { // for each entry to be extracted String name = entry.getName(); - myLogger.debug("Extracting "+name); + LOGGER.debug("Extracting "+name); File file = new File(dst, name); if (entry.isDirectory())