From 521807ac7df2aedfc1497ba3f0ce766a5dee244d Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Wed, 10 May 2017 11:45:52 +0200 Subject: [PATCH] customer tab works in local admin-web --- .../src/test/tomee/conf/hsadmin.properties | 4 +- .../de/hsadmin/web/EntryPointsFactory.java | 40 ++++++++++++++----- .../de/hsadmin/web/EntryPointsSelector.java | 2 +- .../java/de/hsadmin/web/FactoryProducer.java | 4 +- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/cust-services/src/test/tomee/conf/hsadmin.properties b/cust-services/src/test/tomee/conf/hsadmin.properties index 5941ad2..cb2d37f 100644 --- a/cust-services/src/test/tomee/conf/hsadmin.properties +++ b/cust-services/src/test/tomee/conf/hsadmin.properties @@ -1,6 +1,6 @@ -ticketvalidator.class=de.hsadmin.login.TestTicketValidator +ticketvalidator.class=de.hsadmin.login.cas.TestTicketValidator cas.validate.url=https://login.hostsharing.net:443/cas/proxyValidate cas.service.url=https://config.hostsharing.net:443/hsar/backend accountprefix.hostmaster=hsh01 accountprefix.customer=hsh00 -domainpostfix.pacdomain=hostsharing.net \ No newline at end of file +domainpostfix.pacdomain=hostsharing.net diff --git a/web/src/main/java/de/hsadmin/web/EntryPointsFactory.java b/web/src/main/java/de/hsadmin/web/EntryPointsFactory.java index 638fef4..2759fbb 100644 --- a/web/src/main/java/de/hsadmin/web/EntryPointsFactory.java +++ b/web/src/main/java/de/hsadmin/web/EntryPointsFactory.java @@ -1,30 +1,50 @@ package de.hsadmin.web; +import java.util.ArrayList; +import java.util.List; + import de.hsadmin.login.Role; +import de.hsadmin.rpc.ModulesManager; public class EntryPointsFactory extends AbstractEntryPointsFactory { -// FIXME: Domain-Modul zum Testen auskommentiert (ph) + private final MainWindow mainWindow; + + public EntryPointsFactory(final MainWindow window) { + this.mainWindow = window; + } @Override public String[] getEntryPointNames(final String role) { - + final ModulesManager modulesManager = mainWindow.getModulesManager(); + final List entryPointNames = new ArrayList<>(); if (Role.SYSTEM.name().equals(role)) { - return new String[] { "customer", "pac" }; -// return new String[] { "customer", "pac", "domain" }; + addEntryPointIfModuleExists(modulesManager, entryPointNames, "customer"); + addEntryPointIfModuleExists(modulesManager, entryPointNames, "pac"); + addEntryPointIfModuleExists(modulesManager, entryPointNames, "domain"); } if (Role.CUSTOMER.name().equals(role)) { - return new String[] { "customer", "pac" }; -// return new String[] { "customer", "pac", "domain" }; + addEntryPointIfModuleExists(modulesManager, entryPointNames, "customer"); + addEntryPointIfModuleExists(modulesManager, entryPointNames, "pac"); + addEntryPointIfModuleExists(modulesManager, entryPointNames, "domain"); } if (Role.PACKET.name().equals(role)) { - return new String[] { "pac" }; -// return new String[] { "pac", "domain" }; + addEntryPointIfModuleExists(modulesManager, entryPointNames, "pac"); + addEntryPointIfModuleExists(modulesManager, entryPointNames, "domain"); } if (Role.DOMAIN.name().equals(role)) { -// return new String[] { "domain" }; + addEntryPointIfModuleExists(modulesManager, entryPointNames, "domain"); + } + return entryPointNames.toArray(new String[] {}); + } + + private void addEntryPointIfModuleExists( + final ModulesManager modulesManager, final List entryPointNames, + final String moduleName) + { + if (modulesManager.hasModule(moduleName)) { + entryPointNames.add(moduleName); } - return new String[] { }; } } diff --git a/web/src/main/java/de/hsadmin/web/EntryPointsSelector.java b/web/src/main/java/de/hsadmin/web/EntryPointsSelector.java index 60439de..88beae3 100644 --- a/web/src/main/java/de/hsadmin/web/EntryPointsSelector.java +++ b/web/src/main/java/de/hsadmin/web/EntryPointsSelector.java @@ -41,7 +41,7 @@ public class EntryPointsSelector extends CustomComponent implements ItemClickLis private void createTabs() throws RpcException { final String role = getRole(); - final AbstractEntryPointsFactory entryPointsFactory = FactoryProducer.getEntryPointsFactory("default"); + final AbstractEntryPointsFactory entryPointsFactory = FactoryProducer.getEntryPointsFactory(mainWindow, "default"); int tabCount = 0; for(String tabName : entryPointsFactory.getEntryPointNames(role)) { accordion.addTab(new EntryPoint(this, tabName), I18N.getText(tabName)); diff --git a/web/src/main/java/de/hsadmin/web/FactoryProducer.java b/web/src/main/java/de/hsadmin/web/FactoryProducer.java index 2a0fd2a..7c52cea 100644 --- a/web/src/main/java/de/hsadmin/web/FactoryProducer.java +++ b/web/src/main/java/de/hsadmin/web/FactoryProducer.java @@ -18,8 +18,8 @@ public class FactoryProducer { return new GenericEditorFactory(); } - public static AbstractEntryPointsFactory getEntryPointsFactory(String choice) { - return new EntryPointsFactory(); + public static AbstractEntryPointsFactory getEntryPointsFactory(MainWindow window, String choice) { + return new EntryPointsFactory(window); } }