This is an automated email from the git hooks/post-receive script. New commit to branch feature/1197-modularisation in repository lima. See http://git.chorem.org/lima.git commit 1b9c88125db8eca665ef5ce980d75f92ecfe7c49 Author: Arnaud Thimel <thimel@codelutin.com> Date: Wed Mar 18 00:24:58 2015 +0100 Move some configuration (about lima-report) in lima-business common module --- .../chorem/lima/business/api/OptionsService.java | 4 ++++ .../lima/business/utils/EntryComparator.java | 2 +- .../business/utils/FinancialPeriodComparator.java | 0 .../chorem/lima/business/LimaBusinessConfig.java | 24 +++++++++++++++++++++- .../lima/business/ejb/OptionsServiceImpl.java | 10 +++++++++ .../org.chorem.lima/server/HttpServerService.java | 21 +++++++++++-------- .../org.chorem.lima/server/LimaServerConfig.java | 23 --------------------- .../src/main/java/org/chorem/lima/ui/MainView.jaxx | 2 +- .../java/org/chorem/lima/ui/MainViewHandler.java | 21 ++++++++++++++----- 9 files changed, 67 insertions(+), 40 deletions(-) diff --git a/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java b/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java index 1ccb1d9..9942002 100644 --- a/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/api/OptionsService.java @@ -54,4 +54,8 @@ public interface OptionsService extends BigDecimalToString.Config { LimaConfigOptionDef getThousandSeparatorOption(); + String getLimaReportHost(); + + int getLimaReportPort(); + } diff --git a/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java b/lima-business-api/src/main/java/org/chorem/lima/business/utils/EntryComparator.java similarity index 91% rename from lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java rename to lima-business-api/src/main/java/org/chorem/lima/business/utils/EntryComparator.java index 466a846..b2e0faf 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java +++ b/lima-business-api/src/main/java/org/chorem/lima/business/utils/EntryComparator.java @@ -35,7 +35,7 @@ public class EntryComparator implements Serializable, Comparator<Entry> { public int compare(Entry o1, Entry o2) { int result = o1.getFinancialTransaction().getTransactionDate().compareTo(o2.getFinancialTransaction().getTransactionDate()); if (result == 0) { - result = o1.getFinancialTransaction().getTopiaCreateDate().compareTo(o2.getFinancialTransaction().getTopiaCreateDate()); + result = o1.getFinancialTransaction().getTopiaCreateDate().compareTo(o2.getFinancialTransaction().getTopiaCreateDate()); } if (result == 0) { result = o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate()); diff --git a/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java b/lima-business-api/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java similarity index 100% rename from lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java rename to lima-business-api/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java diff --git a/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java b/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java index 73bc7fc..951af46 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java +++ b/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessConfig.java @@ -33,7 +33,6 @@ import org.chorem.lima.entity.LimaCallaoEntityEnum; import org.chorem.lima.entity.LimaFlywayServiceImpl; import org.nuiton.config.ApplicationConfig; import org.nuiton.config.ArgumentsParserException; -import org.nuiton.config.ConfigOptionDef; import org.nuiton.topia.flyway.TopiaFlywayService; import org.nuiton.topia.persistence.TopiaConfigurationConstants; @@ -265,6 +264,26 @@ public class LimaBusinessConfig { config.saveForUser(); } + public String getReportHost() { + String host = config.getOption(ServiceConfigOption.REPORT_HOST.getKey()); + return host; + } + + public void setReportHost(String serverAddress) { + config.setOption(ServiceConfigOption.REPORT_HOST.key, serverAddress); + config.saveForUser(); + } + + public int getReportPort() { + int port = config.getOptionAsInt(ServiceConfigOption.REPORT_PORT.getKey()); + return port; + } + + public void setReportPort(int port) { + config.setOption(ServiceConfigOption.REPORT_PORT.key, String.valueOf(port)); + config.saveForUser(); + } + /** * Lima option definition. * <p/> @@ -287,6 +306,9 @@ public class LimaBusinessConfig { DATA_DIR("lima.data.dir", n("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false), RULES_NATIONALTY("lima.rules", n("lima.config.rulesnationality.description"), FranceAccountingRules.class.getName(), String.class, false, false), + REPORT_HOST("lima.serveraddress", n("lima.config.serveraddress.description"), "localhost", String.class, false, false), + REPORT_PORT("lima.httpport", n("lima.config.httpport.description"), "5462", Integer.class, false, false), + SCALE("lima.data.bigDecimal.scale", t("lima.config.scale.label"), n("lima.config.scale.description"), "2", String.class, false, false), CURRENCY("lima.config.currency", t("lima.config.currency.label"), n("lima.config.currency.description"), "false", Boolean.class, false, false), DECIMAL_SEPARATOR("lima.data.bigDecimal.decimalSeparator", t("lima.config.decimalSeparator.label"), "", ",", Character.class, false, false), diff --git a/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java b/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java index 11d4f4b..635bf98 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java +++ b/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java @@ -92,4 +92,14 @@ public class OptionsServiceImpl extends AbstractLimaService implements OptionsSe return LimaBusinessConfig.ServiceConfigOption.THOUSAND_SEPARATOR; } + @Override + public String getLimaReportHost() { + return LimaBusinessConfig.getInstance().getReportHost(); + } + + @Override + public int getLimaReportPort() { + return LimaBusinessConfig.getInstance().getReportPort(); + } + } diff --git a/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java b/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java index a195ff9..6daf877 100644 --- a/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java +++ b/lima-server/src/main/java/org.chorem.lima/server/HttpServerService.java @@ -29,6 +29,7 @@ import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.api.AccountService; +import org.chorem.lima.business.api.OptionsService; import org.chorem.lima.report.DocumentsEnum; import org.chorem.lima.business.utils.FormatsEnum; import org.chorem.lima.entity.Account; @@ -72,7 +73,8 @@ public class HttpServerService { //protected String path; - protected int port; + protected String limaReportHost; + protected int limaReportPort; private static final SimpleDateFormat DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd"); @@ -80,8 +82,11 @@ public class HttpServerService { public HttpServerService() { - port = LimaServerConfig.getInstance().getHttpPort(); + OptionsService optionsService = LimaServiceFactory.getService(OptionsService.class); accountService = LimaServiceFactory.getService(AccountService.class); + + limaReportHost = optionsService.getLimaReportHost(); + limaReportPort = optionsService.getLimaReportPort(); documentService = new DocumentService(); reportBuilder = new ReportBuilder(); } @@ -94,7 +99,7 @@ public class HttpServerService { FileUtil.createDirectoryIfNecessary(reportDir); - server = new Server(port); + server = new Server(limaReportPort); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); @@ -103,7 +108,7 @@ public class HttpServerService { server.start(); if (log.isInfoEnabled()) { - log.info("Web server running on port: " + port); + log.info("Web server running on port: " + limaReportPort); } } catch (Exception eee) { @@ -113,7 +118,7 @@ public class HttpServerService { } public int getHttpPort() { - return port; + return limaReportPort; } /** @@ -122,8 +127,6 @@ public class HttpServerService { public class MainServlet extends HttpServlet { private static final long serialVersionUID = 1L; - private String serverAddressConfig = LimaServerConfig.getInstance().getAddressServer(); - @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -222,10 +225,10 @@ public class HttpServerService { log.info("Page load"); /** create server Address : static config if exist or dynamical adress */ - if (serverAddressConfig.equals("")) { + if (limaReportHost.equals("")) { serverAddress += req.getServerName() + ":" + req.getServerPort(); } else { - serverAddress += serverAddressConfig + ":" + getHttpPort(); + serverAddress += limaReportHost + ":" + getHttpPort(); } Calendar calendar = Calendar.getInstance(); diff --git a/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java b/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java index 18df1c6..afea90b 100644 --- a/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java +++ b/lima-server/src/main/java/org.chorem.lima/server/LimaServerConfig.java @@ -110,27 +110,6 @@ public class LimaServerConfig { return dataDir; } - public String getAddressServer() { - String serverAddress = config.getOption(ServiceConfigOption.SERVER_ADRESS.getKey()); - return serverAddress; - } - - public void setAddressServer(String serverAddress) { - config.setOption(ServiceConfigOption.SERVER_ADRESS.key, serverAddress); - config.saveForUser(); - } - - public int getHttpPort() { - String httpPort = config.getOption(ServiceConfigOption.HTTP_PORT.getKey()); - Integer port = Integer.valueOf(httpPort); - return port; - } - - public void setHttpPort(int port) { - config.setOption(ServiceConfigOption.HTTP_PORT.key, String.valueOf(port)); - config.saveForUser(); - } - public String getVatPDFUrl() { String vatPDFUrl = config.getOption(ServiceConfigOption.VAT_PDF_URL.getKey()); return vatPDFUrl; @@ -396,8 +375,6 @@ public class LimaServerConfig { APPLICATION_VERSION("application.version", n("application.version"), null, String.class, false, false), DATA_DIR("lima.data.dir", n("lima.config.data.dir.description"), "${user.home}/.lima", File.class, false, false), RULES_NATIONALTY("lima.rules", n("lima.config.rulesnationality.description"), FranceAccountingRules.class.getName(), String.class, false, false), - HTTP_PORT("lima.httpport", n("lima.config.httpport.description"), "5462", String.class, false, false), - SERVER_ADRESS("lima.serveraddress", n("lima.config.serveraddress.description"), "localhost", String.class, false, false), VAT_PDF_URL("lima.report.vatpdfurl", n("lima.config.reportvatpdfurl.description"), "default", String.class, false, false), REPORTS_MODEL_DIR("lima.reports.dir",n("lima.config.reports.dir.description"),"${lima.data.dir}/reports", File.class, false, false), diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx index 9ddecce..7e1d4ac 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx @@ -107,7 +107,7 @@ </JMenu> <JSeparator/> <JMenuItem id="documents" - onActionPerformed="getHandler().loadURI(this)"/> + onActionPerformed="getHandler().openLimaReport(this)"/> <JSeparator/> <JMenuItem id="identity" onActionPerformed="getHandler().showIdentity(this)"/> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java index f8205ab..cbe4203 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java @@ -31,8 +31,8 @@ import org.chorem.lima.LimaSwingApplicationContext; import org.chorem.lima.LimaSwingConfig; import org.chorem.lima.business.api.OptionsService; import org.chorem.lima.enums.ImportExportEnum; -import org.chorem.lima.server.LimaServerConfig; import org.chorem.lima.business.LimaServiceFactory; +import org.chorem.lima.server.LimaServerConfig; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.celleditor.NumberSeparatorCellRenderer; import org.chorem.lima.ui.celleditor.NumberSeparatorTableCellRenderer; @@ -491,10 +491,21 @@ public class MainViewHandler { importExport.processImportExport(type, true); } - public void loadURI(MainView ui) { - int port = LimaServerConfig.getInstance().getHttpPort(); - String address = LimaServerConfig.getInstance().getHostAddress(); - String url = "http://" + address + ":" + port + "/"; + public void openLimaReport(MainView ui) { + + OptionsService optionsService = LimaServiceFactory.getService(OptionsService.class); + + String host = optionsService.getLimaReportHost(); + int port = optionsService.getLimaReportPort(); + + String url; + if (port == 80) { + url = String.format("http://%s/", host); + } else if (port == 443) { + url = String.format("https://%s/", host); + } else { + url = String.format("http://%s:%d/", host, port); + } if (log.isDebugEnabled()) { log.debug("URL : " + url); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.