Umstellung auf Vaadin Projekt
This commit is contained in:
parent
dda8fc11e7
commit
e780b1a427
BIN
hsarweb/WebContent/WEB-INF/lib/vaadin-6.4.8.jar
Normal file
BIN
hsarweb/WebContent/WEB-INF/lib/vaadin-6.4.8.jar
Normal file
Binary file not shown.
@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
|
||||
|
||||
<display-name>HSAdmin</display-name>
|
||||
|
||||
<context-param>
|
||||
<param-name>serverName</param-name>
|
||||
@ -16,7 +17,12 @@
|
||||
<param-name>xmlrpcURL</param-name>
|
||||
<param-value>https://agnes.ostwall195.de:9443/hsar/xmlrpc/hsadmin</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<description>Vaadin production mode</description>
|
||||
<param-name>productionMode</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
|
||||
<filter>
|
||||
<filter-name>CAS Authentication Filter</filter-name>
|
||||
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
|
||||
@ -26,7 +32,7 @@
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>service</param-name>
|
||||
<param-value>http://agnes.ostwall195.de:8180/hsarweb</param-value>
|
||||
<param-value>https://agnes.ostwall195.de:8443/HSAdmin</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
@ -43,11 +49,11 @@
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>proxyCallbackUrl</param-name>
|
||||
<param-value>https://agnes.ostwall195.de:9443/hsarweb/proxyCallback</param-value>
|
||||
<param-value>https://agnes.ostwall195.de:8443/HSAdmin/proxyCallback</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>service</param-name>
|
||||
<param-value>http://agnes.ostwall195.de:8180/hsarweb</param-value>
|
||||
<param-value>https://agnes.ostwall195.de:8443/HSAdmin</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
@ -60,20 +66,22 @@
|
||||
<filter-name>CAS Authentication Filter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Faces Servlet</servlet-name>
|
||||
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Faces Servlet</servlet-name>
|
||||
<url-pattern>*.html</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>HSAdmin Web</servlet-name>
|
||||
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
|
||||
<init-param>
|
||||
<description>Vaadin application class to start</description>
|
||||
<param-name>application</param-name>
|
||||
<param-value>de.hsadmin.web.DomainModule</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>HSAdmin Web</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
||||
</web-app>
|
@ -4,9 +4,9 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Hello World</title>
|
||||
<title>HSAdmin Web Client</title>
|
||||
</head>
|
||||
<body>
|
||||
<jsp:forward page="hello/index.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
@ -2,16 +2,16 @@
|
||||
<project name="hsarweb" default="war">
|
||||
|
||||
<path id="cp">
|
||||
<fileset dir="lib">
|
||||
<fileset dir="WebContent/WEB-INF/lib">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="/usr/share/java">
|
||||
<include name="servlet-api-2.4.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<target name="war" depends="compile">
|
||||
<war destfile="build/hsarweb.war" basedir="webapp">
|
||||
<lib dir="lib">
|
||||
<include name="**/*.jar"/>
|
||||
</lib>
|
||||
<war destfile="build/hsarweb.war" basedir="WebContent">
|
||||
<classes dir="build/cls" />
|
||||
<classes dir="src">
|
||||
<include name="**/*.properties"/>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,54 +0,0 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
|
||||
@ManagedBean(name="hello")
|
||||
@SessionScoped
|
||||
public class Bean {
|
||||
|
||||
public final static DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
|
||||
@ManagedProperty(value="#{context}")
|
||||
private Context context;
|
||||
|
||||
@ManagedProperty(value="#{remote}")
|
||||
private Remote remote;
|
||||
|
||||
public String getMessage() {
|
||||
Map<String, String> where = new HashMap<String, String>();
|
||||
where.put("name", context.getUser());
|
||||
String name = "Welt";
|
||||
try {
|
||||
Object test = remote.callSearch("user", context.getUser(), where);
|
||||
if (test instanceof Object[] && ((Object[])test).length > 0 ) {
|
||||
if (((Object[])test)[0] instanceof Map) {
|
||||
name = (String) ((Map<?, ?>)((Object[])test)[0]).get("comment");
|
||||
}
|
||||
}
|
||||
} catch (HsarwebException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "Hallo " + name;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return df.format(new Date());
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setRemote(Remote remote) {
|
||||
this.remote = remote;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.jasig.cas.client.authentication.AttributePrincipal;
|
||||
import org.jasig.cas.client.util.AbstractCasFilter;
|
||||
import org.jasig.cas.client.validation.Assertion;
|
||||
|
||||
@ManagedBean(name="context")
|
||||
@SessionScoped
|
||||
public class Context {
|
||||
|
||||
private ExternalContext getExternalContext() {
|
||||
return FacesContext.getCurrentInstance().getExternalContext();
|
||||
}
|
||||
|
||||
private AttributePrincipal getPrincipal() {
|
||||
ExternalContext context = getExternalContext();
|
||||
Assertion assertion = (Assertion) context.getSessionMap().get(AbstractCasFilter.CONST_CAS_ASSERTION);
|
||||
return assertion.getPrincipal();
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return getPrincipal().getName();
|
||||
}
|
||||
|
||||
public String getProxyTicket() {
|
||||
String backendURL = getContextParam("backendURL");
|
||||
return getPrincipal().getProxyTicketFor(backendURL);
|
||||
}
|
||||
|
||||
public String getContextPath() {
|
||||
return getExternalContext().getRequestContextPath();
|
||||
}
|
||||
|
||||
public String getContextParam(String name) {
|
||||
return getExternalContext().getInitParameter(name);
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
@ManagedBean(name="domain")
|
||||
@SessionScoped
|
||||
public class Domain {
|
||||
|
||||
@ManagedProperty(value="#{context}")
|
||||
private Context context;
|
||||
|
||||
@ManagedProperty(value="#{remote}")
|
||||
private Remote remote;
|
||||
|
||||
@ManagedProperty(value="#{texts}")
|
||||
private Texts texts;
|
||||
|
||||
private List<Map<String, String>> list = null;
|
||||
private String error = null;
|
||||
public Map<String, String> labels = null;
|
||||
public Map<String, String> urls = null;
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setRemote(Remote remote) {
|
||||
this.remote = remote;
|
||||
}
|
||||
|
||||
public void setTexts(Texts texts) {
|
||||
this.texts = texts;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getList() {
|
||||
if (list == null) {
|
||||
list = new ArrayList<Map<String,String>>();
|
||||
try {
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object testList = remote.callSearch("domain", context.getUser(), whereParams);
|
||||
if (testList != null && testList instanceof Object[]) {
|
||||
Object[] lst = (Object[])testList;
|
||||
for (int i = 0; i<lst.length; i++) {
|
||||
Object testRow = lst[i];
|
||||
if (testRow instanceof Map<?, ?>) {
|
||||
Map<?, ?> row = (Map<?, ?>) testRow;
|
||||
Map<String, String> dom = new HashMap<String, String>();
|
||||
for (String key : new String[] { "id", "name", "user", "hive", "pac", "since" }) {
|
||||
dom.put(key, (String) row.get(key));
|
||||
}
|
||||
list.add(dom);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (HsarwebException e) {
|
||||
error = e.getMessage();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String, String> getLabels() {
|
||||
if (labels == null) {
|
||||
labels = new HashMap<String, String>();
|
||||
for (String key : new String[]{ "name", "user" }) {
|
||||
labels.put(key, texts.getLabel("domain." + key + ".label"));
|
||||
}
|
||||
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
|
||||
public Map<String, String> getUrls() {
|
||||
if (urls == null) {
|
||||
String path = context.getContextPath() + "/";
|
||||
urls = new HashMap<String, String>();
|
||||
for (String key : new String[]{ "edit", "delete" }) {
|
||||
urls.put(key, path + "domain/" + key + ".html");
|
||||
}
|
||||
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
public String delete() {
|
||||
System.out.println("domain.delete" + FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dom_id"));
|
||||
return null;
|
||||
}
|
||||
|
||||
public String edit() {
|
||||
System.out.println("domain.edit" + FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dom_id"));
|
||||
return null;
|
||||
}
|
||||
}
|
29
hsarweb/src/de/hsadmin/web/DomainModule.java
Normal file
29
hsarweb/src/de/hsadmin/web/DomainModule.java
Normal file
@ -0,0 +1,29 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import de.hsadmin.web.config.ModuleConfig;
|
||||
import de.hsadmin.web.config.PropertyConfig;
|
||||
|
||||
public class DomainModule extends GenericModule {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ModuleConfig moduleConfig;
|
||||
|
||||
public DomainModule() {
|
||||
moduleConfig = new ModuleConfig("domain");
|
||||
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true));
|
||||
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class, ""));
|
||||
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, ""));
|
||||
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true));
|
||||
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, "", true));
|
||||
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class, ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleConfig getModuleConfig() {
|
||||
return moduleConfig;
|
||||
}
|
||||
|
||||
}
|
212
hsarweb/src/de/hsadmin/web/GenericModule.java
Normal file
212
hsarweb/src/de/hsadmin/web/GenericModule.java
Normal file
@ -0,0 +1,212 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
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.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 {
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Window mainWindow = new Window(getModuleConfig().getName());
|
||||
mainWindow.setHeight(100.0f, Sizeable.UNITS_PERCENTAGE);
|
||||
mainWindow.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE);
|
||||
try {
|
||||
initTable();
|
||||
mainWindow.addComponent(table);
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
setMainWindow(mainWindow);
|
||||
}
|
||||
|
||||
private void initTable() throws IllegalAccessException {
|
||||
table = new Table() {
|
||||
private static final long serialVersionUID = 35127658139420917L;
|
||||
@Override
|
||||
protected String formatPropertyValue(Object rowId, Object colId,
|
||||
Property property) {
|
||||
if (Date.class == property.getType()) {
|
||||
try {
|
||||
return df.format(property.getValue());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return "---";
|
||||
}
|
||||
}
|
||||
return super.formatPropertyValue(rowId, colId, property);
|
||||
}
|
||||
};
|
||||
table.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE);
|
||||
table.setHeight(100.0f, Sizeable.UNITS_PERCENTAGE);
|
||||
table.setSelectable(true);
|
||||
table.setImmediate(true);
|
||||
table.setColumnCollapsingAllowed(true);
|
||||
table.setColumnReorderingAllowed(true);
|
||||
for (PropertyConfig prop : getModuleConfig().getPropertyList()) {
|
||||
table.addContainerProperty(prop.getId(), prop.getType(), prop.getDefaultValue());
|
||||
table.setColumnHeader(prop.getId(), prop.getLabel());
|
||||
if (prop.isHidden()) {
|
||||
table.setColumnCollapsed(prop.getId(), true);
|
||||
}
|
||||
}
|
||||
table.addContainerProperty("edit", Button.class, null);
|
||||
table.setColumnWidth("edit", 16);
|
||||
table.setColumnHeader("edit", "");
|
||||
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>());
|
||||
List<PropertyConfig> propertyList = getModuleConfig().getPropertyList();
|
||||
if (callSearch instanceof Object[]) {
|
||||
for (Object row : ((Object[])callSearch)) {
|
||||
long oid = -1L;
|
||||
if (row instanceof Map<?, ?>) {
|
||||
Object[] itemData = new Object[propertyList.size()+2];
|
||||
int idx = 0;
|
||||
for (PropertyConfig prop : propertyList) {
|
||||
Object valueObject = ((Map<?, ?>) row).get(prop.getId());
|
||||
if (valueObject != null && valueObject instanceof String) {
|
||||
if (Long.class.equals(prop.getType())) {
|
||||
itemData[idx] = Long.parseLong((String) valueObject);
|
||||
}
|
||||
if (Date.class.equals(prop.getType())) {
|
||||
try {
|
||||
itemData[idx] = df.parse((String) valueObject);
|
||||
} catch (ParseException e) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.clear();
|
||||
itemData[idx] = cal.getTime();
|
||||
}
|
||||
}
|
||||
if (String.class.equals(prop.getType())) {
|
||||
itemData[idx] = (String) valueObject;
|
||||
}
|
||||
if (prop.isIdent() && Long.class.equals(prop.getType())) {
|
||||
if (valueObject instanceof String) {
|
||||
oid = Long.parseLong((String) valueObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
itemData[idx] = createEditButton(oid);
|
||||
idx++;
|
||||
itemData[idx] = createDeleteButton(oid);
|
||||
idx++;
|
||||
table.addItem(itemData, oid);
|
||||
}
|
||||
}
|
||||
table.sort();
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (HsarwebException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Button createEditButton(long id) {
|
||||
ThemeResource icon = new ThemeResource("../runo/icons/16/document-txt.png");
|
||||
Button button = new Button();
|
||||
button.setIcon(icon);
|
||||
button.setData(id);
|
||||
button.setStyleName(BaseTheme.BUTTON_LINK);
|
||||
button.addListener(new Button.ClickListener() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void buttonClick(ClickEvent event) {
|
||||
loadTable();
|
||||
System.out.println("Data: " + event.getButton().getData());
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
private Button createDeleteButton(long id) {
|
||||
ThemeResource icon = new ThemeResource("../runo/icons/16/cancel.png");
|
||||
Button button = new Button();
|
||||
button.setIcon(icon);
|
||||
button.setData(id);
|
||||
button.setStyleName(BaseTheme.BUTTON_LINK);
|
||||
button.addListener(new Button.ClickListener() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public void buttonClick(ClickEvent event) {
|
||||
loadTable();
|
||||
System.out.println("Data: " + event.getButton().getData());
|
||||
}
|
||||
});
|
||||
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();
|
||||
|
||||
}
|
@ -5,16 +5,8 @@ public class HsarwebException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HsarwebException(String msg, Exception e) {
|
||||
super(msg, e);
|
||||
}
|
||||
|
||||
public HsarwebException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public HsarwebException(String msg) {
|
||||
super(msg);
|
||||
public HsarwebException(String string, Throwable e) {
|
||||
super(string, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
|
||||
@ManagedBean(name="modules")
|
||||
@SessionScoped
|
||||
public class Modules {
|
||||
|
||||
@ManagedProperty(value="#{context}")
|
||||
private Context context;
|
||||
|
||||
@ManagedProperty(value="#{texts}")
|
||||
private Texts texts;
|
||||
|
||||
public String[] pageNames = new String[] { "hello", "domain" };
|
||||
public Map<String, String> labels = null;
|
||||
public Map<String, String> urls = null;
|
||||
|
||||
public List<String> getPageNames() {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
for (String name : pageNames) {
|
||||
names.add(name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public Map<String, String> getLabels() {
|
||||
if (labels == null) {
|
||||
labels = new HashMap<String, String>();
|
||||
for (String key : pageNames) {
|
||||
labels.put(key, texts.getLabel(key + ".label"));
|
||||
}
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
|
||||
public Map<String, String> getUrls() {
|
||||
if (urls == null) {
|
||||
String path = context.getContextPath() + "/";
|
||||
urls = new HashMap<String, String>();
|
||||
for (String key : pageNames) {
|
||||
urls.put(key, path + key + "/index.html");
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setTexts(Texts texts) {
|
||||
this.texts = texts;
|
||||
}
|
||||
|
||||
}
|
@ -4,35 +4,27 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.ManagedProperty;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
||||
|
||||
@ManagedBean(name="remote")
|
||||
@SessionScoped
|
||||
public class Remote {
|
||||
|
||||
private XmlRpcClient client;
|
||||
private GenericModule module;
|
||||
|
||||
@ManagedProperty(value="#{context}")
|
||||
private Context context;
|
||||
|
||||
public Remote() throws HsarwebException {
|
||||
client = null;
|
||||
public Remote(GenericModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public Object callSearch(String module, String user, Map<String, String> where) throws HsarwebException {
|
||||
|
||||
public Object callSearch(String user, Map<String, String> where) throws HsarwebException {
|
||||
Object[] params = new Object[3];
|
||||
params[0] = user;
|
||||
params[1] = context.getProxyTicket();
|
||||
params[1] = module.getProxyTicket();
|
||||
params[2] = where;
|
||||
Object res;
|
||||
try {
|
||||
res = getClient().execute(module + ".search", params);
|
||||
res = getClient().execute(module.getModuleConfig().getName() + ".search", params);
|
||||
} catch (XmlRpcException e) {
|
||||
throw new HsarwebException("error in remote server call", e);
|
||||
}
|
||||
@ -43,7 +35,7 @@ public class Remote {
|
||||
if (client == null) {
|
||||
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
|
||||
try {
|
||||
String xmlrpcURL = context.getContextParam("xmlrpcURL");
|
||||
String xmlrpcURL = module.getContextParam("xmlrpcURL");
|
||||
config.setServerURL(new URL(xmlrpcURL));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new HsarwebException("error in remote server url", e);
|
||||
@ -54,7 +46,5 @@ public class Remote {
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.SessionScoped;
|
||||
|
||||
@ManagedBean(name="texts")
|
||||
@SessionScoped
|
||||
public class Texts {
|
||||
|
||||
public String getLabel(String key) {
|
||||
ResourceBundle resource = ResourceBundle.getBundle("texts.messages");
|
||||
return resource.getString(key);
|
||||
}
|
||||
|
||||
}
|
21
hsarweb/src/de/hsadmin/web/config/LocaleConfig.java
Normal file
21
hsarweb/src/de/hsadmin/web/config/LocaleConfig.java
Normal file
@ -0,0 +1,21 @@
|
||||
package de.hsadmin.web.config;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class LocaleConfig {
|
||||
|
||||
private ResourceBundle bundle;
|
||||
|
||||
public LocaleConfig(Locale locale, String moduleName) {
|
||||
bundle = ResourceBundle.getBundle("texts." + moduleName, locale);
|
||||
}
|
||||
|
||||
public String getText(String key) {
|
||||
try {
|
||||
return bundle.getString(key);
|
||||
} catch (Exception e) {
|
||||
return "!!" + key + "!!";
|
||||
}
|
||||
}
|
||||
}
|
38
hsarweb/src/de/hsadmin/web/config/ModuleConfig.java
Normal file
38
hsarweb/src/de/hsadmin/web/config/ModuleConfig.java
Normal file
@ -0,0 +1,38 @@
|
||||
package de.hsadmin.web.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ModuleConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private List<PropertyConfig> propertyList;
|
||||
private LocaleConfig localeConfig;
|
||||
|
||||
public ModuleConfig(String name) {
|
||||
this.name = name;
|
||||
propertyList = new ArrayList<PropertyConfig>();
|
||||
localeConfig = new LocaleConfig(Locale.getDefault(), name);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void addProperty(PropertyConfig property) {
|
||||
this.propertyList.add(property);
|
||||
}
|
||||
|
||||
public List<PropertyConfig> getPropertyList() {
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
public String getLabel(String key) {
|
||||
return localeConfig.getText(key);
|
||||
}
|
||||
|
||||
}
|
87
hsarweb/src/de/hsadmin/web/config/PropertyConfig.java
Normal file
87
hsarweb/src/de/hsadmin/web/config/PropertyConfig.java
Normal file
@ -0,0 +1,87 @@
|
||||
package de.hsadmin.web.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PropertyConfig implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ModuleConfig moduleConfig;
|
||||
private String id;
|
||||
private Class<?> type;
|
||||
private String defaultValue;
|
||||
private boolean hidden;
|
||||
private boolean ident;
|
||||
|
||||
public PropertyConfig(ModuleConfig moduleConfig, String id, Class<?> clasz, String defaultValue) {
|
||||
this.moduleConfig = moduleConfig;
|
||||
this.id = id;
|
||||
this.type = clasz;
|
||||
this.defaultValue = defaultValue;
|
||||
this.setHidden(false);
|
||||
this.setIdent(false);
|
||||
}
|
||||
|
||||
public PropertyConfig(ModuleConfig moduleConfig, String id, Class<?> clasz, String defaultValue, boolean hidden) {
|
||||
this.moduleConfig = moduleConfig;
|
||||
this.id = id;
|
||||
this.type = clasz;
|
||||
this.defaultValue = defaultValue;
|
||||
this.setHidden(hidden);
|
||||
this.setIdent(false);
|
||||
}
|
||||
|
||||
public PropertyConfig(ModuleConfig moduleConfig, String id, Class<?> clasz, String defaultValue, boolean hidden, boolean ident) {
|
||||
this.moduleConfig = moduleConfig;
|
||||
this.id = id;
|
||||
this.type = clasz;
|
||||
this.defaultValue = defaultValue;
|
||||
this.setHidden(hidden);
|
||||
this.setIdent(ident);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return moduleConfig.getLabel(id);
|
||||
}
|
||||
|
||||
public Class<?> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Class<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setIdent(boolean ident) {
|
||||
this.ident = ident;
|
||||
}
|
||||
|
||||
public boolean isIdent() {
|
||||
return ident;
|
||||
}
|
||||
|
||||
}
|
6
hsarweb/src/texts/domain.properties
Normal file
6
hsarweb/src/texts/domain.properties
Normal file
@ -0,0 +1,6 @@
|
||||
id=identifier
|
||||
name=domain
|
||||
user=admin
|
||||
pac=packet
|
||||
hive=host
|
||||
since=connected since
|
6
hsarweb/src/texts/domain_de.properties
Normal file
6
hsarweb/src/texts/domain_de.properties
Normal file
@ -0,0 +1,6 @@
|
||||
id=Schlüssel
|
||||
name=Domain
|
||||
user=Administrator
|
||||
pac=Paket
|
||||
hive=Server
|
||||
since=aufgeschaltet seit
|
@ -1,6 +0,0 @@
|
||||
edit=bearbeiten
|
||||
delete=loeschen
|
||||
hello.label=Hallo
|
||||
domain.label=Domains
|
||||
domain.name.label=Domain
|
||||
domain.user.label=Verwalter
|
@ -1,6 +0,0 @@
|
||||
edit=edit
|
||||
delete=delete
|
||||
hello.label=Hello
|
||||
domain.label=Domains
|
||||
domain.name.label=Domain
|
||||
domain.user.label=Owner
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
|
||||
version="2.0">
|
||||
|
||||
<application>
|
||||
<locale-config>
|
||||
<default-locale>de</default-locale>
|
||||
<supported-locale>en</supported-locale>
|
||||
</locale-config>
|
||||
<message-bundle>texts.messages</message-bundle>
|
||||
<resource-bundle>
|
||||
<base-name>texts.messages</base-name>
|
||||
<var>msgs</var>
|
||||
</resource-bundle>
|
||||
</application>
|
||||
|
||||
</faces-config>
|
@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:f="http://java.sun.com/jsf/core"
|
||||
xmlns:h="http://java.sun.com/jsf/html"
|
||||
xmlns:ui="http://java.sun.com/jsf/facelets">
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
</head>
|
||||
<body>
|
||||
<ui:composition template="/templates/menu-template.xhtml">
|
||||
<ui:param name="title" value="Hostsharing - Ihre Domains"/>
|
||||
<ui:define name="content">
|
||||
<f:view>
|
||||
<h:dataTable var="dom" value="#{domain.list}">
|
||||
<h:column>
|
||||
<f:facet name="header">
|
||||
<h:outputText value="#{domain.labels['name']}" />
|
||||
</f:facet>
|
||||
<h:outputText value="#{dom['name']}" />
|
||||
</h:column>
|
||||
<h:column>
|
||||
<f:facet name="header">
|
||||
<h:outputText value="#{domain.labels['user']}" />
|
||||
</f:facet>
|
||||
<h:outputText value="#{dom['user']}" />
|
||||
</h:column>
|
||||
<h:column>
|
||||
<h:outputLink value="#{domain.urls['edit']}">
|
||||
<h:outputText value="#{msgs.edit}" />
|
||||
<f:param name="id" value="#{dom['id']}" />
|
||||
</h:outputLink>
|
||||
</h:column>
|
||||
<h:column>
|
||||
<h:outputLink value="#{domain.urls['delete']}">
|
||||
<h:outputText value="#{msgs.delete}" />
|
||||
<f:param name="id" value="#{dom['id']}" />
|
||||
</h:outputLink>
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
</f:view>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</body>
|
||||
</html>
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:f="http://java.sun.com/jsf/core"
|
||||
xmlns:h="http://java.sun.com/jsf/html"
|
||||
xmlns:ui="http://java.sun.com/jsf/facelets">
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
</head>
|
||||
<body>
|
||||
<ui:composition template="/templates/menu-template.xhtml">
|
||||
<ui:param name="title" value="Hallo schöne Welt"/>
|
||||
<ui:define name="content">
|
||||
<f:view>
|
||||
<h:outputText value="#{hello.message}"/>, es ist jetzt  <h:outputText value="#{hello.time}"/> Uhr.
|
||||
</f:view>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 9.3 KiB |
@ -1,99 +0,0 @@
|
||||
body {
|
||||
font-family:Arial,Helvetica,SansSerif;
|
||||
font-style:normal;
|
||||
font-variant:normal;
|
||||
font-size:12pt;
|
||||
font-weight:normal;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
min-height:1600px;
|
||||
color:#707172;
|
||||
background-color:#f0f0f0;
|
||||
}
|
||||
.page {
|
||||
width:944px;
|
||||
margin-left:auto;
|
||||
margin-top:2px;
|
||||
margin-right:auto;
|
||||
padding-top:0px;
|
||||
padding-left:0px;
|
||||
padding-right:0px;
|
||||
color:#707172;
|
||||
background-color:#ffffff;
|
||||
}
|
||||
.header {
|
||||
height:68px;
|
||||
width:944px;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
background-color:#005094;
|
||||
background-image:url(../resources/images/logo.png);
|
||||
background-repeat:no-repeat;
|
||||
border-style: none solid;
|
||||
border-width: 1px;
|
||||
border-color: #005094;
|
||||
}
|
||||
.main {
|
||||
width:936px;
|
||||
margin:0px;
|
||||
padding-top:10px;
|
||||
padding-left:4px;
|
||||
padding-right:4px;
|
||||
padding-bottom:0px;
|
||||
border-style: none solid;
|
||||
border-width: 1px;
|
||||
border-color: #dd4901;
|
||||
}
|
||||
.menu {
|
||||
float:left;
|
||||
width:300px;
|
||||
margin-left:0px;
|
||||
margin-top:0px;
|
||||
margin-right:0px;
|
||||
padding-top:0px;
|
||||
padding-left:0px;
|
||||
padding-right:0px;
|
||||
}
|
||||
.dummy {
|
||||
clear:both;
|
||||
}
|
||||
.content {
|
||||
width:606px;
|
||||
margin-left:304px;
|
||||
margin-top:0px;
|
||||
margin-right:auto;
|
||||
margin-bottom:0px;
|
||||
padding-top:0px;
|
||||
padding-left:10px;
|
||||
padding-right:10px;
|
||||
border-left-style: solid;
|
||||
border-left-width: 1px;
|
||||
border-left-color: #dd4901;
|
||||
}
|
||||
.footer {
|
||||
width:944px;
|
||||
clear:left;
|
||||
font-family:Arial,Helvetica,SansSerif;
|
||||
font-style:normal;
|
||||
font-variant:normal;
|
||||
font-size:10pt;
|
||||
font-weight:normal;
|
||||
text-decoration:none;
|
||||
text-align:center;
|
||||
padding-top:4px;
|
||||
padding-bottom:4px;
|
||||
padding-left:0px;
|
||||
padding-right:0px;
|
||||
border-top-color:#ede9e8;
|
||||
border-top-width:2pt;
|
||||
border-top-style:solid;
|
||||
border-left-style: solid;
|
||||
border-left-width: 1px;
|
||||
border-left-color: #dd4901;
|
||||
border-right-style: solid;
|
||||
border-right-width: 1px;
|
||||
border-right-color: #dd4901;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-color: #dd4901;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:f="http://java.sun.com/jsf/core"
|
||||
xmlns:h="http://java.sun.com/jsf/html"
|
||||
xmlns:ui="http://java.sun.com/jsf/facelets">
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
</head>
|
||||
<body>
|
||||
<ui:composition template="/templates/template.xhtml">
|
||||
<ui:define name="menu">
|
||||
<f:view>
|
||||
<h:dataTable var="menuitem" value="#{modules.pageNames}">
|
||||
<h:column>
|
||||
<h:outputLink value="#{modules.urls[menuitem]}">
|
||||
<h:outputText value="#{modules.labels[menuitem]}" />
|
||||
</h:outputLink>
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
</f:view>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</body>
|
||||
</html>
|
@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:f="http://java.sun.com/jsf/core"
|
||||
xmlns:h="http://java.sun.com/jsf/html"
|
||||
xmlns:ui="http://java.sun.com/jsf/facelets">
|
||||
|
||||
<ui:insert name="metadata"/>
|
||||
<h:head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>#{title}</title>
|
||||
</h:head>
|
||||
<h:body>
|
||||
<h:outputStylesheet library="styles" name="hsar.css"/>
|
||||
<h:outputScript library="javax.faces" name="jsf.js" target="head"/>
|
||||
<div class="page">
|
||||
<div class="header">
|
||||
<ui:insert name="header" />
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="menu">
|
||||
<ui:insert name="menu">Default Menu</ui:insert>
|
||||
</div>
|
||||
<div class="content">
|
||||
<ui:insert name="content">Default Content</ui:insert>
|
||||
</div>
|
||||
<div class="dummy"></div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<ui:insert name="footer">Default Footer</ui:insert>
|
||||
</div>
|
||||
</div>
|
||||
</h:body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user