refactorings, extract core.util package

This commit is contained in:
Peter Hormanns 2020-05-12 19:45:43 +02:00
parent a100a21ce2
commit a197b4b8af
45 changed files with 68 additions and 354 deletions

View File

@ -2,7 +2,11 @@
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/> <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/> <classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/>
<classpathentry kind="lib" path="lib/commons-beanutils-1.8.3.jar"/> <classpathentry kind="lib" path="lib/commons-beanutils-1.8.3.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
@ -17,7 +21,6 @@
<classpathentry kind="lib" path="lib/geronimo-jpa_2.0_spec-1.1.jar"/> <classpathentry kind="lib" path="lib/geronimo-jpa_2.0_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jta_1.1_spec-1.1.1.jar"/> <classpathentry kind="lib" path="lib/geronimo-jta_1.1_spec-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-validation_1.0_spec-1.1.jar"/> <classpathentry kind="lib" path="lib/geronimo-validation_1.0_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/jpwgen-1.2.0.jar"/>
<classpathentry kind="lib" path="lib/mail.jar"/> <classpathentry kind="lib" path="lib/mail.jar"/>
<classpathentry kind="lib" path="lib/openjpa-2.1.1.jar"/> <classpathentry kind="lib" path="lib/openjpa-2.1.1.jar"/>
<classpathentry kind="lib" path="lib/org.apache.bval.bundle-0.2-incubating.jar"/> <classpathentry kind="lib" path="lib/org.apache.bval.bundle-0.2-incubating.jar"/>
@ -31,5 +34,6 @@
<classpathentry kind="lib" path="lib/velocity-1.7.jar"/> <classpathentry kind="lib" path="lib/velocity-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/> <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-api-1.1.1.jar"/> <classpathentry kind="lib" path="lib/commons-logging-api-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/hsadmin-util-4.0.1-SNAPSHOT.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

Binary file not shown.

View File

@ -25,8 +25,8 @@ import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.email.EMailAddress; import de.hsadmin.mods.email.EMailAddress;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;

View File

@ -2,6 +2,7 @@ package de.hsadmin.core.model;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public abstract class AbstractEntity { public abstract class AbstractEntity {

View File

@ -1,5 +1,6 @@
package de.hsadmin.core.model; package de.hsadmin.core.model;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -13,6 +14,7 @@ import de.hsadmin.core.qserv.EntityProcessorFactory;
import de.hsadmin.core.qserv.NullProcessor; import de.hsadmin.core.qserv.NullProcessor;
import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
/** /**
@ -174,7 +176,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
try { try {
procFactClass = Class.forName(procFactName); procFactClass = Class.forName(procFactName);
if (procFactClass != null) { if (procFactClass != null) {
procFact = (EntityProcessorFactory) procFactClass.newInstance(); procFact = (EntityProcessorFactory) procFactClass.getDeclaredConstructor().newInstance();
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// no processor defined // no processor defined
@ -182,6 +184,8 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
throw new HSAdminException(e); throw new HSAdminException(e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new HSAdminException(e); throw new HSAdminException(e);
} catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// no processor defined
} }
return procFact; return procFact;
} }

View File

@ -1,5 +1,7 @@
package de.hsadmin.core.model; package de.hsadmin.core.model;
import de.hsadmin.core.util.HSAdminException;
public class AuthenticationException extends HSAdminException { public class AuthenticationException extends HSAdminException {
private static final long serialVersionUID = 6242824365822822456L; private static final long serialVersionUID = 6242824365822822456L;

View File

@ -1,5 +1,6 @@
package de.hsadmin.core.model; package de.hsadmin.core.model;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public class AuthorisationException extends HSAdminException { public class AuthorisationException extends HSAdminException {

View File

@ -1,6 +1,5 @@
package de.hsadmin.core.model; package de.hsadmin.core.model;
public class EntitySessionHelper { public class EntitySessionHelper {
/** /**
@ -24,9 +23,9 @@ public class EntitySessionHelper {
} }
private static AbstractModuleImpl instantiateModuleImpl(Transaction tx, Class<?> wrapperClass) private static AbstractModuleImpl instantiateModuleImpl(Transaction tx, Class<?> wrapperClass)
throws InstantiationException, IllegalAccessException { throws ReflectiveOperationException {
AbstractModuleImpl impl; AbstractModuleImpl impl;
impl = (AbstractModuleImpl) wrapperClass.newInstance(); impl = (AbstractModuleImpl) wrapperClass.getDeclaredConstructor().newInstance();
impl.construct(tx); impl.construct(tx);
return impl; return impl;
} }

View File

@ -4,7 +4,7 @@ import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import de.hsadmin.core.util.ReflectionUtil; import de.hsadmin.core.util.HSAdminException;
public class GenericModuleImpl implements ModuleInterface { public class GenericModuleImpl implements ModuleInterface {

View File

@ -1,19 +0,0 @@
package de.hsadmin.core.model;
public class HSAdminException extends Exception {
private static final long serialVersionUID = -5082179267383474532L;
public HSAdminException(String message) {
super(message);
}
public HSAdminException(Exception e) {
super(e);
}
public HSAdminException(String message, Exception aExc) {
super(message, aExc);
}
}

View File

@ -1,25 +0,0 @@
package de.hsadmin.core.model;
/**
* Transiente User-Klasse. Entkoppelt das core-Paket vom UnixUser-Modul.
* @author Peter Hormanns
*/
public class LoginUser {
// TODO UnixUser Referenzen im Core-Paket ersetzen
private String login;
public LoginUser(String loginName) {
login = loginName;
}
public String getLogin() {
return login;
}
public boolean hasHostmasterRole() {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -2,6 +2,8 @@ package de.hsadmin.core.model;
import java.util.List; import java.util.List;
import de.hsadmin.core.util.HSAdminException;
/** /**
* Represents a CRUD (Create, Retrieve, Update, Delete) interface for generic * Represents a CRUD (Create, Retrieve, Update, Delete) interface for generic
* entity instances. * entity instances.

View File

@ -2,6 +2,7 @@ package de.hsadmin.core.model;
import java.util.List; import java.util.List;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public class PrivilegesModuleImpl extends AbstractModuleImpl implements PrivilegesInterface { public class PrivilegesModuleImpl extends AbstractModuleImpl implements PrivilegesInterface {

View File

@ -1,4 +1,4 @@
package de.hsadmin.core.util; package de.hsadmin.core.model;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -8,9 +8,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.util.TextUtil;
import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.TechnicalException;
public class ReflectionUtil { public class ReflectionUtil {
@ -81,7 +79,7 @@ public class ReflectionUtil {
if (valueObject != null && valueObject instanceof Object[]) { if (valueObject != null && valueObject instanceof Object[]) {
for (Object item : ((Object[]) valueObject)) { for (Object item : ((Object[]) valueObject)) {
if (item instanceof String && referTo.getDeclaredField("name") != null) { if (item instanceof String && referTo.getDeclaredField("name") != null) {
Object instance = referTo.newInstance(); Object instance = referTo.getDeclaredConstructor().newInstance();
if (instance instanceof AbstractEntity) { if (instance instanceof AbstractEntity) {
invokeSetter((AbstractEntity) instance, referTo, referTo.getDeclaredField("name"), item); invokeSetter((AbstractEntity) instance, referTo, referTo.getDeclaredField("name"), item);
newSet.add(instance); newSet.add(instance);
@ -90,7 +88,7 @@ public class ReflectionUtil {
} }
} }
} else { } else {
Object newInstance = type.newInstance(); Object newInstance = type.getDeclaredConstructor().newInstance();
clasz.getMethod(setterName(f), type).invoke(entity, newInstance); clasz.getMethod(setterName(f), type).invoke(entity, newInstance);
type.getMethod("setName", String.class).invoke(newInstance, valueObject); type.getMethod("setName", String.class).invoke(newInstance, valueObject);
} }

View File

@ -5,6 +5,7 @@ import java.util.List;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
/** /**

View File

@ -3,16 +3,17 @@ package de.hsadmin.core.qserv;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.util.HSAdminException;
public interface EntityProcessorFactory public interface EntityProcessorFactory
{ {
public <T extends AbstractEntity> Processor public <T extends AbstractEntity> Processor
createCreateProcessor(EntityManager em, T entity) throws ProcessorException; createCreateProcessor(EntityManager em, T entity) throws HSAdminException;
public <T extends AbstractEntity> Processor public <T extends AbstractEntity> Processor
createUpdateProcessor(EntityManager em, T newEntity) throws ProcessorException; createUpdateProcessor(EntityManager em, T newEntity) throws HSAdminException;
public <T extends AbstractEntity> Processor public <T extends AbstractEntity> Processor
createDeleteProcessor(EntityManager em, T entity) throws ProcessorException; createDeleteProcessor(EntityManager em, T entity) throws HSAdminException;
} }

View File

@ -60,7 +60,7 @@ public class JDBCProcessor extends AbstractProcessor {
System.out.println("SQL: " + sqlStatement); System.out.println("SQL: " + sqlStatement);
s.execute(sqlStatement); s.execute(sqlStatement);
} }
return new Integer(0); return 0;
} catch (SQLException aSqlExc) { } catch (SQLException aSqlExc) {
Exception exc = aSqlExc.getNextException(); Exception exc = aSqlExc.getNextException();
if (exc == null) { if (exc == null) {

View File

@ -1,6 +1,6 @@
package de.hsadmin.core.qserv; package de.hsadmin.core.qserv;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.util.HSAdminException;
public class ProcessorException extends HSAdminException { public class ProcessorException extends HSAdminException {

View File

@ -11,8 +11,8 @@ import org.apache.commons.net.smtp.SMTPClient;
import org.apache.commons.net.smtp.SMTPReply; import org.apache.commons.net.smtp.SMTPReply;
import org.apache.commons.net.smtp.SimpleSMTPHeader; import org.apache.commons.net.smtp.SimpleSMTPHeader;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
import de.hsadmin.core.util.HSAdminException;
public class SmtpHelper { public class SmtpHelper {

View File

@ -1,58 +0,0 @@
package de.hsadmin.core.util;
import java.io.File;
import java.io.FileReader;
import java.util.Properties;
import java.util.logging.Logger;
public class Config {
private static Config instance;
private static Logger LOG = Logger.getLogger(Config.class.getName());
private Properties props;
private Config() {
props = new Properties();
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
if (!file.canRead()) {
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
}
if (!file.canRead()) {
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
}
if (!file.canRead()) {
file = new File("/etc/hsadmin.properties");
}
if (!file.canRead()) {
file = new File("/etc/hsadmin/hsadmin.properties");
}
if (file.canRead()) {
try {
LOG.info("Constructor - Properties-File: " + file.getAbsolutePath());
props.load(new FileReader(file));
} catch (Exception e) {
// should not happen
e.printStackTrace();
}
}
}
public static Config getInstance() {
if (instance == null) {
instance = new Config();
}
return instance;
}
public String getProperty(String propertyName) {
String property = props.getProperty(propertyName);
return property;
}
public String getProperty(String propertyName, String defaultValue) {
return props.getProperty(propertyName, defaultValue).trim();
}
}

View File

@ -1,87 +0,0 @@
package de.hsadmin.core.util;
import java.net.InetAddress;
import java.net.UnknownHostException;
import de.hsadmin.core.qserv.ProcessorException;
public class IPv6Trick {
private static final String IPv4_LOCALHOST = "127.0.0";
private static final String IPv6_LOCALHOST = "::1";
private static final String IPv6_LOCALHOST_ALT = "0:0:0:0:0:0:0:1";
private static final String IPv4_83_223_79 = "83.223.79"; // Alboin-Kontor Berlin
private static final String IPv4_83_223_91 = "83.223.91"; // Alboin-Kontor Berlin
private static final String IPv4_83_223_95 = "83.223.95"; // Alboin-Kontor Berlin
private static final String IPv6_PREFIX_AK = "2a01:37:1000::1";
private static final String IPv4_83_223_78 = "83.223.78"; // e-Shelter Berlin
private static final String IPv4_83_223_94 = "83.223.94"; // e-Shelter Berlin
private static final String IPv6_PREFIX_ES = "2a01:37:3000::1";
private static final String IPv6_PREFIX_HS = "2a01:37:";
private static final String IPv6_PREFIX_HS_ALT = "2a01:0037:";
public static String convertIPv4ToIPv6(final String ipv4address) throws ProcessorException {
if (ipv4address == null || ipv4address.length() == 0) {
throw new ProcessorException("no IPv4 address given");
}
try {
final InetAddress inetV4Address = InetAddress.getByName(ipv4address);
if (ipv4address.startsWith(IPv4_83_223_79) // Alboin-Kontor Berlin
|| ipv4address.startsWith(IPv4_83_223_91)
|| ipv4address.startsWith(IPv4_83_223_95) ) {
return embedIPv4Address(inetV4Address, InetAddress.getByName(IPv6_PREFIX_AK));
}
if (ipv4address.startsWith(IPv4_83_223_78) // e-Shelter Berlin
|| ipv4address.startsWith(IPv4_83_223_94) ) {
return embedIPv4Address(inetV4Address, InetAddress.getByName(IPv6_PREFIX_ES));
}
} catch (UnknownHostException e) {
throw new ProcessorException(e);
}
throw new ProcessorException("unknown IPv4 address given");
}
public static boolean isKnownRemote(final String remoteAddress) {
boolean isKnown = false;
System.out.print(remoteAddress + "\n");
if (remoteAddress.startsWith(IPv4_LOCALHOST) || remoteAddress.startsWith(IPv6_LOCALHOST) || remoteAddress.startsWith(IPv6_LOCALHOST_ALT)) {
// localhost
isKnown = true;
}
if (remoteAddress.startsWith(IPv6_PREFIX_HS) || remoteAddress.startsWith(IPv6_PREFIX_HS_ALT)) {
// Hostsharing IPv6
isKnown = true;
}
if (remoteAddress.startsWith(IPv4_83_223_78) || remoteAddress.startsWith(IPv4_83_223_94)) {
// e-Shelter
isKnown = true;
}
if (remoteAddress.startsWith(IPv4_83_223_79) || remoteAddress.startsWith(IPv4_83_223_91) || remoteAddress.startsWith(IPv4_83_223_95)) {
// Speedbone Alboin Kontor
isKnown = true;
}
return isKnown;
}
private static String embedIPv4Address(final InetAddress ipv4address, final InetAddress ipv6Mask) throws UnknownHostException {
final byte[] ipv4Bytes = ipv4address.getAddress();
final byte[] ipv6Bytes = ipv6Mask.getAddress();
ipv6Bytes[10] = ipv4Bytes[0];
ipv6Bytes[11] = ipv4Bytes[1];
ipv6Bytes[12] = ipv4Bytes[2];
ipv6Bytes[13] = ipv4Bytes[3];
ipv6Bytes[14] = 0;
ipv6Bytes[15] = 0;
final InetAddress ipv6Address = InetAddress.getByAddress(ipv6Bytes);
final String ipv6String = ipv6Address.getHostAddress();
if (ipv6String.startsWith("/")) {
return ipv6String.substring(1);
} else {
return ipv6String;
}
}
}

View File

@ -1,25 +0,0 @@
package de.hsadmin.core.util;
import java.util.Random;
import de.rrze.jpwgen.flags.PwGeneratorFlagBuilder;
import de.rrze.jpwgen.impl.PwGenerator;
public class PasswordTool {
public static PwGeneratorFlagBuilder flagBuilder = new PwGeneratorFlagBuilder();
public static Random random = new Random();
static {
flagBuilder.setIncludeCapitals();
flagBuilder.setIncludeNumerals();
// flagBuilder.setIncludeReducedSymbols();
flagBuilder.setFilterAmbiguous();
}
public static String generatePassword() {
String password = PwGenerator.generatePassword(17, flagBuilder.build(), 100, random);
return password;
}
}

View File

@ -1,87 +0,0 @@
package de.hsadmin.core.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class TextUtil {
private static final DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
public static synchronized String replaceUmlautCharacters(String umlautString) {
StringBuffer buffer = new StringBuffer();
for (char c : umlautString.toCharArray()) {
if ( (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
(c == ' ') ) {
buffer.append(c);
} else {
switch (c) {
case 'ä':
buffer.append("ae");
break;
case 'ö':
buffer.append("oe");
break;
case 'ü':
buffer.append("ue");
break;
case 'Ä':
buffer.append("Ae");
break;
case 'Ö':
buffer.append("Oe");
break;
case 'Ü':
buffer.append("Ue");
break;
case 'ß':
buffer.append("ss");
break;
default:
buffer.append('-');
break;
}
}
}
return buffer.toString();
}
public static synchronized String format(Date date) {
return df.format(date);
}
public static synchronized Date parseDate(String dateString) {
try {
return df.parse(dateString);
} catch (ParseException e) {
try {
return df.parse("01.01.1970");
} catch (ParseException e1) {
// don't care
return null;
}
}
}
public static synchronized String format(boolean free) {
return free ? "true" : "false";
}
public static synchronized boolean parseBool(String boolString) {
boolean parsedValue = "T".equals(boolString.toUpperCase()) || "TRUE".equals(boolString.toUpperCase());
return parsedValue;
}
public static synchronized String hidePassword(String passwd) {
final StringBuffer val = new StringBuffer(passwd.substring(0, 2));
for (int i = 2; i < 6; i++) {
val.append('*');
}
return val.toString();
}
}

View File

@ -8,8 +8,8 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -8,8 +8,8 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -8,8 +8,8 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -8,7 +8,7 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -13,7 +13,7 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.GenericModuleImpl; import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.email.EMailAddress; import de.hsadmin.mods.email.EMailAddress;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -19,9 +19,9 @@ import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AnnModuleImpl; import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.core.model.SearchFilter; import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;

View File

@ -8,8 +8,8 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.dom.DomainOption; import de.hsadmin.mods.dom.DomainOption;

View File

@ -8,8 +8,8 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -13,7 +13,7 @@ import javax.persistence.SequenceGenerator;
import javax.persistence.Table; import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.qserv.ProcessorException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.core.util.IPv6Trick; import de.hsadmin.core.util.IPv6Trick;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@ -73,7 +73,7 @@ public class INetAddress extends AbstractEntity implements Serializable {
return name; return name;
} }
public String getInet6Addr() throws ProcessorException { public String getInet6Addr() throws HSAdminException {
return IPv6Trick.convertIPv4ToIPv6(name); return IPv6Trick.convertIPv4ToIPv6(name);
} }

View File

@ -14,7 +14,7 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.GenericModuleImpl; import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.core.util.TextUtil; import de.hsadmin.core.util.TextUtil;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.cust.Contact; import de.hsadmin.mods.cust.Contact;
@ -136,7 +136,7 @@ public class PacModuleImpl extends AbstractModuleImpl {
for (PacComponent c : oldPacComponents) { for (PacComponent c : oldPacComponents) {
String feature = c.getBaseComponent().getFeature(); String feature = c.getBaseComponent().getFeature();
int quantity = c.getQuantity(); int quantity = c.getQuantity();
oldQuantities.put(feature, new Integer(quantity)); oldQuantities.put(feature, quantity);
em.remove(c); em.remove(c);
} }
oldPacComponents.clear(); oldPacComponents.clear();

View File

@ -21,6 +21,7 @@ import de.hsadmin.core.qserv.ShellProcessor;
import de.hsadmin.core.qserv.VelocityProcessor; import de.hsadmin.core.qserv.VelocityProcessor;
import de.hsadmin.core.qserv.WaitingTasksProcessor; import de.hsadmin.core.qserv.WaitingTasksProcessor;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.core.util.PasswordTool; import de.hsadmin.core.util.PasswordTool;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.QuotaLimit; import de.hsadmin.hostsharing.QuotaLimit;
@ -32,7 +33,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
@Override @Override
public <T extends AbstractEntity> Processor createCreateProcessor( public <T extends AbstractEntity> Processor createCreateProcessor(
EntityManager em, T entity) throws ProcessorException { EntityManager em, T entity) throws HSAdminException {
Pac pac = (Pac) entity; Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName(); String basepacName = pac.getBasepac().getName();
if (basepacName.equals(BasePacType.PAC_WEB)) { if (basepacName.equals(BasePacType.PAC_WEB)) {
@ -67,7 +68,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
@Override @Override
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity)
throws ProcessorException { throws HSAdminException {
Pac pac = (Pac) entity; Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName(); String basepacName = pac.getBasepac().getName();
if (basepacName.equals(BasePacType.PAC_WEB)) { if (basepacName.equals(BasePacType.PAC_WEB)) {
@ -91,7 +92,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
} }
@Override @Override
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException { public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws HSAdminException {
Pac pac = (Pac) entity; Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName(); String basepacName = pac.getBasepac().getName();
if (basepacName.equals(BasePacType.PAC_WEB)) { if (basepacName.equals(BasePacType.PAC_WEB)) {
@ -130,7 +131,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
return new ShellProcessor("mk-iptables-rules Accounting"); return new ShellProcessor("mk-iptables-rules Accounting");
} }
private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException { private Processor createHttpdVirtualProc(Hive hive) throws HSAdminException {
Processor domSetupProcessor = new CompoundProcessor( Processor domSetupProcessor = new CompoundProcessor(
new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive, new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive,
"/etc/apache2/conf.d/virtual.conf.tmp", "root", "root", "644", true), "/etc/apache2/conf.d/virtual.conf.tmp", "root", "root", "644", true),
@ -145,7 +146,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
return new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", hive, "/etc/hosts", true); return new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", hive, "/etc/hosts", true);
} }
private Processor createNetworkInterfacesProc(final Hive hive) throws ProcessorException { private Processor createNetworkInterfacesProc(final Hive hive) throws HSAdminException {
return return
new CompoundProcessor( new CompoundProcessor(
new VelocityProcessor("/de/hsadmin/mods/pac/pac-addr-ipv4.vm", hive, "/etc/network/pac-addr-ipv4", true), new VelocityProcessor("/de/hsadmin/mods/pac/pac-addr-ipv4.vm", hive, "/etc/network/pac-addr-ipv4", true),
@ -180,7 +181,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
zonefileTemplateVars.put("inet4Addr", pac.getCurINetAddr().getInet4Addr()); zonefileTemplateVars.put("inet4Addr", pac.getCurINetAddr().getInet4Addr());
try { try {
zonefileTemplateVars.put("inet6Addr", pac.getCurINetAddr().getInet6Addr()); zonefileTemplateVars.put("inet6Addr", pac.getCurINetAddr().getInet6Addr());
} catch (ProcessorException e) { } catch (HSAdminException e) {
// dont care // dont care
} }
final String domName = pac.getName() + ".hostsharing.net"; final String domName = pac.getName() + ".hostsharing.net";
@ -288,7 +289,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
); );
} }
private Processor createIfUp(final Pac pac) throws ProcessorException { private Processor createIfUp(final Pac pac) throws HSAdminException {
return new CompoundProcessor( return new CompoundProcessor(
new ShellProcessor("ip addr add " new ShellProcessor("ip addr add "
+ pac.getCurINetAddr().getInet4Addr() + pac.getCurINetAddr().getInet4Addr()
@ -301,7 +302,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
); );
} }
private Processor createIfDown(final Pac pac) throws ProcessorException { private Processor createIfDown(final Pac pac) throws HSAdminException {
return new CompoundProcessor( return new CompoundProcessor(
new ShellProcessor("ip addr del " new ShellProcessor("ip addr del "
+ pac.getCurINetAddr().getInet4Addr() + pac.getCurINetAddr().getInet4Addr()

View File

@ -4,7 +4,7 @@ import java.util.List;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.util.HSAdminException;
public class QTaskModuleImpl extends AbstractModuleImpl { public class QTaskModuleImpl extends AbstractModuleImpl {

View File

@ -9,8 +9,8 @@ import javax.persistence.Query;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.hostsharing.BasePacType; import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;

View File

@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.qserv.ProcessorException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.core.util.IPv6Trick; import de.hsadmin.core.util.IPv6Trick;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.pac.Hive; import de.hsadmin.mods.pac.Hive;
@ -61,7 +61,7 @@ public class JsonPillarServlet extends HttpServlet {
writer.println(" , \"hiveipv4\": \"" + hive.getInetAddr().getInet4Addr() + "\""); writer.println(" , \"hiveipv4\": \"" + hive.getInetAddr().getInet4Addr() + "\"");
try { try {
writer.println(" , \"hiveipv6\": \"" + hive.getInetAddr().getInet6Addr() + "\""); writer.println(" , \"hiveipv6\": \"" + hive.getInetAddr().getInet6Addr() + "\"");
} catch (ProcessorException e) { } catch (HSAdminException e) {
// dont care // dont care
} }
final long currentTimeSeconds = System.currentTimeMillis() / 1000L; final long currentTimeSeconds = System.currentTimeMillis() / 1000L;
@ -86,7 +86,7 @@ public class JsonPillarServlet extends HttpServlet {
writer.println(" , \"ipv4\": \"" + curINetAddr.getInet4Addr() + "\""); writer.println(" , \"ipv4\": \"" + curINetAddr.getInet4Addr() + "\"");
try { try {
writer.println(" , \"ipv6\": \"" + curINetAddr.getInet6Addr() + "\""); writer.println(" , \"ipv6\": \"" + curINetAddr.getInet6Addr() + "\"");
} catch (ProcessorException e) { } catch (HSAdminException e) {
// dont care // dont care
} }
final PacComponent pacQuota = pac.getPacComponent("QUOTA"); final PacComponent pacQuota = pac.getPacComponent("QUOTA");

View File

@ -12,9 +12,9 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AuthenticationException; import de.hsadmin.core.model.AuthenticationException;
import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.GenericModuleImpl; import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ModuleInterface; import de.hsadmin.core.model.ModuleInterface;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public abstract class AbstractRemote implements IRemote { public abstract class AbstractRemote implements IRemote {

View File

@ -7,11 +7,11 @@ import java.util.regex.Pattern;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.core.model.ReflectionUtil;
import de.hsadmin.core.model.TechnicalException; import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.ReflectionUtil; import de.hsadmin.core.util.HSAdminException;
public abstract class GenericAbstractRemote extends AbstractRemote { public abstract class GenericAbstractRemote extends AbstractRemote {

View File

@ -3,7 +3,7 @@ package de.hsadmin.remote;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.util.HSAdminException;
public interface IRemote { public interface IRemote {

View File

@ -12,11 +12,11 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AuthenticationException; import de.hsadmin.core.model.AuthenticationException;
import de.hsadmin.core.model.DefaultSelectableValues; import de.hsadmin.core.model.DefaultSelectableValues;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.KindOfSelectableValue; import de.hsadmin.core.model.KindOfSelectableValue;
import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.core.model.SelectableValue; import de.hsadmin.core.model.SelectableValue;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
public class ModulePropertiesRemote implements IRemote { public class ModulePropertiesRemote implements IRemote {

View File

@ -6,8 +6,8 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.core.util.TextUtil; import de.hsadmin.core.util.TextUtil;
import de.hsadmin.mods.cust.Customer; import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.pac.BasePac; import de.hsadmin.mods.pac.BasePac;

View File

@ -11,9 +11,9 @@ import java.util.Properties;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO; import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AuthenticationException; import de.hsadmin.core.model.AuthenticationException;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ReadWriteAccess; import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.HSAdminException;
public class PropertyRemote implements IRemote { public class PropertyRemote implements IRemote {

View File

@ -8,9 +8,9 @@ import java.util.Map;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AuthenticationException; import de.hsadmin.core.model.AuthenticationException;
import de.hsadmin.core.model.GenericModuleImpl; import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.dom.Domain; import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;