mehrere Tabs fuer Module, EMail noch kaputt

This commit is contained in:
Peter Hormanns 2010-12-15 17:22:36 +00:00
parent e780b1a427
commit 4cb63d7c3b
13 changed files with 247 additions and 68 deletions

View File

@ -22,6 +22,11 @@
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>HSAdmin Module</description>
<param-name>hsarmodules</param-name>
<param-value>de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule</param-value>
</context-param>
<filter>
<filter-name>CAS Authentication Filter</filter-name>
@ -32,7 +37,7 @@
</init-param>
<init-param>
<param-name>service</param-name>
<param-value>https://agnes.ostwall195.de:8443/HSAdmin</param-value>
<param-value>https://agnes.ostwall195.de:8443/hsarweb</param-value>
</init-param>
</filter>
@ -49,11 +54,11 @@
</init-param>
<init-param>
<param-name>proxyCallbackUrl</param-name>
<param-value>https://agnes.ostwall195.de:8443/HSAdmin/proxyCallback</param-value>
<param-value>https://agnes.ostwall195.de:8443/hsarweb/proxyCallback</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
<param-value>https://agnes.ostwall195.de:8443/HSAdmin</param-value>
<param-value>https://agnes.ostwall195.de:8443/hsarweb</param-value>
</init-param>
</filter>
@ -73,7 +78,7 @@
<init-param>
<description>Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>de.hsadmin.web.DomainModule</param-value>
<param-value>de.hsadmin.web.MainApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>

View File

@ -0,0 +1,30 @@
package de.hsadmin.web;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
public class EMailAddressModule extends GenericModule {
private static final long serialVersionUID = 1L;
private ModuleConfig moduleConfig;
public EMailAddressModule() {
moduleConfig = new ModuleConfig("emailaddress");
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "emailaddress", String.class, ""));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "localpart", String.class, "", true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "subdomain", String.class, "", true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "domain", String.class, "", true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class, ""));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "admin", String.class, "", true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "fulldomain", String.class, "", true));
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
}

View File

@ -0,0 +1,25 @@
package de.hsadmin.web;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
public class EMailAliasModule extends GenericModule {
private static final long serialVersionUID = 1L;
private ModuleConfig moduleConfig;
public EMailAliasModule() {
moduleConfig = new ModuleConfig("emailalias");
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class, ""));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class, ""));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true));
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
}

View File

@ -8,53 +8,44 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.authentication.AuthenticationFilter;
import org.jasig.cas.client.validation.Assertion;
import com.vaadin.Application;
import com.vaadin.data.Property;
import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.server.HttpServletRequestListener;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.themes.BaseTheme;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
public abstract class GenericModule extends Application implements HttpServletRequestListener {
public abstract class GenericModule {
private static final long serialVersionUID = 1L;
private static final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
private HttpSession httpSession;
private AttributePrincipal userPrincipal;
private ServletContext servletContext;
private Table table;
private Remote remote;
@Override
public void init() {
Window mainWindow = new Window(getModuleConfig().getName());
mainWindow.setHeight(100.0f, Sizeable.UNITS_PERCENTAGE);
mainWindow.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE);
public void setRemote(Remote remote) {
this.remote = remote;
try {
initTable();
mainWindow.addComponent(table);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setMainWindow(mainWindow);
}
public abstract ModuleConfig getModuleConfig();
public Component getComponent() {
return table;
}
public void reload() {
loadTable();
}
private void initTable() throws IllegalAccessException {
@ -92,14 +83,12 @@ public abstract class GenericModule extends Application implements HttpServletRe
table.addContainerProperty("del", Button.class, null);
table.setColumnWidth("del", 16);
table.setColumnHeader("del", "");
loadTable();
}
private void loadTable() {
Remote remote = new Remote(this);
table.removeAllItems();
try {
Object callSearch = remote.callSearch(userPrincipal.getName(), new HashMap<String, String>());
Object callSearch = remote.callSearch(getModuleConfig().getName(), new HashMap<String, String>());
List<PropertyConfig> propertyList = getModuleConfig().getPropertyList();
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
@ -169,7 +158,7 @@ public abstract class GenericModule extends Application implements HttpServletRe
}
private Button createDeleteButton(long id) {
ThemeResource icon = new ThemeResource("../runo/icons/16/cancel.png");
ThemeResource icon = new ThemeResource("../runo/icons/16/document-delete.png");
Button button = new Button();
button.setIcon(icon);
button.setData(id);
@ -185,28 +174,4 @@ public abstract class GenericModule extends Application implements HttpServletRe
return button;
}
public String getProxyTicket() {
return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL"));
}
public String getContextParam(String string) {
return servletContext.getInitParameter(string);
}
@Override
public void onRequestStart(HttpServletRequest request,
HttpServletResponse response) {
httpSession = request.getSession();
servletContext = httpSession.getServletContext();
userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal();
}
@Override
public void onRequestEnd(HttpServletRequest request,
HttpServletResponse response) {
}
public abstract ModuleConfig getModuleConfig();
}

View File

@ -0,0 +1,114 @@
package de.hsadmin.web;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.authentication.AuthenticationFilter;
import org.jasig.cas.client.validation.Assertion;
import com.vaadin.Application;
import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.server.HttpServletRequestListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Window;
import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
import com.vaadin.ui.TabSheet.Tab;
import de.hsadmin.web.config.LocaleConfig;
import de.hsadmin.web.config.ModuleConfig;
public class MainApplication extends Application implements HttpServletRequestListener, TabSheet.SelectedTabChangeListener {
private static final long serialVersionUID = 1L;
private HttpSession httpSession;
private ServletContext servletContext;
private AttributePrincipal userPrincipal;
private LocaleConfig localeConfig;
private Remote remote;
private Map<String, GenericModule> modules;
@Override
public void init() {
localeConfig = new LocaleConfig(Locale.getDefault(), "main");
remote = new Remote(this);
Window mainWindow = new Window(localeConfig.getText("title"));
TabSheet tabs = new TabSheet();
tabs.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE);
tabs.setHeight(680.0f, Sizeable.UNITS_PIXELS);
String modulesParamString = getContextParam("hsarmodules");
modules = new HashMap<String, GenericModule>();
GenericModule firstModule = null;
for (String className : modulesParamString.split(",")) {
try {
GenericModule module = (GenericModule) Class.forName(className).newInstance();
module.setRemote(remote);
if (firstModule == null) {
firstModule = module;
}
ModuleConfig moduleConfig = module.getModuleConfig();
String label = moduleConfig.getLabel("title");
modules.put(label, module);
tabs.addTab(module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("icon")));
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
tabs.addListener(this);
mainWindow.addComponent(tabs);
setMainWindow(mainWindow);
firstModule.reload();
}
public String getProxyTicket() {
return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL"));
}
public String getContextParam(String string) {
return servletContext.getInitParameter(string);
}
public Object getLogin() {
return userPrincipal.getName();
}
@Override
public void onRequestStart(HttpServletRequest request,
HttpServletResponse response) {
httpSession = request.getSession();
servletContext = httpSession.getServletContext();
userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal();
}
@Override
public void onRequestEnd(HttpServletRequest request,
HttpServletResponse response) {
}
@Override
public void selectedTabChange(SelectedTabChangeEvent event) {
TabSheet tabSheet = event.getTabSheet();
Component selectedTab = tabSheet.getSelectedTab();
Tab tab = tabSheet.getTab(selectedTab);
GenericModule module = modules.get(tab.getCaption());
module.reload();
}
}

View File

@ -11,20 +11,20 @@ import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class Remote {
private XmlRpcClient client;
private GenericModule module;
private MainApplication app;
public Remote(GenericModule module) {
this.module = module;
public Remote(MainApplication application) {
this.app = application;
}
public Object callSearch(String user, Map<String, String> where) throws HsarwebException {
public Object callSearch(String module, Map<String, String> where) throws HsarwebException {
Object[] params = new Object[3];
params[0] = user;
params[1] = module.getProxyTicket();
params[0] = app.getLogin();
params[1] = app.getProxyTicket();
params[2] = where;
Object res;
try {
res = getClient().execute(module.getModuleConfig().getName() + ".search", params);
res = getClient().execute(module + ".search", params);
} catch (XmlRpcException e) {
throw new HsarwebException("error in remote server call", e);
}
@ -35,13 +35,14 @@ public class Remote {
if (client == null) {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
String xmlrpcURL = module.getContextParam("xmlrpcURL");
String xmlrpcURL = app.getContextParam("xmlrpcURL");
config.setServerURL(new URL(xmlrpcURL));
config.setEnabledForExceptions(true);
client = new XmlRpcClient();
client.setConfig(config);
} catch (MalformedURLException e) {
throw new HsarwebException("error in remote server url", e);
}
client = new XmlRpcClient();
client.setConfig(config);
}
return client;
}

View File

@ -4,3 +4,5 @@ user=admin
pac=packet
hive=host
since=connected since
title=domains
icon=../runo/icons/16/document-web.png

View File

@ -4,3 +4,5 @@ user=Administrator
pac=Paket
hive=Server
since=aufgeschaltet seit
title=Domains
icon=../runo/icons/16/document-web.png

View File

@ -0,0 +1,11 @@
id=identifier
emailaddress=adress
localpart=local part
subdomain=subdomain
domain=main domain
target=target(s)
admin=admin user
pac=packet
fulldomain=full domain
title=email addresses
icon=../runo/icons/16/email.png

View File

@ -0,0 +1,11 @@
id=Schlüssel
emailaddress=EMail Adresse
localpart=lokaler Teil
subdomain=Sub-Domain
domain=Haupt-Domain
target=Ziel(e)
admin=Administrator
pac=Paket
fulldomain=volle Domain
title=EMail Adressen
icon=../runo/icons/16/email.png

View File

@ -0,0 +1,6 @@
id=identifier
name=name
target=target(s)
pac=packet
title=email aliases
icon=../runo/icons/16/email-send.png

View File

@ -0,0 +1,6 @@
id=Schlüssel
name=Alias
target=Ziel(e)
pac=Paket
title=EMail Aliases
icon=../runo/icons/16/email-send.png

View File

@ -0,0 +1 @@
title=HSAdmin Web Application