Merge branch 'master' of ssh://hsh04.hostsharing.net/home/doms/source.hostsharing.net/source/hsadmin into prod

This commit is contained in:
Peter Hormanns 2012-11-14 11:52:58 +01:00
commit 3506f9ff9f
45 changed files with 341 additions and 163 deletions

2
authenticator/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build
/bin

1
hsacppcli/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

2
hsarback/.gitignore vendored
View File

@ -0,0 +1,2 @@
/build
/bin

View File

@ -166,3 +166,5 @@ INSERT INTO domain_option (domain_option_name)
VALUES ('indexes');
INSERT INTO domain_option (domain_option_name)
VALUES ('multiviews');
INSERT INTO domain_option (domain_option_name)
VALUES ('php');

View File

@ -1,80 +1,31 @@
-- Migrate database from version 2.1 to version 2.2
-- Migrate database from version 2.2 to version 2.3
--
-- domain options
--
CREATE SEQUENCE domain_option_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE domain_option (
domain_option_id integer DEFAULT nextval(('"domain_option_id_seq"'::text)::regclass) NOT NULL,
domain_option_name character varying(50) NOT NULL
);
ALTER TABLE ONLY domain_option
ADD CONSTRAINT pk_domain_option PRIMARY KEY (domain_option_id);
CREATE UNIQUE INDEX domain_option_name_idx ON domain_option USING btree ( domain_option_name );
CREATE TABLE domain__domain_option (
domain_option_id integer NOT NULL,
domain_id integer NOT NULL
);
ALTER TABLE ONLY domain__domain_option
ADD CONSTRAINT pk_domain__domain_option PRIMARY KEY (domain_option_id, domain_id);
ALTER TABLE ONLY domain__domain_option
ADD CONSTRAINT domain_option_id_fkey FOREIGN KEY (domain_option_id)
REFERENCES domain_option(domain_option_id) DEFERRABLE;
ALTER TABLE ONLY domain__domain_option
ADD CONSTRAINT domain_id_fkey FOREIGN KEY (domain_id)
REFERENCES domain(domain_id) DEFERRABLE;
--
-- table: domain_option
--
INSERT INTO domain_option (domain_option_name)
VALUES ('backupmxforexternalmx');
INSERT INTO domain_option (domain_option_name)
VALUES ('greylisting');
INSERT INTO domain_option (domain_option_name)
VALUES ('htdocsfallback');
INSERT INTO domain_option (domain_option_name)
VALUES ('includes');
INSERT INTO domain_option (domain_option_name)
VALUES ('indexes');
INSERT INTO domain_option (domain_option_name)
VALUES ('multiviews');
VALUES ('php');
--
-- new domain options settings
--
-- existing default = ON
-- existing default = On for DW-packet, Off otherwise.
--
INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
FROM domain, domain_option
WHERE domain_option.domain_option_name = 'greylisting' ;
INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
FROM domain, domain_option
WHERE domain_option.domain_option_name = 'htdocsfallback' ;
INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
FROM domain, domain_option
WHERE domain_option.domain_option_name = 'includes' ;
INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
FROM domain, domain_option
WHERE domain_option.domain_option_name = 'indexes' ;
INSERT INTO domain__domain_option SELECT domain_option_id, domain_id
FROM domain, domain_option
WHERE domain_option.domain_option_name = 'multiviews' ;
FROM domain
JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
JOIN packet on ( unixuser.packet_id = packet.packet_id )
JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
, domain_option
WHERE basepacket.basepacket_code = 'DW/B'
AND domain_option.domain_option_name = 'php' ;
DELETE FROM domain__domain_option USING domain_option, domain
JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id )
JOIN packet on ( unixuser.packet_id = packet.packet_id )
JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id )
WHERE basepacket.basepacket_code != 'DW/B'
AND domain__domain_option.domain_option_id = domain_option.domain_option_id
AND domain_option.domain_option_name = 'php' ;
--
-- existing default = OFF
--
DELETE FROM domain__domain_option USING domain_option
WHERE domain__domain_option.domain_option_id = domain_option.domain_option_id
AND domain_option.domain_option_name = 'backupmxforexternalmx' ;
--
-- End of migratino to version 2.2
-- End of migration to version 2.3
--

View File

@ -59,7 +59,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net");
}
for (String queueName : config.getProperty("queues.mail").split(",")) {
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, domName, pac), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
}
templateVars = new HashMap<String, String>();
templateVars.put("PAC", pacName);
@ -95,7 +95,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
WaitingTasksProcessor processor = new WaitingTasksProcessor(createApacheVHostSetupProcessor(em, dom, templateVars));
Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.mail").split(",")) {
processor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net");
processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net");
}
return processor;
}
@ -111,8 +111,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
mainProcessor.appendProcessor(queueName, createDNSServerRemoveProcessor(domName), queueName + ".hostsharing.net");
}
for (String queueName : config.getProperty("queues.mail").split(",")) {
mainProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createMailinUnsetupProcessor(em, dom), queueName + ".hostsharing.net");
}
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
return mainProcessor;
@ -176,17 +175,30 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" && invoke-rc.d bind9 reload");
}
private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException {
private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
String inetAddr = pac.getCurINetAddr().getInetAddr();
return new CompoundProcessor(
CompoundProcessor cp = new CompoundProcessor(
createPostgreyConfiguration(em),
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
domName + " anything\n" +
"." + domName + " anything\n"),
new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport",
domName + " smtp:" + inetAddr + ":225\n" +
"." + domName + " smtp:" + inetAddr + ":225\n")
);
dom.getName() + " anything\n" +
"." + dom.getName() + " anything\n"));
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
query.setParameter("domname", dom.getName());
query.setParameter("option", "backupmxforexternalmx");
if (query.getResultList().isEmpty()) {
cp.appendProcessor(
new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport",
dom.getName() + " smtp:" + inetAddr + ":225\n" +
"." + dom.getName() + " smtp:" + inetAddr + ":225\n")
);
} else {
cp.appendProcessor(
new ShellProcessor(
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport")
);
}
return cp;
}
private Processor createPostgreyConfiguration(EntityManager em) throws ProcessorException {
@ -213,12 +225,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
);
}
private Processor createMailinDeleteProcessor(String domName) {
Processor mailQueueProcessor = new ShellProcessor(
"postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '" + domName + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/transport");
private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
Processor mailQueueProcessor = new CompoundProcessor(
createPostgreyConfiguration(em),
new ShellProcessor(
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport"));
return mailQueueProcessor;
}

View File

@ -23,12 +23,16 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
CompoundProcessor cp = new CompoundProcessor();
cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual",
email.getFullDomain() + " -" ) );
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
Config config = Config.getInstance();
cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual",
email.getEMailAddress() + " " + email.getTarget() ) );
if (emailAddressCount(em, email) < 2) {
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
for (String queueName : config.getProperty("queues.mail").split(",")) {
waitingTasksProcessor.appendProcessor(queueName, new ShellProcessor( "postmap -r -i /etc/postfix-mailin/relayrecipients",
email.getEMailAddress() + " anything" ), "Add to relayrecipients" );
}
if (emailAddressCount(em, email) <= 1) {
String domName = email.getDomain().getName();
Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.mail").split(",")) {
waitingTasksProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net");
}
@ -49,14 +53,18 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
EMailAddress email = (EMailAddress) entity;
cp.appendProcessor(
new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/virtual" ) );
Config config = Config.getInstance();
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
for (String queueName : config.getProperty("queues.mail").split(",")) {
waitingTasksProcessor.appendProcessor(queueName,
new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/relayrecipients" ), "Remove from relayrecipients" );
}
int emailAddressCount = emailAddressCount(em, email);
if (emailAddressCount == 0) {
// remove the domain from virtual.db
String fullDomain = email.getFullDomain();
cp.appendProcessor(
new ShellProcessor( "postmap -d '" + fullDomain + "' /etc/postfix-mailin/virtual" ) );
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.mail").split(",")) {
waitingTasksProcessor.appendProcessor(queueName, createMailinDeleteProcessor(fullDomain), queueName + ".hostsharing.net");
}

1
hsarback/webapp/META-INF/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/context.xml

1
hsarback/webapp/WEB-INF/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/web.xml

2
hsarjcli/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build
/bin

1
hsarweb/.gitignore vendored
View File

@ -1 +1,2 @@
/build
/bin

1
hsarweb/WebContent/WEB-INF/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/web.xml

View File

@ -19,11 +19,13 @@
<script language='javascript' src='/hsarweb/VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/com.vaadin.terminal.gwt.DefaultWidgetSet.nocache.js'>
</script>
<link rel="stylesheet" type="text/css" href="/hsarweb/VAADIN/themes/reindeer/styles.css"/>
<!--#include virtual="/hostsharing/includes/head.html" -->
</head>
<body>
<iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>
<h1>HSAdmin Web</h1>
<!--#include virtual="/hostsharing/includes/header.html" -->
<div id="hsarweb" style="width:100%;height:800px;"
class="v-app v-app-loading v-theme-reindeer v-app-MainApplication"> </div>
<!--#include virtual="/hostsharing/includes/footer.html" -->
</body>
</html>

View File

@ -57,6 +57,7 @@
</init-param>
</filter>
<filter-mapping>
<filter-name>CAS Validation Filter</filter-name>
<url-pattern>/*</url-pattern>
@ -93,11 +94,15 @@
<servlet-mapping>
<servlet-name>HSAdmin Web</servlet-name>
<url-pattern>/*</url-pattern>
<url-pattern>/MainApplication/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HSAdmin Web</servlet-name>
<url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

View File

@ -4,15 +4,21 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Select;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import de.hsadmin.web.config.ComponentFactory;
import de.hsadmin.web.config.LocaleConfig;
@ -28,22 +34,28 @@ public abstract class AbstractModule implements Module, Serializable {
private VerticalLayout layout;
private Component component;
private ComponentFactory componentFactory;
private Select selRunAs;
public Component getComponent() {
return layout;
}
public void reload() throws HsarwebException {
if (selRunAs != null) {
selRunAs.select(application.getRunAs());
selRunAs.setScrollToSelectedItem(true);
}
componentFactory.loadData();
}
private void initLayout() {
private void initLayout() throws HsarwebException {
layout = new VerticalLayout();
layout.setSizeFull();
final Module thisModule = this;
final ModuleConfig moduleConfig = getModuleConfig();
final LocaleConfig localeConfig = application.getLocaleConfig();
if (this instanceof SearchAble || this instanceof InsertAble) {
if (this instanceof SearchAble || this instanceof InsertAble ||
!("USER".equals(application.getLoginUserRole()) || "NONE".equals(application.getLoginUserRole()))) {
HorizontalLayout toolbar = new HorizontalLayout();
if (this instanceof InsertAble) {
Button btNew = new Button(moduleConfig.getLabel("new"));
@ -97,16 +109,53 @@ public abstract class AbstractModule implements Module, Serializable {
});
toolbar.addComponent(btNew);
}
// if (this instanceof SearchAble) {
// Button btSearch = new Button("search");
// toolbar.addComponent(btSearch);
// }
toolbar.setWidth("100%");
Label space = new Label(" ");
space.setWidth("100%");
toolbar.addComponent(space);
toolbar.setExpandRatio(space, 1.0f);
createRunAsSelect(toolbar);
Button btLogout = new Button(localeConfig.getText("logout"));
btLogout.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
ExternalResource logoutLink = new ExternalResource("logout");
application.getMainWindow().open(logoutLink);
}
});
toolbar.addComponent(btLogout);
ThemeResource icon = new ThemeResource("../runo/icons/16/cancel.png");
btLogout.setIcon(icon);
layout.addComponent(toolbar);
}
layout.addComponent(component);
layout.setExpandRatio(component, 1.0f);
}
private void createRunAsSelect(HorizontalLayout toolbar) throws UnsupportedOperationException, HsarwebException {
selRunAs = new Select();
selRunAs.setWidth(100.0f, Sizeable.UNITS_PIXELS);
selRunAs.setImmediate(true);
selRunAs.setNewItemsAllowed(true);
selRunAs.setNullSelectionAllowed(false);
selRunAs.addItem(application.getLogin());
for (Object item : application.readSelectRunAsItems()) {
selRunAs.addItem(item);
}
selRunAs.select(application.getRunAs());
selRunAs.setScrollToSelectedItem(true);
selRunAs.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void valueChange(ValueChangeEvent event) {
Property property = event.getProperty();
application.setRunAs(property.getValue().toString());
}
});
selRunAs.setDescription(application.getLocaleConfig().getText("runas"));
toolbar.addComponent(selRunAs);
}
public void setApplication(MainApplication app) throws HsarwebException {
application = app;

View File

@ -29,7 +29,7 @@ public abstract class DatabaseModule extends GenericModule {
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
String login = application.getLogin();
String login = application.getRunAs();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);

View File

@ -24,7 +24,7 @@ public abstract class DatabaseUserModule extends GenericModule {
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
String login = application.getLogin();
String login = application.getRunAs();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);

View File

@ -23,7 +23,7 @@ public class DomainModule extends GenericModule {
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig("domain", application.getLocale());
String login = application.getLogin();
String login = application.getRunAs();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);

View File

@ -22,7 +22,7 @@ public class EMailAddressModule extends GenericModule {
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig("emailaddress", application.getLocale());
String login = application.getLogin();
String login = application.getRunAs();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);

View File

@ -22,7 +22,7 @@ public class EMailAliasModule extends GenericModule {
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig("emailalias", application.getLocale());
String login = application.getLogin();
String login = application.getRunAs();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);

View File

@ -95,7 +95,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
button.setIcon(icon);
Map<String, String> whereHash = new HashMap<String, String>();
whereHash.put("name", application.getLogin());
whereHash.put("name", application.getRunAs());
Long key = -1L;
try {
Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash);

View File

@ -0,0 +1,25 @@
package de.hsadmin.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ItemsReader {
public static List<Object> readItemList(MainApplication app, String module, String property) throws HsarwebException {
final List<Object> itemsList = new ArrayList<Object>();
Object custListObj = app.getRemote().callSearch(module, new HashMap<String, String>());
if (custListObj instanceof Object[]) {
Object[] custList = (Object[]) custListObj;
for (Object custObj : custList) {
if (custObj instanceof Map<?, ?>) {
Map<?, ?> custHash = (Map<?, ?>)custObj;
itemsList.add(custHash.get(property));
}
}
}
return itemsList;
}
}

View File

@ -1,6 +1,8 @@
package de.hsadmin.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -46,6 +48,11 @@ public class MainApplication extends Application implements HttpServletRequestLi
private Remote remote;
private Map<String, Module> modules;
private Locale requestLocale;
private String loginUserRole = "NONE";
private String runAs = null;
private TabSheet tabSheet;
private Window mainWindow;
private List<Object> runAsList = null;
@Override
@ -56,41 +63,9 @@ public class MainApplication extends Application implements HttpServletRequestLi
}
localeConfig = new LocaleConfig(locale, "main");
remote = new Remote(this);
String role = "NONE";
try {
Object rolesArrayObj = remote.callSearch("role", null);
if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) {
Object[] rolesArray = (Object[]) rolesArrayObj;
if (rolesArray.length > 0 && rolesArray[0] instanceof Map<?, ?>) {
role = (String) ((Map<?, ?>) rolesArray[0]).get("role");
}
}
} catch (HsarwebException e) {
showSystemException(e);
}
Window mainWindow = new Window(localeConfig.getText("applicationtitle"));
TabSheet tabs = new TabSheet();
tabs.setSizeFull();
String modulesParamString = localeConfig.getText("modules." + role);
modules = new HashMap<String, Module>();
Module firstModule = null;
for (String className : modulesParamString.split(",")) {
try {
Module module = (Module) Class.forName(className).newInstance();
module.setApplication(this);
if (firstModule == null) {
firstModule = module;
}
ModuleConfig moduleConfig = module.getModuleConfig();
String label = moduleConfig.getLabel("moduletitle");
modules.put(label, module);
tabs.addTab((Component) module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("moduleicon")));
} catch (Exception e) {
showSystemException(e);
}
}
tabs.addListener(this);
mainWindow.setContent(tabs);
loginUserRole = readUserRole();
mainWindow = new Window(localeConfig.getText("applicationtitle"));
Module firstModule = initTabSheet();
setMainWindow(mainWindow);
setErrorHandler(new Terminal.ErrorListener() {
private static final long serialVersionUID = 1L;
@ -106,6 +81,51 @@ public class MainApplication extends Application implements HttpServletRequestLi
}
}
private String readUserRole() {
try {
Object rolesArrayObj = remote.callSearch("role", null);
if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) {
Object[] rolesArray = (Object[]) rolesArrayObj;
if (rolesArray.length > 0 && rolesArray[0] instanceof Map<?, ?>) {
return (String) ((Map<?, ?>) rolesArray[0]).get("role");
}
}
} catch (HsarwebException e) {
showSystemException(e);
}
return "NONE";
}
private Module initTabSheet() {
tabSheet = new TabSheet();
tabSheet.setSizeFull();
String modulesParamString = localeConfig.getText("modules." + readUserRole());
modules = new HashMap<String, Module>();
Module firstModule = null;
for (String className : modulesParamString.split(",")) {
try {
Module module = (Module) Class.forName(className).newInstance();
module.setApplication(this);
if (firstModule == null) {
firstModule = module;
}
ModuleConfig moduleConfig = module.getModuleConfig();
String label = moduleConfig.getLabel("moduletitle");
modules.put(label, module);
tabSheet.addTab((Component) module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("moduleicon")));
} catch (Exception e) {
showSystemException(e);
}
}
tabSheet.addListener(this);
mainWindow.setContent(tabSheet);
return firstModule;
}
public String getLoginUserRole() {
return loginUserRole;
}
public String getProxyTicket() {
return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL"));
}
@ -186,4 +206,41 @@ public class MainApplication extends Application implements HttpServletRequestLi
getMainWindow().showNotification("System-Fehler", "<br />Bitte informieren Sie den Support<br/ >" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE);
}
public String getRunAs() {
if (runAs == null) {
return getLogin();
}
return runAs;
}
public void setRunAs(String runAs) {
this.runAs = runAs;
initTabSheet();
Component selectedTab = tabSheet.getSelectedTab();
Tab tab = tabSheet.getTab(selectedTab);
Module module = modules.get(tab.getCaption());
try {
module.reload();
} catch (HsarwebException e) {
e.printStackTrace();
showSystemException(e);
}
}
public List<Object> readSelectRunAsItems() throws HsarwebException {
if (runAsList == null) {
runAsList = new ArrayList<Object>();
if ("HOSTMASTER".equals(loginUserRole)) {
runAsList = ItemsReader.readItemList(this, "member", "membercode");
}
if ("CUSTOMER".equals(loginUserRole)) {
runAsList = ItemsReader.readItemList(this, "pac", "name");
}
if (loginUserRole.startsWith("PAC")) {
runAsList = ItemsReader.readItemList(this, "user", "name");
}
}
return runAsList;
}
}

View File

@ -36,7 +36,7 @@ public class Remote {
private Object xmlrpcCall(String module, String operation, Map<String, String> param1) throws HsarwebException {
Object[] params = new Object[3];
params[0] = app.getLogin();
params[0] = app.getRunAs();
params[1] = app.getProxyTicket();
params[2] = param1 != null ? param1 : new HashMap<String, String>();
return xmlrpcCall(module + "." + operation, params);
@ -44,7 +44,7 @@ public class Remote {
private Object xmlrpcCall(String module, String operation, Map<String, String> param1, Map<String, String> param2) throws HsarwebException {
Object[] params = new Object[4];
params[0] = app.getLogin();
params[0] = app.getRunAs();
params[1] = app.getProxyTicket();
params[2] = param1 != null ? param1 : new HashMap<String, String>();
params[3] = param2 != null ? param2 : new HashMap<String, String>();

View File

@ -22,7 +22,7 @@ public class UnixUserModule extends GenericModule {
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig("user", application.getLocale());
String login = application.getLogin();
String login = application.getRunAs();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
pacProp.setSelectValues(new PropertySelectValues() {

View File

@ -75,6 +75,38 @@ public class GenericForm {
return null;
}
public Form createDeleteForm() {
try {
MainApplication application = module.getApplication();
ModuleConfig config = module.getModuleConfig();
Map<String, String> where = new HashMap<String, String>();
where.put(findIdKey(), entityId.toString());
Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where);
if (searchResult instanceof Object[]) {
Map<?, ?> row = (Map<?, ?>) (((Object[]) searchResult)[0]);
Form f = new Form();
f.setCaption(config.getLabel("delete"));
f.setData(entityId);
Layout layout = f.getLayout();
for (PropertyConfig prop : config.getPropertyList()) {
if (prop.getPropFieldFactory().getClass().equals(DefaultPropertyFieldFactory.class)
&& prop.getPropTableColumn().equals(PropertyTableColumn.DISPLAY)) {
PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory();
Object value = row.get(prop.getId());
Component component = (Component) propFieldFactory.createFieldComponent(prop, value);
component.setReadOnly(true);
layout.addComponent(component);
}
}
return f;
}
} catch (HsarwebException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private String findIdKey() {
List<PropertyConfig> propertyList = module.getModuleConfig().getPropertyList();
String idKey = null;

View File

@ -13,13 +13,12 @@ import com.vaadin.data.Property;
import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.themes.BaseTheme;
import de.hsadmin.web.DeleteAble;
@ -260,6 +259,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
private Button createDeleteButton(long id) {
ThemeResource icon = new ThemeResource("../runo/icons/16/document-delete.png");
final Button button = new Button();
final Module thisModule = module;
button.setIcon(icon);
button.setDescription(module.getApplication().getLocaleConfig().getText("delete"));
button.setData(id);
@ -269,14 +269,16 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
private Window childWindow;
@Override
public void buttonClick(ClickEvent event) {
final GenericForm genericForm = new GenericForm(thisModule, (Long) button.getData());
final Form form = genericForm.createDeleteForm();
final MainApplication application = module.getApplication();
LocaleConfig localeConfig = application.getLocaleConfig();
childWindow = new Window(module.getModuleConfig().getLabel("moduletitle") + " " + localeConfig.getText("delete"));
childWindow.setWidth(320.0f, Sizeable.UNITS_PIXELS);
childWindow.setWidth(640.0f, Sizeable.UNITS_PIXELS);
VerticalLayout vLayout = new VerticalLayout();
vLayout.setMargin(true);
vLayout.setSpacing(true);
vLayout.addComponent(new Label(localeConfig.getText("confirmdelete")));
vLayout.addComponent(form);
HorizontalLayout hLayout = new HorizontalLayout();
Button btDeleteRow = new Button(localeConfig.getText("delete"));
btDeleteRow.addListener(new Button.ClickListener() {

View File

@ -8,3 +8,4 @@ moduletitle=domains
moduleicon=../runo/icons/16/document-web.png
new=configure domain
update=update domain
delete=delete domain

View File

@ -7,4 +7,5 @@ since=aufgeschaltet seit
moduletitle=Domains
moduleicon=../runo/icons/16/document-web.png
new=Domain konfigurieren
update=Domaindaten ändern
update=Domainkonfiguration ändern
delete=Domainkonfiguration löschen

View File

@ -11,3 +11,4 @@ moduletitle=email addresses
moduleicon=../runo/icons/16/email.png
new=create address
update=update address
delete=delete address

View File

@ -11,3 +11,4 @@ moduletitle=EMail Adressen
moduleicon=../runo/icons/16/email.png
new=EMail-Adresse anlegen
update=EMail-Adresse ändern
delete=EMail-Adresse löschen

View File

@ -6,3 +6,4 @@ moduletitle=email aliases
moduleicon=../runo/icons/16/email-send.png
new=create alias
update=update alias
delete=delete alias

View File

@ -6,3 +6,4 @@ moduletitle=EMail Aliases
moduleicon=../runo/icons/16/email-send.png
new=EMail-Alias anlegen
update=EMail-Alias ändern
delete=EMail-Alias löschen

View File

@ -5,6 +5,8 @@ confirmdelete=confirm delete
save=save
abort=abort
new=new
runas=<strong>select</strong><br />change user perspective
logout=logout
modules.NONE=de.hsadmin.web.HomeModule
modules.USER=de.hsadmin.web.HomeModule
modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule

View File

@ -5,3 +5,5 @@ confirmdelete=Diesen Eintrag l
save=speichern
abort=abbrechen
new=Eintrag anlegen
runas=<strong>Auswahl/Eingabe:</strong><br />zur Ansicht eines anderen<br />Benutzers wechseln
logout=abmelden

View File

@ -4,6 +4,7 @@ pac=packet
encoding=encoding
owner=owner
moduletitle=mysql db
new=create db
update=update db
new=create database
update=database
delete=delete database
moduleicon=../hs/icons/table.png

View File

@ -5,5 +5,6 @@ encoding=Zeichensatz
owner=Verwalter
moduletitle=MySQL DB
new=Datenbank anlegen
update=Datenbank ändern
update=Datenbank
delete=Datenbank löschen
moduleicon=../hs/icons/table.png

View File

@ -7,4 +7,5 @@ pac=packet
moduletitle=mysql user
new=create user
update=change password
delete=delete user
moduleicon=../hs/icons/table_key.png

View File

@ -7,4 +7,5 @@ pac=Paket
moduletitle=MySQL User
new=User anlegen
update=Passwort ändern
delete=User löschen
moduleicon=../hs/icons/table_key.png

View File

@ -4,6 +4,7 @@ pac=packet
encoding=encoding
owner=owner
moduletitle=postgresql db
new=create db
new=create database
update=database
delete=delete database
moduleicon=../hs/icons/database.png

View File

@ -6,4 +6,5 @@ owner=Verwalter
moduletitle=PostgreSQL DB
new=Datenbank anlegen
update=Datenbank
delete=Datenbank löschen
moduleicon=../hs/icons/database.png

View File

@ -7,4 +7,5 @@ pac=packet
moduletitle=postgres user
new=create user
update=change password
delete=delete user
moduleicon=../hs/icons/database_key.png

View File

@ -7,4 +7,5 @@ pac=Paket
moduletitle=PostgreSQL User
new=User anlegen
update=Passwort ändern
delete=User löschen
moduleicon=../hs/icons/database_key.png

View File

@ -13,4 +13,5 @@ quota_hardlimit=quota hard limit
moduletitle=unix user
new=create user
update=update user
delete=delete user
moduleicon=../runo/icons/16/users.png

View File

@ -14,3 +14,4 @@ moduletitle=Unix User
moduleicon=../runo/icons/16/users.png
new=Benutzer anlegen
update=Benutzer ändern
delete=Benutzer löschen