Compare commits
151 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8e8d2f17b8 | ||
|
f539c87aea | ||
|
aec87c80f9 | ||
|
18a68db9eb | ||
|
673c3ce918 | ||
|
a6420d2c5a | ||
|
39aee47937 | ||
|
3140a373a1 | ||
|
74639d93c5 | ||
|
81d34d4e19 | ||
|
0f6b43605d | ||
|
0709b037a7 | ||
|
86a9476f27 | ||
|
ef637b1b85 | ||
|
71ff5dcd2b | ||
|
bf39b135b2 | ||
|
19422f3827 | ||
|
8ffa54cc6a | ||
|
e5bde743cb | ||
|
18b6f30b35 | ||
|
48892ff0d0 | ||
|
0ec8d64442 | ||
|
2d4105e302 | ||
|
ee21c742a4 | ||
|
df9986361f | ||
|
4aea51728e | ||
|
f583b57c92 | ||
|
7e67742c1c | ||
|
6b5f5006e0 | ||
|
0ea2cb2277 | ||
|
683e0de78d | ||
|
4eb7ac232d | ||
|
fa25a66a65 | ||
|
bfbbee6aea | ||
|
474817403d | ||
|
12499aae20 | ||
|
ade38796a5 | ||
|
955d1918ae | ||
|
ad95bf357b | ||
|
70acf77d37 | ||
|
ddbfd37591 | ||
|
75df8a9a85 | ||
|
9f47eba454 | ||
|
f227d28fe1 | ||
|
1aef34a46a | ||
|
53d2f38fa0 | ||
|
bab2f0356f | ||
|
3336715ed6 | ||
|
83e8edc328 | ||
|
f102f4b203 | ||
|
28f50fa56f | ||
|
8620a4c9a1 | ||
|
c4856fccfb | ||
|
c4f3025c80 | ||
|
e52b8d7308 | ||
|
e713d988d3 | ||
|
d81734371c | ||
|
624d73086f | ||
|
ba45fc8886 | ||
|
43d542d63b | ||
|
b35785093e | ||
|
ae7bd7abb9 | ||
|
ea0b1112e8 | ||
|
d7e610a18d | ||
|
cf6c5e3493 | ||
|
2ea4a23132 | ||
|
ea0c853829 | ||
|
61e5634160 | ||
|
ae2e353ed8 | ||
|
917807bbb0 | ||
|
56b34d3016 | ||
|
8d2a8e3ddf | ||
|
4462a7157f | ||
|
7abf79e7bb | ||
|
1eb93f7ecc | ||
|
5ad5f1b827 | ||
|
bbf5f1389f | ||
|
f9ca46697c | ||
|
d409ef5238 | ||
|
fabb643226 | ||
|
277d9f3399 | ||
|
c826fc5170 | ||
|
352bc4c083 | ||
|
6c54a57852 | ||
|
438b9eec6e | ||
|
4703ae751c | ||
|
a345199918 | ||
|
bfa01e0733 | ||
|
084c6fae35 | ||
|
3fc3920c03 | ||
|
1629ad60b0 | ||
|
63ae4117cd | ||
|
d27eb14da4 | ||
|
5cd78f58a9 | ||
|
92c50c8e48 | ||
|
f358e01d52 | ||
|
bb42be700e | ||
|
203d896066 | ||
|
667960ee75 | ||
|
b974a2521a | ||
|
2299ec4a87 | ||
|
eccfa84055 | ||
|
c812971073 | ||
|
6abbbabb39 | ||
|
6377b9b31c | ||
|
8a36ca7901 | ||
|
da37fd8832 | ||
|
19c43be1d7 | ||
|
3b0e29d5ae | ||
|
521807ac7d | ||
|
33ec937904 | ||
|
53ad73e825 | ||
|
26d03049ec | ||
|
09d069f181 | ||
|
806039220b | ||
|
886580156e | ||
|
75f8c7d596 | ||
|
5c600212a4 | ||
|
72c96911d7 | ||
|
91cce7a8d9 | ||
|
da867ae48b | ||
|
9f8ccd461b | ||
|
6156febca2 | ||
|
c763facb95 | ||
|
d8f2345d6f | ||
|
be09bfc036 | ||
|
a2aad851bb | ||
|
0f16953a98 | ||
|
726058c75d | ||
|
d0c617b70e | ||
|
1b44709320 | ||
|
7894bc88aa | ||
|
cc2a17c81a | ||
|
87d698f828 | ||
|
2c9785af14 | ||
|
93b7e8b8c5 | ||
|
e454bf007d | ||
|
f918b70d5e | ||
|
30211f65ae | ||
|
1ccea7bcd4 | ||
|
79292ec263 | ||
|
5a9d2a0ba4 | ||
|
d7e5379948 | ||
|
de7b440edf | ||
|
69f3721e98 | ||
|
3264be68a9 | ||
|
d211cbb336 | ||
|
67a7817e77 | ||
|
dc08da121e | ||
|
25ce2009af | ||
|
cd6e63d92d |
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,4 +11,4 @@ hs_err_pid*
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
||||
db-migration/bin/
|
||||
*/bin/
|
||||
|
35
README.md
35
README.md
@ -18,3 +18,38 @@ und Ihrer Rolle für die Genossenschaft (technischer oder kaufmännischer Anspre
|
||||
## pac
|
||||
|
||||
Das neue Paket-Modul ist in Entwicklung https://dev.hostsharing.net/doc/hsadmin!hs.hsadmin.jee.git/master/services!doc!package.md
|
||||
|
||||
## run locally
|
||||
|
||||
Alles bauen und Eclipse Konfiguration erzeugen:
|
||||
|
||||
```bash
|
||||
mvn clean install eclipse:clean eclipse
|
||||
```
|
||||
|
||||
Backend auf localhost:8080 starten:
|
||||
|
||||
```bash
|
||||
cd cust-services
|
||||
# entweder:
|
||||
mvn tomee:run
|
||||
# oder:
|
||||
mvn tomee:debug
|
||||
```
|
||||
|
||||
Frontend auf localhost:8081 starten:
|
||||
|
||||
```bash
|
||||
cd ../web
|
||||
# entweder:
|
||||
mvn tomcat7:run
|
||||
# oder:
|
||||
mvnDebug tomcat7:run
|
||||
```
|
||||
|
||||
Sobald der Debugger unter dem in der Programmausgabe genannten Port verbunden ist, startet der Server.
|
||||
|
||||
Login unter http://localhost:8081/ mit ad/ad.
|
||||
|
||||
Im Webfrontend funktioniert natürlich nur der Customer-Teil,
|
||||
weil sich die anderen Module im Legacy Backend befinden.
|
||||
|
@ -1,5 +1,5 @@
|
||||
backendURL=https://config.hostsharing.net:443/hsar/backend
|
||||
;xmlrpcURL=https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin
|
||||
;loginURL=https://login.hostsharing.net:443/cas/v1/tickets
|
||||
xmlrpcURL=http://localhost:8080/cust-webapp/xmlrpc/hsadmin
|
||||
loginURL=TestUmgebung
|
||||
xmlrpcURL=https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin,https://config2.hostsharing.net:443/hsar/xmlrpc/hsadmin
|
||||
loginURL=https://login.hostsharing.net:443/cas/v1/tickets
|
||||
;xmlrpcURL=http://localhost:8080/cust-webapp/xmlrpc/hsadmin
|
||||
;loginURL=TestUmgebung
|
26
cli/pom.xml
26
cli/pom.xml
@ -1,14 +1,14 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0.4</version>
|
||||
</parent>
|
||||
<artifactId>hsadmin-cli</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.3.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin-Cli</name>
|
||||
@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>${hsadmin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
@ -37,12 +37,17 @@
|
||||
<dependency>
|
||||
<groupId>jline</groupId>
|
||||
<artifactId>jline</artifactId>
|
||||
<version>2.14.2</version>
|
||||
<version>2.14.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
<version>15.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
@ -73,12 +78,13 @@
|
||||
<plugin>
|
||||
<groupId>org.vafer</groupId>
|
||||
<artifactId>jdeb</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.10</version>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<dataSet>
|
||||
<data>
|
||||
<src>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</src>
|
||||
<src>
|
||||
${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</src>
|
||||
<dst>hsscript-full.jar</dst>
|
||||
<type>file</type>
|
||||
<mapper>
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
JAVA_HOME=/usr/lib/jvm/default-java/
|
||||
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
||||
ls /usr/lib/jvm/java-11-openjdk-amd64 >/dev/null 2>&1 && JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
|
||||
JAVA=$JAVA_HOME/bin/java
|
||||
exec $JAVA -jar /usr/local/lib/hostsharing/hsadmin/hsscript-full.jar "$@"
|
||||
exec $JAVA $JVM_ARGS -jar /usr/local/lib/hostsharing/hsadmin/hsscript-full.jar "$@"
|
@ -3,7 +3,7 @@ Version: [[version]]
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: default-jre
|
||||
Depends: openjdk-11-jre | openjdk-17-jre
|
||||
Maintainer: Peter Hormanns <peter.hormanns@hostsharing.net>
|
||||
Description: hostsharing command and scripting shell
|
||||
Distribution: hostsharing
|
@ -75,6 +75,12 @@ public class Main {
|
||||
for (String ll : lines) {
|
||||
console.println(ll);
|
||||
}
|
||||
} catch (RuntimeException re) {
|
||||
if (re.getCause() instanceof JSCliException) {
|
||||
console.println(findRootException(re.getCause()));
|
||||
} else {
|
||||
throw re;
|
||||
}
|
||||
} catch (JSCliException e) {
|
||||
console.println(findRootException(e));
|
||||
}
|
||||
@ -92,7 +98,7 @@ public class Main {
|
||||
return "bye".equals(trimmedCommand) || "exit".equals(trimmedCommand) || "quit".equals(trimmedCommand);
|
||||
}
|
||||
|
||||
private static String findRootException(final Exception exp) {
|
||||
private static String findRootException(final Throwable exp) {
|
||||
Throwable cause = exp;
|
||||
while (cause.getCause() != null && cause.getCause() != cause) {
|
||||
cause = cause.getCause();
|
||||
|
@ -11,9 +11,10 @@ import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import de.hsadmin.jscli.cas.TicketProviderFactory;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.jscli.console.ConsoleWrapper;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
import de.hsadmin.login.cas.TicketProviderFactory;
|
||||
|
||||
public class ScriptClient {
|
||||
|
||||
@ -22,51 +23,57 @@ public class ScriptClient {
|
||||
|
||||
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
||||
final RpcClient rpcClient = new RpcClient();
|
||||
engine = new ScriptEngineManager().getEngineByName("js");
|
||||
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
||||
engine.put("xmlrpcclient", rpcClient);
|
||||
engine.put("xmlrpcLastResult", null);
|
||||
completionStrings = new HashSet<String>();
|
||||
completionStrings.add("set");
|
||||
completionStrings.add("where");
|
||||
considerArguments(arguments);
|
||||
try {
|
||||
final InputStream inputResource = getClass().getClassLoader().getResourceAsStream("js/functions.js");
|
||||
engine.eval(new InputStreamReader(inputResource));
|
||||
} catch (ScriptException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
final List<String> methods = rpcClient.listMethods();
|
||||
for (final String method : methods) {
|
||||
final String[] parts = method.split("\\.");
|
||||
if (parts.length == 2) {
|
||||
final String module = parts[0];
|
||||
final String function = parts[1];
|
||||
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
||||
continue;
|
||||
}
|
||||
completionStrings.add(module);
|
||||
final String jsFunctionIdent;
|
||||
if ("delete".equals(function)) {
|
||||
jsFunctionIdent = module + "['remove']";
|
||||
completionStrings.add(module + ".remove");
|
||||
} else {
|
||||
jsFunctionIdent = module + "['" + function + "']";
|
||||
completionStrings.add(module + "." + function);
|
||||
}
|
||||
try {
|
||||
engine.eval(
|
||||
"if (typeof " + module + " === 'undefined')" +
|
||||
" { var " + module + " = { }; };\n" +
|
||||
jsFunctionIdent +
|
||||
" = function(json) { return hsaModuleCall('" + module + "', '" + function + "', json); }"
|
||||
);
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
engine = new ScriptEngineManager().getEngineByName("js");
|
||||
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
||||
engine.put("xmlrpcclient", rpcClient);
|
||||
engine.put("xmlrpcLastResult", null);
|
||||
completionStrings = new HashSet<String>();
|
||||
completionStrings.add("set");
|
||||
completionStrings.add("where");
|
||||
considerArguments(arguments);
|
||||
try {
|
||||
final ClassLoader classLoader = getClass().getClassLoader();
|
||||
final InputStream inputResource = classLoader.getResourceAsStream("js/functions.js");
|
||||
final InputStreamReader inputStreamReader = new InputStreamReader(inputResource);
|
||||
engine.eval(inputStreamReader);
|
||||
} catch (ScriptException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
final List<String> methods = rpcClient.listMethods();
|
||||
for (final String method : methods) {
|
||||
final String[] parts = method.split("\\.");
|
||||
if (parts.length == 2) {
|
||||
final String module = parts[0];
|
||||
final String function = parts[1];
|
||||
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
||||
continue;
|
||||
}
|
||||
completionStrings.add(module);
|
||||
final String jsFunctionIdent;
|
||||
if ("delete".equals(function)) {
|
||||
jsFunctionIdent = module + "['remove']";
|
||||
completionStrings.add(module + ".remove");
|
||||
} else {
|
||||
jsFunctionIdent = module + "['" + function + "']";
|
||||
completionStrings.add(module + "." + function);
|
||||
}
|
||||
try {
|
||||
engine.eval(
|
||||
"if (typeof " + module + " === 'undefined')" +
|
||||
" { var " + module + " = { }; };\n" +
|
||||
jsFunctionIdent +
|
||||
" = function(json) { return hsaModuleCall('" + module + "', '" + function + "', json); }"
|
||||
);
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
console.codeCompletion(getCodeCompletionStrings());
|
||||
} catch (TechnicalException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
console.codeCompletion(getCodeCompletionStrings());
|
||||
}
|
||||
|
||||
public String[] getCodeCompletionStrings() {
|
||||
|
@ -1,13 +0,0 @@
|
||||
package de.hsadmin.jscli;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public interface TicketProvider {
|
||||
|
||||
public String getTicket() throws JSCliException, FileNotFoundException;
|
||||
|
||||
public String getRunAs();
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package de.hsadmin.jscli.cas;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.jscli.TicketProvider;
|
||||
import de.hsadmin.jscli.console.PasswordReader;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public class TicketProviderFactory {
|
||||
|
||||
private static final String HOSTSHARING_LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
||||
private static final String HOSTSHARING_BACKEND_URL = "https://config.hostsharing.net:443/hsar/backend";
|
||||
|
||||
public static TicketProvider getInstance(final PasswordReader console, final String user, final String runAs) throws JSCliException
|
||||
{
|
||||
Config config;
|
||||
try {
|
||||
config = Config.getInstance();
|
||||
final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
|
||||
final String loginURL = config.getProperty("loginURL", HOSTSHARING_LOGIN_URL);
|
||||
if ("TestUmgebung".equalsIgnoreCase(loginURL)) {
|
||||
return new TestTicketProvider(user, runAs);
|
||||
} else {
|
||||
return new CASTicketProvider(console, user, runAs, backendURL, loginURL);
|
||||
}
|
||||
} catch (TechnicalException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package de.hsadmin.jscli.conf;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
@ -24,7 +24,7 @@ public class CommandlineParser {
|
||||
opts.addOption("e", "expr", true, "expression to execute");
|
||||
opts.addOption("f", "file", true, "script file to execute");
|
||||
opts.addOption("i", "interactive", false, "interactive shell");
|
||||
PosixParser parser = new PosixParser();
|
||||
DefaultParser parser = new DefaultParser();
|
||||
try {
|
||||
if (args.length < 1) {
|
||||
printHelp();
|
||||
|
@ -3,7 +3,9 @@ package de.hsadmin.jscli.console;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
import de.hsadmin.login.cas.PasswordReader;
|
||||
import jline.console.ConsoleReader;
|
||||
import jline.console.completer.StringsCompleter;
|
||||
import jline.console.history.FileHistory;
|
||||
@ -11,6 +13,7 @@ import jline.console.history.FileHistory;
|
||||
public class ConsoleWrapper implements PasswordReader {
|
||||
|
||||
private ConsoleReader cons;
|
||||
private FileHistory history;
|
||||
private String prompt;
|
||||
|
||||
public void open(final String prompt) throws JSCliException {
|
||||
@ -20,7 +23,8 @@ public class ConsoleWrapper implements PasswordReader {
|
||||
cons.setExpandEvents(false);
|
||||
cons.setPrompt(prompt);
|
||||
final String userHome = System.getProperty("user.home");
|
||||
cons.setHistory(new FileHistory(new File(userHome + "/.hsscript_history")));
|
||||
history = new FileHistory(new File(userHome + "/.hsscript_history"));
|
||||
cons.setHistory(history);
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
}
|
||||
@ -35,28 +39,34 @@ public class ConsoleWrapper implements PasswordReader {
|
||||
return line;
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
} finally {
|
||||
try {
|
||||
history.flush();
|
||||
} catch (IOException e) {
|
||||
// dont care about
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void println(final String text) throws JSCliException {
|
||||
public void println(final String text) throws TechnicalException {
|
||||
try {
|
||||
if (cons != null) {
|
||||
cons.println(text);
|
||||
} else {
|
||||
throw new JSCliException("cannot write console");
|
||||
throw new TechnicalException("cannot write console");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String readPassword() throws JSCliException {
|
||||
public String readPassword() throws TechnicalException {
|
||||
try {
|
||||
final String pw = cons.readLine("Password: ", new Character('*'));
|
||||
final String pw = cons.readLine("Password: ", Character.valueOf('*'));
|
||||
cons.setPrompt(prompt);
|
||||
return pw;
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
package de.hsadmin.jscli.console;
|
||||
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
|
||||
public interface PasswordReader {
|
||||
|
||||
public String readPassword() throws JSCliException;
|
||||
|
||||
public void println(final String text) throws JSCliException;
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
importClass(java.util.ArrayList);
|
||||
importClass(java.util.HashMap);
|
||||
var JArrayList = Java.type("java.util.ArrayList")
|
||||
var JHashMap = Java.type("java.util.HashMap")
|
||||
|
||||
function hsaParseParam(val) {
|
||||
if (val === null) {
|
||||
@ -20,7 +20,7 @@ function hsaParseParam(val) {
|
||||
}
|
||||
|
||||
function hsaParseParamArray(o) {
|
||||
var lst = new ArrayList();
|
||||
var lst = new JArrayList();
|
||||
var val = '';
|
||||
for (var idx=0; idx < o.length; idx++) {
|
||||
val = o[idx];
|
||||
@ -36,7 +36,7 @@ function hsaParseParamArray(o) {
|
||||
}
|
||||
|
||||
function hsaParseParamObject(o) {
|
||||
var hsh = new HashMap();
|
||||
var hsh = new JHashMap();
|
||||
for (var key in o) {
|
||||
var val = o[key];
|
||||
if (!val === null) {
|
||||
@ -73,7 +73,7 @@ function hsaToNativeJSObject(val) {
|
||||
}
|
||||
|
||||
function hsaModuleCall(mod, fct, json) {
|
||||
var params = new ArrayList();
|
||||
var params = new JArrayList();
|
||||
params.add(casgrantingticket.getRunAs());
|
||||
params.add(casgrantingticket.getTicket());
|
||||
if (typeof json === "undefined") {
|
||||
|
16
cust-services/.externalToolBuilders/OpenJPAEnhancer.launch
Normal file
16
cust-services/.externalToolBuilders/OpenJPAEnhancer.launch
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="enhance,"/>
|
||||
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="enhance,"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="cust-webapp"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/cust-webapp/builder_project/enhance.xml}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Dopenjpa.libs -Dbuild.dir"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/cust-webapp/builder_project}"/>
|
||||
</launchConfiguration>
|
1
cust-services/.gitignore
vendored
1
cust-services/.gitignore
vendored
@ -11,3 +11,4 @@ hs_err_pid*
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
||||
/derby.log
|
||||
|
@ -1,44 +1,52 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cust-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>HSAdmin XML-RPC Customers Webapp</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>${hsadmin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<groupId>jakarta.platform</groupId>
|
||||
<artifactId>jakarta.jakartaee-api</artifactId>
|
||||
<version>8.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.apache.bval</groupId>
|
||||
<artifactId>org.apache.bval.bundle</artifactId>
|
||||
<version>${bval.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa</artifactId>
|
||||
<version>${openjpa.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-core</artifactId>
|
||||
<version>${liquibase.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-server</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<version>${xmlrpc.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
@ -50,67 +58,69 @@
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<configuration>
|
||||
<archiveClasses>true</archiveClasses>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.2.0</version>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/XmlRpcServlet.properties</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-a-jar</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-artifacts</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>attach-artifact</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifacts>
|
||||
<artifact>
|
||||
<file>${project.basedir}/target/cust-webapp-1.0-SNAPSHOT.jar</file>
|
||||
<type>jar</type>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.openejb.maven</groupId>
|
||||
<groupId>org.apache.tomee.maven</groupId>
|
||||
<artifactId>tomee-maven-plugin</artifactId>
|
||||
<version>1.7.4</version>
|
||||
<version>${tomee.version}</version>
|
||||
<configuration>
|
||||
<tomeeVersion>1.7.4</tomeeVersion>
|
||||
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||
<debug>false</debug>
|
||||
<debugPort>8000</debugPort>
|
||||
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||
<context>cust-webapp</context>
|
||||
<libs>
|
||||
<lib>org.postgresql:postgresql:9.4.1212.jre7</lib>
|
||||
<lib>${postgresql.lib}</lib>
|
||||
</libs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa-maven-plugin</artifactId>
|
||||
<version>${openjpa.version}</version>
|
||||
<configuration>
|
||||
<includes>**/bo/*.class</includes>
|
||||
<addDefaultConstructor>true</addDefaultConstructor>
|
||||
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enhancer</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>enhance</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa</artifactId>
|
||||
<version>${openjpa.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -1,11 +0,0 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
public enum AssetAction {
|
||||
PAYMENT,
|
||||
PAYBACK,
|
||||
ADOPTION,
|
||||
HANDOVER,
|
||||
LOSS,
|
||||
CLEARING,
|
||||
PRESCRIPTION
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
import static javax.persistence.CascadeType.ALL;
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -10,15 +9,12 @@ import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
@Entity(name = "Contact")
|
||||
@Table(name = "contact")
|
||||
@ -35,12 +31,6 @@ public class Contact implements Serializable {
|
||||
@ManyToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
@Column(name = "login", columnDefinition = "character varying(40)")
|
||||
private String login;
|
||||
|
||||
@Transient
|
||||
private String password;
|
||||
|
||||
@Column(name = "salut", columnDefinition = "character varying(30)")
|
||||
private String salut;
|
||||
|
||||
@ -94,9 +84,6 @@ public class Contact implements Serializable {
|
||||
@Column(name="role")
|
||||
private List<String> roles;
|
||||
|
||||
@OneToMany(fetch=FetchType.LAZY, cascade = ALL, mappedBy = "contact")
|
||||
private List<PacAdministration> pacAdminList;
|
||||
|
||||
public Contact() {
|
||||
}
|
||||
|
||||
@ -116,22 +103,6 @@ public class Contact implements Serializable {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSalut() {
|
||||
return salut;
|
||||
}
|
||||
@ -260,12 +231,4 @@ public class Contact implements Serializable {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public List<PacAdministration> getPacAdminList() {
|
||||
return pacAdminList;
|
||||
}
|
||||
|
||||
public void setPacAdminList(List<PacAdministration> pacAdminList) {
|
||||
this.pacAdminList = pacAdminList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,13 +65,6 @@ public class Customer implements Serializable {
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date nonDiscContract;
|
||||
|
||||
@Column(name = "shares_updated", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date sharesUpdated;
|
||||
|
||||
@Column(name = "shares_signed", columnDefinition = "integer")
|
||||
private int sharesSigned;
|
||||
|
||||
@Column(name = "free", nullable = false)
|
||||
private boolean free = false;
|
||||
|
||||
@ -176,22 +169,6 @@ public class Customer implements Serializable {
|
||||
this.nonDiscContract = nonDiscContract;
|
||||
}
|
||||
|
||||
public Date getSharesUpdated() {
|
||||
return sharesUpdated;
|
||||
}
|
||||
|
||||
public void setSharesUpdated(final Date sharesUpdated) {
|
||||
this.sharesUpdated = sharesUpdated;
|
||||
}
|
||||
|
||||
public int getSharesSigned() {
|
||||
return sharesSigned;
|
||||
}
|
||||
|
||||
public void setSharesSigned(final int sharesSigned) {
|
||||
this.sharesSigned = sharesSigned;
|
||||
}
|
||||
|
||||
public String getUidVAT() {
|
||||
return uidVAT;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
@ -24,7 +26,7 @@ public class MemberAsset implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "member_share_id", columnDefinition = "integer")
|
||||
@Column(name = "member_asset_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@JoinColumn(name = "bp_id", columnDefinition = "integer", nullable = false)
|
||||
@ -36,7 +38,8 @@ public class MemberAsset implements Serializable {
|
||||
private Date date;
|
||||
|
||||
@Column(name="action", nullable = false)
|
||||
private ShareAction action;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private MemberAssetAction action;
|
||||
|
||||
@Column(name="amount", nullable = false)
|
||||
private BigDecimal amount;
|
||||
@ -76,16 +79,14 @@ public class MemberAsset implements Serializable {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public ShareAction getAction() {
|
||||
public MemberAssetAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(ShareAction action) {
|
||||
public void setAction(MemberAssetAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
@ -94,4 +95,10 @@ public class MemberAsset implements Serializable {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MemberAsset [id=" + id + ", customer=" + (customer!=null ? customer.getName() : null) + ", date=" + date + ", action=" + action
|
||||
+ ", amount=" + amount + ", comment=" + comment + "]";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
/**
|
||||
* Transaktionstyp für Geschaeftsguthaben {@link MemberAsset}.
|
||||
*/
|
||||
public enum MemberAssetAction {
|
||||
|
||||
/** Einzahlung */
|
||||
PAYMENT,
|
||||
|
||||
/** Auszahlung */
|
||||
PAYBACK,
|
||||
|
||||
/** Empfaenger einer Uebertragung */
|
||||
ADOPTION,
|
||||
|
||||
/** Sender einer Uebertragung */
|
||||
HANDOVER,
|
||||
|
||||
/** Verlustabschreibung */
|
||||
LOSS,
|
||||
|
||||
/** Verrechnung mit Schulden */
|
||||
CLEARING,
|
||||
|
||||
/** Verjaehrung **/
|
||||
PRESCRIPTION
|
||||
}
|
@ -7,6 +7,8 @@ import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
@ -35,7 +37,8 @@ public class MemberShare implements Serializable {
|
||||
private Date date;
|
||||
|
||||
@Column(name="action", nullable = false)
|
||||
private ShareAction action;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private MemberShareAction action;
|
||||
|
||||
@Column(name="quantity", nullable = false)
|
||||
private int quantity;
|
||||
@ -67,11 +70,11 @@ public class MemberShare implements Serializable {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public ShareAction getAction() {
|
||||
public MemberShareAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(ShareAction action) {
|
||||
public void setAction(MemberShareAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
@ -91,4 +94,9 @@ public class MemberShare implements Serializable {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MemberShare [id=" + id + ", customer=" + (customer!=null ? customer.getName() : null) + ", date=" + date + ", action=" + action
|
||||
+ ", quantity=" + quantity + ", comment=" + comment + "]";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
/** Transaktionstyp für Geschaeftsanteile {@link MemberShare}.
|
||||
*/
|
||||
public enum MemberShareAction {
|
||||
|
||||
|
||||
/** Zeichnung */
|
||||
SUBSCRIPTION,
|
||||
|
||||
/** Kuendigung */
|
||||
UNSUBSCRIPTION
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import de.hsadmin.bo.pac.Pac;
|
||||
|
||||
@Entity
|
||||
@Table(name="pac_administration")
|
||||
public class PacAdministration {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "pac_administration_id", columnDefinition = "integer")
|
||||
private long pacAdministrationId;
|
||||
|
||||
@ManyToOne(fetch=FetchType.EAGER)
|
||||
@JoinColumn(name="contact_id")
|
||||
private Contact contact;
|
||||
|
||||
@ManyToOne(fetch=FetchType.EAGER)
|
||||
@JoinColumn(name="pac_id")
|
||||
private Pac pac;
|
||||
|
||||
public PacAdministration() {
|
||||
|
||||
}
|
||||
|
||||
public long getPacAdministrationId() {
|
||||
return pacAdministrationId;
|
||||
}
|
||||
|
||||
public void setPacAdministrationId(long pacAdministrationId) {
|
||||
this.pacAdministrationId = pacAdministrationId;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public void setContact(Contact contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public Pac getPac() {
|
||||
return pac;
|
||||
}
|
||||
|
||||
public void setPac(Pac pac) {
|
||||
this.pac = pac;
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package de.hsadmin.bo.customer;
|
||||
|
||||
public enum ShareAction {
|
||||
|
||||
SUBSCRIPTION,
|
||||
UNSUBSCRIPTION
|
||||
|
||||
}
|
@ -13,6 +13,8 @@ import javax.persistence.ManyToMany;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Table(name="domain_option")
|
||||
@Entity(name="DomainOption")
|
||||
@SequenceGenerator(name = "DomainOptionSeqGen", sequenceName = "domain_option_id_seq")
|
||||
@ -49,14 +51,14 @@ public class DomainOption {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DomainOption) {
|
||||
DomainOption opt = (DomainOption) obj;
|
||||
return getName().equals(opt.getName());
|
||||
return StringUtils.equals(getName(), opt.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
return (getName()!=null ? getName() : "").hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,6 @@ import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
// import javax.persistence.EntityListeners;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
@ -26,12 +25,10 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import de.hsadmin.bo.customer.Customer;
|
||||
import de.hsadmin.bo.customer.PacAdministration;
|
||||
|
||||
@Entity(name = "Pac")
|
||||
@Table(name = "packet")
|
||||
@SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
|
||||
// @EntityListeners({PacEntityListener.class})
|
||||
public class Pac implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -83,9 +80,6 @@ public class Pac implements Serializable {
|
||||
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy="pac")
|
||||
private Set<UnixUser> unixUser;
|
||||
|
||||
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy="pac")
|
||||
private Set<PacAdministration> pacAdministrations;
|
||||
|
||||
public void initPacComponents(final EntityManager em, final BasePac aBasepac, final boolean setDefaults) {
|
||||
final Query qAttachedBasepac = em.createQuery("SELECT b FROM BasePac b WHERE b.valid = :valid AND b.name = :name");
|
||||
qAttachedBasepac.setParameter("valid", Boolean.TRUE);
|
||||
@ -209,14 +203,6 @@ public class Pac implements Serializable {
|
||||
this.unixUser = unixUser;
|
||||
}
|
||||
|
||||
public Set<PacAdministration> getPacAdministrations() {
|
||||
return pacAdministrations;
|
||||
}
|
||||
|
||||
public void setPacAdministrations(Set<PacAdministration> pacAdministrations) {
|
||||
this.pacAdministrations = pacAdministrations;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return super.toString() + "{ name=" + name + " }";
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
@ -20,7 +19,6 @@ import javax.persistence.TemporalType;
|
||||
@Entity(name = "PacComponents")
|
||||
@Table(name = "packet_component")
|
||||
@SequenceGenerator(name = "PacCompSeqGen", sequenceName = "packet_component_id_seq")
|
||||
@EntityListeners({PacEntityListener.class})
|
||||
public class PacComponent implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -95,7 +93,7 @@ public class PacComponent implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "pac=" + pac.getName() + ";comp=" + getBaseComponent().getFeature() + ";quantity=" + getQuantity();
|
||||
return "pac=" + (pac!=null?pac.getName():"") + ";comp=" + (getBaseComponent()!=null?getBaseComponent().getFeature():"") + ";quantity=" + getQuantity();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,131 +0,0 @@
|
||||
package de.hsadmin.bo.pac;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
//import javax.jms.JMSException;
|
||||
//import javax.jms.Queue;
|
||||
//import javax.jms.QueueConnection;
|
||||
//import javax.jms.QueueSender;
|
||||
//import javax.jms.QueueSession;
|
||||
//import javax.jms.Session;
|
||||
//import javax.jms.TextMessage;
|
||||
import javax.persistence.PostLoad;
|
||||
import javax.persistence.PostPersist;
|
||||
import javax.persistence.PostUpdate;
|
||||
import javax.persistence.PreRemove;
|
||||
|
||||
//import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
|
||||
public class PacEntityListener {
|
||||
|
||||
public PacEntityListener() {
|
||||
System.out.println("PacEntityListener()");
|
||||
}
|
||||
|
||||
@PostLoad
|
||||
public void onLoad(final Object entity) {
|
||||
System.out.println("onLoad");
|
||||
Pac pac = null;
|
||||
if (entity instanceof PacComponent) {
|
||||
final PacComponent component = (PacComponent) entity;
|
||||
pac = component.getPac();
|
||||
}
|
||||
if (entity instanceof Pac) {
|
||||
pac = (Pac) entity;
|
||||
System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree());
|
||||
}
|
||||
System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree());
|
||||
System.out.println(" from: " + this.toString());
|
||||
}
|
||||
|
||||
@PostPersist
|
||||
public void onCreate(final Object entity) {
|
||||
System.out.println("onCreate");
|
||||
Pac pac = null;
|
||||
if (entity instanceof PacComponent) {
|
||||
final PacComponent component = (PacComponent) entity;
|
||||
pac = component.getPac();
|
||||
}
|
||||
if (entity instanceof Pac) {
|
||||
pac = (Pac) entity;
|
||||
System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree());
|
||||
}
|
||||
if (pac != null) {
|
||||
final String name = pac.getName();
|
||||
System.out.println("Pac: " + name + " free:" + pac.isFree());
|
||||
sendNotification("pac", "add", name);
|
||||
}
|
||||
System.out.println(" from: " + this.toString());
|
||||
}
|
||||
|
||||
@PostUpdate
|
||||
public void onUpdate(final Object entity) {
|
||||
System.out.println("onUpdate");
|
||||
Pac pac = null;
|
||||
if (entity instanceof PacComponent) {
|
||||
final PacComponent component = (PacComponent) entity;
|
||||
pac = component.getPac();
|
||||
}
|
||||
if (entity instanceof Pac) {
|
||||
pac = (Pac) entity;
|
||||
System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree());
|
||||
}
|
||||
if (pac != null) {
|
||||
final String name = pac.getName();
|
||||
System.out.println("Pac: " + name + " free:" + pac.isFree());
|
||||
sendNotification("pac", "update", name);
|
||||
}
|
||||
System.out.println(" from: " + this.toString());
|
||||
}
|
||||
|
||||
@PreRemove
|
||||
public void onDelete(final Object entity) {
|
||||
System.out.println("onDelete");
|
||||
Pac pac = null;
|
||||
if (entity instanceof PacComponent) {
|
||||
final PacComponent component = (PacComponent) entity;
|
||||
pac = component.getPac();
|
||||
}
|
||||
if (entity instanceof Pac) {
|
||||
pac = (Pac) entity;
|
||||
System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree());
|
||||
}
|
||||
if (pac != null) {
|
||||
System.out.println("Pac: " + pac.getName() + " free:" + pac.isFree());
|
||||
final String name = pac.getName();
|
||||
System.out.println("Pac: " + name + " free:" + pac.isFree());
|
||||
sendNotification("pac", "delete", name);
|
||||
}
|
||||
System.out.println(" from: " + this.toString());
|
||||
}
|
||||
|
||||
public void sendNotification(final String module, final String opCode, final String name)
|
||||
{
|
||||
// final ActiveMQConnectionFactory connFactory = new ActiveMQConnectionFactory("ssl://hsh03.hostsharing.net:61617");
|
||||
// QueueConnection connection = null;
|
||||
// try {
|
||||
// connection = connFactory.createQueueConnection("user-pactasks", "Ohf4oh");
|
||||
// connection.start();
|
||||
// final QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
// final Queue queue = session.createQueue("queue.hsadminSystem-pactasks");
|
||||
// final String string = module + "." + opCode + ":" + name + ":" + new Date();
|
||||
// System.out.println(string);
|
||||
// final TextMessage message = session.createTextMessage(string);
|
||||
// final QueueSender sender = session.createSender(queue);
|
||||
// sender.send(message);
|
||||
// sender.close();
|
||||
// session.close();
|
||||
// } catch (JMSException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (connection != null) { try { connection.close(); } catch(JMSException e) { } }
|
||||
// }
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
PacEntityListener listener = new PacEntityListener();
|
||||
listener.sendNotification("pac", "add", "xyz01");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package de.hsadmin.dao.customer;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import de.hsadmin.bo.customer.Customer;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.service.customer.CustomerVO;
|
||||
|
||||
@Stateless
|
||||
public class CustomerDao {
|
||||
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
public CustomerDao() {
|
||||
}
|
||||
|
||||
public CustomerDao(EntityManager em) {
|
||||
this.entityManager = em;
|
||||
}
|
||||
|
||||
public Customer findCustomerByName(final String customerName) throws UserException {
|
||||
return findCustomerByNameImpl(customerName);
|
||||
}
|
||||
|
||||
public Customer findCustomerByName(final CustomerVO prototype) throws UserException, TechnicalException {
|
||||
return findCustomerByNameImpl(prototype.get("name").getValue());
|
||||
}
|
||||
|
||||
private Customer findCustomerByNameImpl(final Object customerName) throws UserException {
|
||||
final Query query = entityManager.createQuery("SELECT c FROM Customer c WHERE c.name = :name");
|
||||
query.setParameter("name", customerName);
|
||||
return (Customer) query.getSingleResult();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package de.hsadmin.rest.customer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.LoginServiceLocal;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.service.customer.ContactServiceLocal;
|
||||
import de.hsadmin.service.customer.ContactVO;
|
||||
|
||||
@Path("/contacts")
|
||||
public class ContactsAPI {
|
||||
|
||||
@Inject
|
||||
LoginServiceLocal loginEJB;
|
||||
|
||||
@Inject
|
||||
ContactServiceLocal contactEJB;
|
||||
|
||||
@GET
|
||||
@Path("/{customer}")
|
||||
public List<ContactVO> getContactsByMember(@PathParam("customer") String customer, @HeaderParam("X-HS-Auth") String ticket) throws UserException, TechnicalException {
|
||||
System.out.println("customer: " + customer);
|
||||
System.out.println("ticket: " + ticket);
|
||||
System.out.println("LoginService: " + loginEJB);
|
||||
RequestContext context = loginEJB.createContext(ticket.trim(), "");
|
||||
ContactVO vo = new ContactVO();
|
||||
vo.setCustomer(customer);
|
||||
List<ContactVO> list = contactEJB.read(context, vo);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
@ -11,6 +14,7 @@ import de.hsadmin.bo.customer.Contact;
|
||||
import de.hsadmin.bo.customer.Customer;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.dao.customer.CustomerDao;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
@ -24,6 +28,9 @@ public class ContactService extends AbstractModule<ContactVO> implements Contact
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@EJB
|
||||
private CustomerDao customerDao;
|
||||
|
||||
@Override
|
||||
public ContactVO buildVO() throws TechnicalException {
|
||||
return new ContactVO();
|
||||
@ -35,7 +42,22 @@ public class ContactService extends AbstractModule<ContactVO> implements Contact
|
||||
throws UserException, TechnicalException {
|
||||
final ContactVO vo = super.create(requestContext, prototype);
|
||||
final Contact bo = new Contact();
|
||||
bo.setCustomer(findCustomerByName(prototype.getCustomer()));
|
||||
final Customer cust = customerDao.findCustomerByName(prototype.getCustomer());
|
||||
final Set<Contact> existingContacts = cust.getContacts();
|
||||
final String[] givenRoles = vo.getRoles();
|
||||
if ((existingContacts == null || existingContacts.isEmpty()) && (givenRoles == null || givenRoles.length == 0)) {
|
||||
final Query query = entityManager.createNativeQuery("SELECT role_name FROM role");
|
||||
final List<?> rolesList = query.getResultList();
|
||||
final List<String> roles = new ArrayList<>();
|
||||
for (int idx = 0; idx < rolesList.size(); idx++) {
|
||||
final Object role = rolesList.get(idx);
|
||||
if (role instanceof String) {
|
||||
roles.add((String) role);
|
||||
}
|
||||
}
|
||||
bo.setRoles(roles);
|
||||
}
|
||||
bo.setCustomer(cust);
|
||||
vo.copyPropertiesToPersistentObject(bo);
|
||||
entityManager.persist(bo);
|
||||
final Contact newBO = findContactByNames(vo);
|
||||
@ -91,10 +113,4 @@ public class ContactService extends AbstractModule<ContactVO> implements Contact
|
||||
return (Contact) query.getSingleResult();
|
||||
}
|
||||
|
||||
private Customer findCustomerByName(final String customer) throws UserException {
|
||||
final Query query = entityManager.createQuery("SELECT c FROM Customer c WHERE c.name = :name");
|
||||
query.setParameter("name", customer);
|
||||
return (Customer) query.getSingleResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractVO;
|
||||
import de.hsadmin.module.property.ElementsType;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Required;
|
||||
@ -29,11 +26,6 @@ public class ContactVO extends AbstractVO implements ValueObject {
|
||||
@Search(SearchPolicy.EQUALS)
|
||||
private String customer;
|
||||
|
||||
@Pattern(regexp="[a-z0-9\\-]*")
|
||||
@Size(min=0,max=40)
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
private String login;
|
||||
|
||||
@Pattern(regexp="[A-Za-z]*")
|
||||
@Size(min=0,max=16)
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
@ -112,10 +104,6 @@ public class ContactVO extends AbstractVO implements ValueObject {
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
private final StringSet roles;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
@ElementsType(PacAdministrationVO.class)
|
||||
private List<PacAdministrationVO> pacAdminList;
|
||||
|
||||
public ContactVO() throws TechnicalException {
|
||||
super();
|
||||
roles = new StringSet();
|
||||
@ -129,14 +117,6 @@ public class ContactVO extends AbstractVO implements ValueObject {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getSalut() {
|
||||
return salut;
|
||||
}
|
||||
@ -265,12 +245,4 @@ public class ContactVO extends AbstractVO implements ValueObject {
|
||||
roles.setStrings(changedRoles);
|
||||
}
|
||||
|
||||
public List<PacAdministrationVO> getPacAdminList() {
|
||||
return pacAdminList;
|
||||
}
|
||||
|
||||
public void setPacAdminList(List<PacAdministrationVO> pacAdminList) {
|
||||
this.pacAdminList = pacAdminList;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import de.hsadmin.bo.customer.Customer;
|
||||
import de.hsadmin.bo.pac.Pac;
|
||||
@ -16,11 +16,14 @@ import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserErrorList;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.DateUtil;
|
||||
import de.hsadmin.dao.customer.CustomerDao;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.impl.AbstractModule;
|
||||
import de.hsadmin.module.property.StringSet;
|
||||
import de.hsadmin.module.property.StringSetProperty;
|
||||
import de.hsadmin.module.util.QueryBuilder;
|
||||
|
||||
@Stateless
|
||||
@ -29,6 +32,9 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@EJB
|
||||
private CustomerDao customerDao;
|
||||
|
||||
@Override
|
||||
public CustomerVO buildVO() throws TechnicalException {
|
||||
return new CustomerVO();
|
||||
@ -41,12 +47,14 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
||||
final CustomerVO customerVO = super.create(requestContext, prototype);
|
||||
final String[] priceLists = customerVO.getPriceLists();
|
||||
if (priceLists == null) {
|
||||
customerVO.setPriceLists(new String[] { "Standard" });
|
||||
final StringSet stringSet = new StringSet();
|
||||
stringSet.setStrings(new String[] { "Standard" });
|
||||
((StringSetProperty) customerVO.get("priceLists")).setValue(stringSet);
|
||||
}
|
||||
final Customer customerBO = new Customer();
|
||||
customerVO.copyPropertiesToPersistentObject(customerBO);
|
||||
entityManager.persist(customerBO);
|
||||
final Customer newBO = findCustomerByName(prototype);
|
||||
final Customer newBO = customerDao.findCustomerByName(prototype);
|
||||
final CustomerVO newVO = new CustomerVO();
|
||||
newVO.copyPropertiesFromPersistentObject(newBO);
|
||||
return newVO;
|
||||
@ -71,7 +79,7 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
||||
throws UserException, TechnicalException {
|
||||
final List<CustomerVO> customersForUpdate = super.update(requestContext, criteria, prototype);
|
||||
for (CustomerVO vo : customersForUpdate) {
|
||||
final Customer customer = findCustomerByName(vo);
|
||||
final Customer customer = customerDao.findCustomerByName(vo);
|
||||
prototype.copyPropertiesToPersistentObject(customer);
|
||||
vo.copyPropertiesFromPersistentObject(customer);
|
||||
}
|
||||
@ -111,10 +119,4 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
||||
errors.raiseException();
|
||||
}
|
||||
|
||||
private Customer findCustomerByName(final CustomerVO prototype) throws UserException, TechnicalException {
|
||||
final Query query = entityManager.createQuery("SELECT c FROM Customer c WHERE c.name = :name");
|
||||
query.setParameter("name", prototype.get("name").getValue());
|
||||
return (Customer) query.getSingleResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,12 +49,6 @@ public class CustomerVO extends AbstractVO {
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
private Date nonDiscContract;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
private Date sharesUpdated;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
private Integer sharesSigned;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
private Boolean free;
|
||||
|
||||
@ -74,10 +68,11 @@ public class CustomerVO extends AbstractVO {
|
||||
|
||||
@ElementsType(SEPADirectDebitVO.class)
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
@Display(visible=DisplayPolicy.NEVER)
|
||||
@Display(visible=DisplayPolicy.OPTIONAL)
|
||||
private List<SEPADirectDebitVO> sepaDirectDebits;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||
@Display(visible=DisplayPolicy.NEVER)
|
||||
private final StringSet priceLists;
|
||||
|
||||
public CustomerVO() throws TechnicalException {
|
||||
@ -141,22 +136,6 @@ public class CustomerVO extends AbstractVO {
|
||||
this.nonDiscContract = nonDiscContract;
|
||||
}
|
||||
|
||||
public Date getSharesUpdated() {
|
||||
return sharesUpdated;
|
||||
}
|
||||
|
||||
public void setSharesUpdated(Date sharesUpdated) {
|
||||
this.sharesUpdated = sharesUpdated;
|
||||
}
|
||||
|
||||
public Integer getSharesSigned() {
|
||||
return sharesSigned;
|
||||
}
|
||||
|
||||
public void setSharesSigned(Integer sharesSigned) {
|
||||
this.sharesSigned = sharesSigned;
|
||||
}
|
||||
|
||||
public Boolean getFree() {
|
||||
return free;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||
import de.hsadmin.xmlrpc.Remote;
|
||||
|
||||
public class MemberAssetRemote extends AbstractRemote<MemberAssetVO> implements Remote {
|
||||
|
||||
@Override
|
||||
protected String getModuleLookup() {
|
||||
return MemberAssetServiceLocal.class.getSimpleName();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
import de.hsadmin.bo.customer.MemberAsset;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.dao.customer.CustomerDao;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.impl.AbstractModule;
|
||||
import de.hsadmin.module.util.QueryBuilder;
|
||||
|
||||
@Stateless
|
||||
public class MemberAssetService extends AbstractModule<MemberAssetVO> implements MemberAssetServiceLocal {
|
||||
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@EJB
|
||||
private CustomerDao customerDao;
|
||||
|
||||
public MemberAssetService() {
|
||||
}
|
||||
|
||||
public MemberAssetService(final EntityManager em, final CustomerDao customerDao) {
|
||||
this.entityManager = em;
|
||||
this.customerDao = customerDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberAssetVO buildVO() throws TechnicalException {
|
||||
return new MemberAssetVO();
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM)})
|
||||
public MemberAssetVO create(final RequestContext requestContext, final MemberAssetVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
final MemberAssetVO vo = super.create(requestContext, prototype);
|
||||
final MemberAsset bo = new MemberAsset();
|
||||
bo.setCustomer(customerDao.findCustomerByName(prototype.getCustomer()));
|
||||
vo.copyPropertiesToPersistentObject(bo);
|
||||
entityManager.persist(bo);
|
||||
final MemberAssetVO newVO = new MemberAssetVO();
|
||||
newVO.copyPropertiesFromPersistentObject(bo);
|
||||
return newVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM), @ScopePolicy(value=Role.CUSTOMER, property="customer")})
|
||||
public List<MemberAssetVO> read(final RequestContext requestContext, final MemberAssetVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
final List<MemberAssetVO> emptyList = super.read(requestContext, criteria);
|
||||
final List<MemberAsset> list = runCriteriaQuery(criteria);
|
||||
for (MemberAsset c : list) {
|
||||
final MemberAssetVO vo = new MemberAssetVO();
|
||||
vo.copyPropertiesFromPersistentObject(c);
|
||||
emptyList.add(vo);
|
||||
}
|
||||
return emptyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM)})
|
||||
public List<MemberAssetVO> update(final RequestContext requestContext, final MemberAssetVO criteria, final MemberAssetVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
throw new TechnicalException(new NotImplementedException("MemberAsset are immutable"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM)})
|
||||
public void delete(final RequestContext requestContext, final MemberAssetVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
throw new TechnicalException(new NotImplementedException("MemberAsset are immutable"));
|
||||
}
|
||||
|
||||
// macht diese Klasse Unit-testbar
|
||||
List<MemberAsset> runCriteriaQuery(final MemberAssetVO criteria) throws UserException, TechnicalException {
|
||||
return QueryBuilder.newBuilder(entityManager, MemberAsset.class).getResultList(criteria);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import de.hsadmin.module.Module;
|
||||
|
||||
@Local
|
||||
public interface MemberAssetServiceLocal extends Module<MemberAssetVO> {
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractVO;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Required;
|
||||
import de.hsadmin.module.property.Search;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
import de.hsadmin.module.property.mapping.DefaultEnumPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.Mapping;
|
||||
import de.hsadmin.module.property.mapping.ReferredStringPersistentObjectMapper;
|
||||
|
||||
public class MemberAssetVO extends AbstractVO implements ValueObject {
|
||||
|
||||
@Mapping(boMapping=ReferredStringPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="customer.name")
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
@Search(SearchPolicy.EQUALS)
|
||||
private String customer;
|
||||
|
||||
@Mapping(boMapping=DefaultEnumPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="customer.name")
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
@Search(SearchPolicy.EQUALS)
|
||||
private String action;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
private Date date;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
private BigDecimal amount;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
private String comment;
|
||||
|
||||
public MemberAssetVO() throws TechnicalException {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(String customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MemberShareVO [customer=" + customer + ", action=" + action + ", date=" + date + ", amount="
|
||||
+ amount + ", comment=" + comment + "]";
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||
import de.hsadmin.xmlrpc.Remote;
|
||||
|
||||
|
||||
public class MemberShareRemote extends AbstractRemote<MemberShareVO> implements Remote {
|
||||
|
||||
@Override
|
||||
protected String getModuleLookup() {
|
||||
return MemberShareServiceLocal.class.getSimpleName();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
import de.hsadmin.bo.customer.MemberShare;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.dao.customer.CustomerDao;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.impl.AbstractModule;
|
||||
import de.hsadmin.module.util.QueryBuilder;
|
||||
|
||||
@Stateless
|
||||
public class MemberShareService extends AbstractModule<MemberShareVO> implements MemberShareServiceLocal {
|
||||
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@EJB
|
||||
private CustomerDao customerDao;
|
||||
|
||||
public MemberShareService() {
|
||||
}
|
||||
|
||||
public MemberShareService(final EntityManager em, final CustomerDao customerDao) {
|
||||
this.entityManager = em;
|
||||
this.customerDao = customerDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberShareVO buildVO() throws TechnicalException {
|
||||
return new MemberShareVO();
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM)})
|
||||
public MemberShareVO create(final RequestContext requestContext, final MemberShareVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
final MemberShareVO vo = super.create(requestContext, prototype);
|
||||
final MemberShare bo = new MemberShare();
|
||||
bo.setCustomer(customerDao.findCustomerByName(prototype.getCustomer()));
|
||||
vo.copyPropertiesToPersistentObject(bo);
|
||||
entityManager.persist(bo);
|
||||
final MemberShareVO newVO = new MemberShareVO();
|
||||
newVO.copyPropertiesFromPersistentObject(bo);
|
||||
return newVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM), @ScopePolicy(value=Role.CUSTOMER, property="customer")})
|
||||
public List<MemberShareVO> read(final RequestContext requestContext, final MemberShareVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
final List<MemberShareVO> emptyList = super.read(requestContext, criteria);
|
||||
final List<MemberShare> list = runCriteriaQuery(criteria);
|
||||
for (MemberShare c : list) {
|
||||
final MemberShareVO vo = new MemberShareVO();
|
||||
vo.copyPropertiesFromPersistentObject(c);
|
||||
emptyList.add(vo);
|
||||
}
|
||||
return emptyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM)})
|
||||
public List<MemberShareVO> update(final RequestContext requestContext, final MemberShareVO criteria, final MemberShareVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
throw new TechnicalException(new NotImplementedException("MemberShares are immutable"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({@ScopePolicy(Role.SYSTEM)})
|
||||
public void delete(final RequestContext requestContext, final MemberShareVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
throw new TechnicalException(new NotImplementedException("MemberShares are immutable"));
|
||||
}
|
||||
|
||||
// macht diese Klasse Unit-testbar
|
||||
List<MemberShare> runCriteriaQuery(final MemberShareVO criteria) throws UserException, TechnicalException {
|
||||
return QueryBuilder.newBuilder(entityManager, MemberShare.class).getResultList(criteria);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import de.hsadmin.module.Module;
|
||||
|
||||
@Local
|
||||
public interface MemberShareServiceLocal extends Module<MemberShareVO> {
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractVO;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Required;
|
||||
import de.hsadmin.module.property.Search;
|
||||
import de.hsadmin.module.property.SearchPolicy;
|
||||
import de.hsadmin.module.property.mapping.DefaultEnumPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.Mapping;
|
||||
import de.hsadmin.module.property.mapping.ReferredStringPersistentObjectMapper;
|
||||
|
||||
public class MemberShareVO extends AbstractVO implements ValueObject {
|
||||
|
||||
@Mapping(boMapping=ReferredStringPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="customer.name")
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
@Search(SearchPolicy.EQUALS)
|
||||
private String customer;
|
||||
|
||||
@Mapping(boMapping=DefaultEnumPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="customer.name")
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
@Search(SearchPolicy.EQUALS)
|
||||
private String action;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
private Date date;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
private Integer quantity;
|
||||
|
||||
@ReadWrite(ReadWritePolicy.WRITEONCE)
|
||||
@Required(true)
|
||||
private String comment;
|
||||
|
||||
public MemberShareVO() throws TechnicalException {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(String customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MemberShareVO [customer=" + customer + ", action=" + action + ", date=" + date + ", quantity="
|
||||
+ quantity + ", comment=" + comment + "]";
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractVO;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.Mapping;
|
||||
import de.hsadmin.module.property.mapping.ReferredStringPersistentObjectMapper;
|
||||
|
||||
public class PacAdministrationVO extends AbstractVO implements ValueObject {
|
||||
|
||||
@Mapping(
|
||||
boMapping=ReferredStringPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="contact.customer.name")
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String customer;
|
||||
|
||||
@Mapping(
|
||||
boMapping=ReferredStringPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="contact.login")
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String contactLogin;
|
||||
|
||||
@Mapping(
|
||||
boMapping=ReferredStringPersistentObjectMapper.class,
|
||||
rpcMapping=DefaultStringParameterMapMapper.class,
|
||||
boMappingPath="pac.name")
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
private String packetName;
|
||||
|
||||
public PacAdministrationVO() throws TechnicalException {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(String customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getContactLogin() {
|
||||
return contactLogin;
|
||||
}
|
||||
|
||||
public void setContactLogin(String contactLogin) {
|
||||
this.contactLogin = contactLogin;
|
||||
}
|
||||
|
||||
public String getPacketName() {
|
||||
return packetName;
|
||||
}
|
||||
|
||||
public void setPacketName(String packetName) {
|
||||
this.packetName = packetName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||
import de.hsadmin.xmlrpc.Remote;
|
||||
|
||||
public class RoleRemote extends AbstractRemote<RoleVO> implements Remote {
|
||||
|
||||
@Override
|
||||
protected String getModuleLookup() {
|
||||
return "RoleServiceLocal";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.impl.AbstractModule;
|
||||
import de.hsadmin.module.property.StringProperty;
|
||||
|
||||
@Stateless
|
||||
public class RoleService extends AbstractModule<RoleVO> implements RoleServiceLocal {
|
||||
|
||||
@Override
|
||||
public RoleVO buildVO() throws TechnicalException {
|
||||
return new RoleVO();
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({ @ScopePolicy(Role.NONE) })
|
||||
public RoleVO create(RequestContext requestContext, RoleVO prototype) throws UserException, TechnicalException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({ @ScopePolicy(Role.ANY) })
|
||||
public List<RoleVO> read(RequestContext requestContext, RoleVO criteria) throws UserException, TechnicalException {
|
||||
final Role loginRole = requestContext.getLoginRole();
|
||||
final ArrayList<RoleVO> userRoles = new ArrayList<RoleVO>();
|
||||
final RoleVO roleVO = buildVO();
|
||||
roleVO.setRole(loginRole.name());
|
||||
((StringProperty) roleVO.get("role")).setValue(loginRole.name());
|
||||
userRoles.add(roleVO);
|
||||
return userRoles;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({ @ScopePolicy(Role.NONE) })
|
||||
public List<RoleVO> update(RequestContext requestContext, RoleVO criteria, RoleVO prototype)
|
||||
throws UserException, TechnicalException {
|
||||
return new ArrayList<RoleVO>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequiredScope({ @ScopePolicy(Role.NONE) })
|
||||
public void delete(RequestContext requestContext, RoleVO criteria) throws UserException, TechnicalException {
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import de.hsadmin.module.Module;
|
||||
|
||||
@Local
|
||||
public interface RoleServiceLocal extends Module<RoleVO> {
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package de.hsadmin.service.customer;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractVO;
|
||||
import de.hsadmin.module.property.ReadWrite;
|
||||
import de.hsadmin.module.property.ReadWritePolicy;
|
||||
import de.hsadmin.module.property.Required;
|
||||
|
||||
public class RoleVO extends AbstractVO implements ValueObject {
|
||||
|
||||
@ReadWrite(ReadWritePolicy.READ)
|
||||
@Required(true)
|
||||
@Size(min=1,max=24)
|
||||
private String role;
|
||||
|
||||
public RoleVO() throws TechnicalException {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
}
|
@ -2,16 +2,16 @@ package de.hsadmin.service.customer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import de.hsadmin.bo.customer.Contact;
|
||||
import de.hsadmin.bo.customer.Customer;
|
||||
import de.hsadmin.bo.customer.SEPADirectDebit;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.dao.customer.CustomerDao;
|
||||
import de.hsadmin.login.RequestContext;
|
||||
import de.hsadmin.login.RequiredScope;
|
||||
import de.hsadmin.login.Role;
|
||||
@ -25,6 +25,9 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@EJB
|
||||
private CustomerDao customerDao;
|
||||
|
||||
@Override
|
||||
public SEPADirectDebitVO buildVO() throws TechnicalException {
|
||||
return new SEPADirectDebitVO();
|
||||
@ -36,7 +39,7 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
||||
throws UserException, TechnicalException {
|
||||
final SEPADirectDebitVO vo = super.create(requestContext, prototype);
|
||||
final SEPADirectDebit bo = new SEPADirectDebit();
|
||||
bo.setCustomer(findCustomerByName(prototype.getCustomer()));
|
||||
bo.setCustomer(customerDao.findCustomerByName(prototype.getCustomer()));
|
||||
vo.copyPropertiesToPersistentObject(bo);
|
||||
entityManager.persist(bo);
|
||||
final SEPADirectDebit newBO = findMandatByValues(vo);
|
||||
@ -77,9 +80,9 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
||||
public void delete(final RequestContext requestContext, final SEPADirectDebitVO criteria)
|
||||
throws UserException, TechnicalException {
|
||||
super.delete(requestContext, criteria);
|
||||
final List<Contact> list = QueryBuilder.newBuilder(entityManager, Contact.class).getResultList(criteria);
|
||||
for (Contact c : list) {
|
||||
entityManager.remove(c);
|
||||
final List<SEPADirectDebit> list = QueryBuilder.newBuilder(entityManager, SEPADirectDebit.class).getResultList(criteria);
|
||||
for (SEPADirectDebit m : list) {
|
||||
entityManager.remove(m);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,11 +94,4 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
||||
query.setParameter("mandatSigned", prototype.get("mandatSigned").getValue());
|
||||
return (SEPADirectDebit) query.getSingleResult();
|
||||
}
|
||||
|
||||
private Customer findCustomerByName(final String customer) throws UserException {
|
||||
final Query query = entityManager.createQuery("SELECT c FROM Customer c WHERE c.name = :name");
|
||||
query.setParameter("name", customer);
|
||||
return (Customer) query.getSingleResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
@ -26,6 +27,7 @@ import de.hsadmin.login.Role;
|
||||
import de.hsadmin.login.ScopePolicy;
|
||||
import de.hsadmin.module.impl.AbstractModule;
|
||||
import de.hsadmin.module.util.QueryBuilder;
|
||||
import de.hsadmin.dao.customer.CustomerDao;
|
||||
|
||||
@Stateless
|
||||
public class PacService extends AbstractModule<PacVO> implements PacServiceLocal {
|
||||
@ -33,6 +35,9 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
||||
@PersistenceContext(name="hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@EJB
|
||||
private CustomerDao customerDao;
|
||||
|
||||
@Override
|
||||
public PacVO buildVO() throws TechnicalException {
|
||||
return new PacVO();
|
||||
@ -64,7 +69,7 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
||||
throw new UserException(new UserError(UserError.MSG_MISSING_AUTHORIZATION, "add"));
|
||||
}
|
||||
}
|
||||
bo.setCustomer(findCustomerByName(customerProperty));
|
||||
bo.setCustomer(customerDao.findCustomerByName(customerProperty));
|
||||
vo.copyPropertiesToPersistentObject(bo);
|
||||
if (bo.getCreated() == null) {
|
||||
bo.setCreated(new Date());
|
||||
@ -100,7 +105,7 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
||||
final Pac bo = findPacByName(vo.getName());
|
||||
final String customerName = prototype.getCustomer();
|
||||
if (customerName != null && !customerName.isEmpty()) {
|
||||
final Customer customer = findCustomerByName(customerName);
|
||||
final Customer customer = customerDao.findCustomerByName(customerName);
|
||||
bo.setCustomer(customer);
|
||||
}
|
||||
prototype.copyPropertiesToPersistentObject(bo);
|
||||
@ -162,11 +167,4 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
||||
query.setParameter("name", value);
|
||||
return (BasePac) query.getSingleResult();
|
||||
}
|
||||
|
||||
private Customer findCustomerByName(final String value) {
|
||||
final Query query = entityManager.createQuery("SELECT c FROM Customer c WHERE c.name = :name");
|
||||
query.setParameter("name", value);
|
||||
return (Customer) query.getSingleResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,9 @@
|
||||
<jta-data-source>HsarDataSource</jta-data-source>
|
||||
<class>de.hsadmin.bo.customer.Contact</class>
|
||||
<class>de.hsadmin.bo.customer.Customer</class>
|
||||
<class>de.hsadmin.bo.customer.MemberShare</class>
|
||||
<class>de.hsadmin.bo.customer.MemberAsset</class>
|
||||
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
|
||||
<class>de.hsadmin.bo.customer.PacAdministration</class>
|
||||
<class>de.hsadmin.bo.domain.Domain</class>
|
||||
<class>de.hsadmin.bo.domain.DomainOption</class>
|
||||
<class>de.hsadmin.bo.domain.EMailAddress</class>
|
||||
|
@ -1,6 +1,8 @@
|
||||
role=de.hsadmin.service.customer.RoleRemote
|
||||
customer=de.hsadmin.service.customer.CustomerRemote
|
||||
contact=de.hsadmin.service.customer.ContactRemote
|
||||
mandat=de.hsadmin.service.customer.SEPADirectDebitRemote
|
||||
memberShare=de.hsadmin.service.customer.MemberShareRemote
|
||||
memberAsset=de.hsadmin.service.customer.MemberAssetRemote
|
||||
hive=de.hsadmin.service.pac.HiveRemote
|
||||
pac=de.hsadmin.service.pac.PacRemote
|
||||
property=de.hsadmin.service.property.PropertyRemote
|
@ -1,8 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<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">
|
||||
<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">
|
||||
|
||||
<servlet>
|
||||
<servlet-name>XmlRpcServlet</servlet-name>
|
||||
@ -18,5 +17,4 @@
|
||||
<url-pattern>/xmlrpc/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
</web-app>
|
||||
|
@ -1,34 +0,0 @@
|
||||
package de.hsadmin.test.pac;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PacIT {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
48
cust-services/src/test/resources/META-INF/persistence.xml
Normal file
48
cust-services/src/test/resources/META-INF/persistence.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
|
||||
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||
<persistence-unit name="HSADMIN_H2_TEST_DB" transaction-type="RESOURCE_LOCAL">
|
||||
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
||||
|
||||
<!-- auto scanning fails if there are methods returning entities in the test :-( -->
|
||||
<class>de.hsadmin.bo.customer.Contact</class>
|
||||
<class>de.hsadmin.bo.customer.Customer</class>
|
||||
<class>de.hsadmin.bo.customer.MemberShare</class>
|
||||
<class>de.hsadmin.bo.customer.MemberAsset</class>
|
||||
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
|
||||
<class>de.hsadmin.bo.domain.Domain</class>
|
||||
<class>de.hsadmin.bo.domain.DomainOption</class>
|
||||
<class>de.hsadmin.bo.domain.EMailAddress</class>
|
||||
<class>de.hsadmin.bo.pac.BaseComponent</class>
|
||||
<class>de.hsadmin.bo.pac.BasePac</class>
|
||||
<class>de.hsadmin.bo.pac.Component</class>
|
||||
<class>de.hsadmin.bo.pac.EMailAlias</class>
|
||||
<class>de.hsadmin.bo.pac.Hive</class>
|
||||
<class>de.hsadmin.bo.pac.INetAddress</class>
|
||||
<class>de.hsadmin.bo.pac.Pac</class>
|
||||
<class>de.hsadmin.bo.pac.PacComponent</class>
|
||||
<class>de.hsadmin.bo.pac.UnixUser</class>
|
||||
|
||||
<properties>
|
||||
|
||||
<!-- HSQLDB
|
||||
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:.hsadmin-test-db" />
|
||||
<property name="javax.persistence.jdbc.user" value="sa" />
|
||||
-->
|
||||
|
||||
<!-- H2 -->
|
||||
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:.hsadmin-test-db;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;MVCC=true" />
|
||||
<property name="javax.persistence.jdbc.user" value="sa" />
|
||||
|
||||
<!-- Derby
|
||||
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:derby:.hsadmin-test-db/derbydb3;create=true" /> -->
|
||||
|
||||
<!-- OpenJPA -->
|
||||
<property name="openjpa.RuntimeUnenhancedClasses" value="warn" />
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
@ -1,4 +1,4 @@
|
||||
ticketvalidator.class=de.hsadmin.login.TestTicketValidator
|
||||
ticketvalidator.class=de.hsadmin.login.cas.TestTicketValidator
|
||||
cas.validate.url=https://login.hostsharing.net:443/cas/proxyValidate
|
||||
cas.service.url=https://config.hostsharing.net:443/hsar/backend
|
||||
accountprefix.hostmaster=hsh01
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>database-webapp</artifactId>
|
||||
@ -15,35 +15,34 @@
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>framework</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>${hsadmin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>cust-webapp</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>${hsadmin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
<artifactId>geronimo-jpa_2.2_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<artifactId>geronimo-ejb_3.1_spec</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
||||
<artifactId>geronimo-validation_2.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-server</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<version>${xmlrpc.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
@ -56,23 +55,17 @@
|
||||
<finalName>database-webapp</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<archiveClasses>true</archiveClasses>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.openejb.maven</groupId>
|
||||
<groupId>org.apache.tomee.maven</groupId>
|
||||
<artifactId>tomee-maven-plugin</artifactId>
|
||||
<version>1.7.4</version>
|
||||
<version>${tomee.version}</version>
|
||||
<configuration>
|
||||
<tomeeVersion>1.7.4</tomeeVersion>
|
||||
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||
<debug>false</debug>
|
||||
<debugPort>8000</debugPort>
|
||||
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||
<libs>
|
||||
<lib>org.postgresql:postgresql:9.4.1212.jre7</lib>
|
||||
<lib>${postgresql.lib}</lib>
|
||||
</libs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
1
db-migration/.gitignore
vendored
1
db-migration/.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings/
|
||||
/bin/
|
||||
|
@ -74,31 +74,17 @@ INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quanti
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
|
||||
SELECT basepacket_id, basecomponent_id, 10, 1000, 10, 10, 0, false, 430 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='TRAFFIC';
|
||||
|
||||
--
|
||||
-- Table: role
|
||||
--
|
||||
INSERT INTO role (role_name) VALUES ('billing');
|
||||
INSERT INTO role (role_name) VALUES ('operation');
|
||||
|
||||
--
|
||||
-- Table: business_partner
|
||||
--
|
||||
INSERT INTO business_partner (member_id, member_code, member_since, shares_signed, free, indicator_vat, exempt_vat)
|
||||
VALUES (10000, 'hsh00-hsh', current_date, 0, TRUE, 'NET', FALSE);
|
||||
INSERT INTO business_partner (member_id, member_code, member_since, free, indicator_vat, exempt_vat)
|
||||
VALUES (10000, 'hsh00-hsh', current_date, TRUE, 'NET', FALSE);
|
||||
|
||||
--
|
||||
-- table: contact
|
||||
--
|
||||
INSERT INTO contact (bp_id, salut, first_name, last_name, firma, email)
|
||||
SELECT bp_id, 'Herr', 'Sigi', 'Superb', 'Hosting Inc.', 'info@example.com' FROM business_partner WHERE member_id=10000;
|
||||
|
||||
--
|
||||
-- table: contactrole_ref
|
||||
--
|
||||
INSERT INTO contactrole_ref ( contact_id, role )
|
||||
SELECT contact_id, 'billing' FROM contact WHERE email='info@example.com';
|
||||
INSERT INTO contactrole_ref ( contact_id, role )
|
||||
SELECT contact_id, 'operation' FROM contact WHERE email='info@example.com';
|
||||
SELECT bp_id, 'Herr', 'Uwe', 'Mueller', 'Hostsharing eG', 'service@hostsharing.net' FROM business_partner WHERE member_id=10000;
|
||||
|
||||
--
|
||||
-- Table: inet_addr
|
||||
@ -213,10 +199,11 @@ INSERT INTO domain_option (domain_option_name)
|
||||
--
|
||||
-- table: price_list
|
||||
--
|
||||
INSERT INTO price_list VALUES (1, 'Default Price List');
|
||||
INSERT INTO price_list (name) VALUES ('Default Price List');
|
||||
|
||||
--
|
||||
-- table: customer_price_list_mapping
|
||||
--
|
||||
INSERT INTO pricelist_ref (SELECT bp_id, 'Default Price List' FROM business_partner);
|
||||
INSERT INTO pricelist_ref (SELECT business_partner.bp_id, price_list.name FROM business_partner, price_list);
|
||||
|
||||
|
||||
|
43
db-migration/database/hsdb-drop.sql
Normal file
43
db-migration/database/hsdb-drop.sql
Normal file
@ -0,0 +1,43 @@
|
||||
DROP TABLE pricelist_ref ;
|
||||
DROP TABLE price ;
|
||||
DROP TABLE price_list CASCADE ;
|
||||
-- DROP VIEW business_partner_ticket ;
|
||||
DROP TABLE sepa_mandat ;
|
||||
DROP SEQUENCE sepa_mandat_id_seq ;
|
||||
DROP SEQUENCE contact_contact_id_seq ;
|
||||
DROP TABLE contact CASCADE ;
|
||||
DROP TABLE database ;
|
||||
DROP TABLE database_user ;
|
||||
DROP SEQUENCE database_database_id_seq ;
|
||||
DROP SEQUENCE dbuser_dbuser_id_seq ;
|
||||
DROP TABLE emailaddr ;
|
||||
DROP SEQUENCE emailaddr_emailaddr_id_seq ;
|
||||
DROP TABLE emailalias ;
|
||||
DROP SEQUENCE emailalias_emailalias_id_seq ;
|
||||
DROP TABLE domain__domain_option ;
|
||||
DROP TABLE domain_option ;
|
||||
DROP SEQUENCE domain_option_id_seq ;
|
||||
DROP TABLE domain ;
|
||||
DROP SEQUENCE domain_domain_id_seq ;
|
||||
DROP TABLE queue_task ;
|
||||
DROP SEQUENCE queue_task_id_seq ;
|
||||
DROP TABLE unixuser CASCADE ;
|
||||
DROP SEQUENCE unixuser_unixuser_id_seq ;
|
||||
DROP TABLE packet_component ;
|
||||
DROP TABLE component ;
|
||||
DROP TABLE basecomponent ;
|
||||
DROP TABLE basepacket CASCADE ;
|
||||
DROP SEQUENCE basecomponent_basecomponent_seq ;
|
||||
DROP SEQUENCE basepacket_basepacket_id_seq ;
|
||||
DROP TABLE packet ;
|
||||
DROP SEQUENCE packet_packet_id_seq ;
|
||||
DROP TABLE hive ;
|
||||
DROP SEQUENCE hive_hive_id_seq ;
|
||||
DROP TABLE inet_addr ;
|
||||
DROP SEQUENCE inet_addr_inet_addr_id_seq ;
|
||||
DROP TABLE business_partner CASCADE ;
|
||||
DROP SEQUENCE business_partner_bp_id_seq ;
|
||||
DROP SEQUENCE packet_component_id_seq ;
|
||||
DROP SEQUENCE component_id_seq ;
|
||||
DROP TABLE contactrole_ref CASCADE ;
|
||||
DROP TABLE role CASCADE ;
|
50
db-migration/database/hsdb-migrate.sql
Normal file
50
db-migration/database/hsdb-migrate.sql
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
CREATE TABLE member_asset (
|
||||
member_asset_id integer NOT NULL,
|
||||
bp_id integer NOT NULL,
|
||||
date date,
|
||||
action character varying(60),
|
||||
amount numeric,
|
||||
comment character varying(160)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE member_asset_member_asset_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE member_asset_member_asset_id_seq OWNED BY member_asset.member_asset_id;
|
||||
|
||||
ALTER TABLE ONLY member_asset ALTER COLUMN member_asset_id SET DEFAULT nextval('member_asset_member_asset_id_seq'::regclass);
|
||||
|
||||
CREATE TABLE member_share (
|
||||
member_share_id integer NOT NULL,
|
||||
bp_id integer NOT NULL,
|
||||
date date,
|
||||
action character varying(60),
|
||||
quantity integer,
|
||||
comment character varying(160)
|
||||
);
|
||||
|
||||
CREATE SEQUENCE member_share_member_share_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE member_share_member_share_id_seq OWNED BY member_share.member_share_id;
|
||||
|
||||
ALTER TABLE ONLY member_share ALTER COLUMN member_share_id SET DEFAULT nextval('member_share_member_share_id_seq'::regclass);
|
||||
|
||||
ALTER TABLE ONLY member_asset
|
||||
ADD CONSTRAINT pk_member_asset PRIMARY KEY (member_asset_id);
|
||||
|
||||
ALTER TABLE ONLY member_share
|
||||
ADD CONSTRAINT pk_member_share PRIMARY KEY (member_share_id);
|
||||
|
||||
ALTER TABLE business_partner DROP COLUMN shares_updated ;
|
||||
|
||||
ALTER TABLE business_partner DROP COLUMN shares_signed ;
|
File diff suppressed because it is too large
Load Diff
@ -1,29 +0,0 @@
|
||||
CREATE TABLE pac_administration (
|
||||
pac_administration_id integer NOT NULL,
|
||||
contact_id integer NOT NULL,
|
||||
pac_id integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE pac_administration_pac_administration_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER SEQUENCE pac_administration_pac_administration_id_seq OWNED BY pac_administration.pac_administration_id;
|
||||
|
||||
ALTER TABLE ONLY pac_administration
|
||||
ALTER COLUMN pac_administration_id SET DEFAULT nextval('pac_administration_pac_administration_id_seq'::regclass);
|
||||
|
||||
ALTER TABLE ONLY pac_administration
|
||||
ADD CONSTRAINT pk_pac_administration PRIMARY KEY (pac_administration_id);
|
||||
|
||||
ALTER TABLE ONLY pac_administration
|
||||
ADD CONSTRAINT pac_administration_contact_ref FOREIGN KEY (contact_id) REFERENCES contact(contact_id);
|
||||
|
||||
ALTER TABLE ONLY pac_administration
|
||||
ADD CONSTRAINT pac_administration_pac_ref FOREIGN KEY (pac_id) REFERENCES packet(packet_id);
|
||||
|
||||
ALTER TABLE ONLY contact
|
||||
ADD COLUMN login character varying(40);
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0.4</version>
|
||||
</parent>
|
||||
<artifactId>db-migration</artifactId>
|
||||
<packaging>war</packaging>
|
||||
@ -12,13 +12,13 @@
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>${servlet.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-core</artifactId>
|
||||
<version>3.5.3</version>
|
||||
<version>${liquibase.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -26,20 +26,26 @@
|
||||
<finalName>db-migration</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.openejb.maven</groupId>
|
||||
<groupId>org.apache.tomee.maven</groupId>
|
||||
<artifactId>tomee-maven-plugin</artifactId>
|
||||
<version>1.7.4</version>
|
||||
<version>${tomee.version}</version>
|
||||
<configuration>
|
||||
<tomeeVersion>1.7.4</tomeeVersion>
|
||||
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||
<debug>false</debug>
|
||||
<debugPort>8000</debugPort>
|
||||
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||
<libs>
|
||||
<lib>org.postgresql:postgresql:9.4.1212.jre7</lib>
|
||||
<lib>${postgresql.lib}</lib>
|
||||
</libs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -752,33 +752,11 @@
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet author="phormanns" id="ph-20170412-01">
|
||||
<createTable tableName="pac_administration">
|
||||
<column autoIncrement="true" name="pac_administration_id" type="SERIAL">
|
||||
<constraints primaryKey="true" primaryKeyName="pk_pac_administration"/>
|
||||
</column>
|
||||
<column name="contact_id" type="INT">
|
||||
<constraints
|
||||
foreignKeyName="pac_administration_contact_ref"
|
||||
referencedTableName="contact"
|
||||
referencedColumnNames="contact_id"
|
||||
nullable="false"/>
|
||||
</column>
|
||||
<column name="pac_id" type="INT">
|
||||
<constraints
|
||||
foreignKeyName="pac_administration_pac_ref"
|
||||
referencedTableName="packet"
|
||||
referencedColumnNames="packet_id"
|
||||
nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addColumn tableName="contact">
|
||||
<column name="login" type="VARCHAR(40)"/>
|
||||
</addColumn>
|
||||
<addUniqueConstraint
|
||||
columnNames="login"
|
||||
constraintName="unique_contact_login"
|
||||
tableName="contact"/>
|
||||
<changeSet author="phormanns" id="ph-20170729-01">
|
||||
<dropColumn tableName="business_partner"
|
||||
columnName="shares_updated"/>
|
||||
<dropColumn tableName="business_partner"
|
||||
columnName="shares_signed"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
@ -1,60 +1,54 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>framework</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-parent</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</parent>
|
||||
<artifactId>framework</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin Framework</name>
|
||||
<name>HSAdmin Framework</name>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>jakarta.platform</groupId>
|
||||
<artifactId>jakarta.jakartaee-api</artifactId>
|
||||
<version>8.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.apache.bval</groupId>
|
||||
<artifactId>org.apache.bval.bundle</artifactId>
|
||||
<version>${bval.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-server</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<version>${xmlrpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa</artifactId>
|
||||
<version>${openjpa.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.liquibase</groupId>
|
||||
<artifactId>liquibase-core</artifactId>
|
||||
<version>${liquibase.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
|
@ -4,6 +4,10 @@ public class TechnicalException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public TechnicalException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
|
||||
public TechnicalException(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ public class UserError {
|
||||
public static final String MSG_INVALID_DATEFORMAT = "MSG_INVALID_DATEFORMAT";
|
||||
public static final String MSG_FIELD_REQUIRES_MINLENGTH = "MSG_FIELD_REQUIRES_MINLENGTH";
|
||||
public static final String MSG_FIELD_EXCEEDS_MAXLENGTH = "MSG_FIELD_EXCEEDS_MAXLENGTH";
|
||||
public static final String MSG_FIELD_DOESNOT_MATCH_REGEXP = "MSG_FIELD_DOESNOT_MATCH_REGEXP";
|
||||
public static final String MSG_UNKNOWN_KEY = "MSG_UNKNOWN_KEY";
|
||||
public static final String MSG_INT_VALUE_EXPECTED = "MSG_INT_VALUE_EXPECTED";
|
||||
public static final String MSG_PAC_NOT_CANCELLED = "MSG_PAC_NOT_CANCELLED";
|
||||
|
@ -5,6 +5,11 @@ import java.beans.PropertyDescriptor;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
@ -38,7 +43,7 @@ public class ReflectionUtil {
|
||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||
return propertyDescriptor.getReadMethod().invoke(anObject);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
|
||||
throw new TechnicalException(e);
|
||||
throw new TechnicalException("cannot get value from " + anObject + "." + propertyName, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,17 +52,50 @@ public class ReflectionUtil {
|
||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||
propertyDescriptor.getWriteMethod().invoke(anObject, value);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
|
||||
throw new TechnicalException(e);
|
||||
throw new TechnicalException("cannot set " + value + " to " + anObject + "." + propertyName, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object newInstance(final Object anObject, String propertyName) throws TechnicalException {
|
||||
try {
|
||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||
final Object newInstance = propertyDescriptor.getReadMethod().getReturnType().newInstance();
|
||||
final Object newInstance = propertyDescriptor.getReadMethod().getReturnType().getDeclaredConstructor().newInstance();
|
||||
invokeSetter(anObject, propertyName, newInstance);
|
||||
return newInstance;
|
||||
} catch (InstantiationException | IllegalAccessException | IntrospectionException | TechnicalException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | IntrospectionException | TechnicalException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection<String> getDeclaredFieldNames(Class<?> clazz) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
Collection<String> fieldNames = new ArrayList<String>();
|
||||
for ( Field f: fields ) {
|
||||
if ( (f.getModifiers() & Modifier.STATIC) == 0 ) {
|
||||
fieldNames.add(f.getName());
|
||||
}
|
||||
}
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
public static boolean reflectionEquals(Object o1, Object o2) {
|
||||
Collection<String> excludesFieldNames = new ArrayList<String>();
|
||||
|
||||
// ignore generated fields, e.g. for OpenJPA proxies
|
||||
if ( o1.getClass().isSynthetic() ) {
|
||||
excludesFieldNames.addAll(ReflectionUtil.getDeclaredFieldNames(o1.getClass()));
|
||||
}
|
||||
ReflectionUtil.getDeclaredFieldNames(o2.getClass());
|
||||
if ( o2.getClass().isSynthetic() ) {
|
||||
excludesFieldNames.addAll(ReflectionUtil.getDeclaredFieldNames(o2.getClass()));
|
||||
}
|
||||
return EqualsBuilder.reflectionEquals(o1, 2, excludesFieldNames);
|
||||
}
|
||||
|
||||
public static Class<?> getFieldType(Object persistentObject, String propertyName) throws TechnicalException {
|
||||
try {
|
||||
return persistentObject.getClass().getDeclaredField(propertyName).getType();
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.cas.TicketValidatorFactory;
|
||||
|
||||
@Stateless
|
||||
public class LoginService implements LoginServiceLocal {
|
||||
@ -15,8 +16,6 @@ public class LoginService implements LoginServiceLocal {
|
||||
@PersistenceContext(name = "hsar")
|
||||
private EntityManager entityManager;
|
||||
|
||||
private TicketValidator ticketValidator;
|
||||
|
||||
@Override
|
||||
public RequestContext createContext(final String ticket, final String runAsUser) throws UserException, TechnicalException {
|
||||
if (ticket != null && !ticket.isEmpty()) {
|
||||
@ -74,21 +73,8 @@ public class LoginService implements LoginServiceLocal {
|
||||
}
|
||||
|
||||
private String validateTicket(final String ticket) throws TechnicalException, UserException {
|
||||
final TicketValidator ticketValidator = getTicketValidator();
|
||||
final TicketValidator ticketValidator = TicketValidatorFactory.getTicketValidator();
|
||||
return ticketValidator.validate(ticket);
|
||||
}
|
||||
|
||||
private TicketValidator getTicketValidator() throws TechnicalException {
|
||||
if (ticketValidator == null) {
|
||||
try {
|
||||
final String property = Config.getInstance().getProperty(Config.TICKETVALIDATOR_CLASS);
|
||||
final Class<?> validatorClass = Class.forName(property);
|
||||
ticketValidator = (TicketValidator) validatorClass.newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
return ticketValidator;
|
||||
}
|
||||
|
||||
}
|
||||
|
11
framework/src/main/java/de/hsadmin/login/TicketProvider.java
Normal file
11
framework/src/main/java/de/hsadmin/login/TicketProvider.java
Normal file
@ -0,0 +1,11 @@
|
||||
package de.hsadmin.login;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
|
||||
public interface TicketProvider {
|
||||
|
||||
public String getTicket() throws TechnicalException;
|
||||
|
||||
public String getRunAs();
|
||||
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
package de.hsadmin.jscli.cas;
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@ -20,9 +19,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.jscli.TicketProvider;
|
||||
import de.hsadmin.jscli.console.PasswordReader;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
import de.hsadmin.login.TicketProvider;
|
||||
|
||||
public class CASTicketProvider implements TicketProvider {
|
||||
|
||||
@ -34,7 +31,7 @@ public class CASTicketProvider implements TicketProvider {
|
||||
|
||||
private String grantingTicket;
|
||||
|
||||
public CASTicketProvider(final PasswordReader console, final String user, final String runAs, final String backendURL, final String loginURL) throws JSCliException {
|
||||
public CASTicketProvider(final PasswordReader console, final String user, final String runAs, final String backendURL, final String loginURL) throws TechnicalException {
|
||||
this.passwordReader = console;
|
||||
this.user = user;
|
||||
this.runAs = runAs;
|
||||
@ -44,7 +41,7 @@ public class CASTicketProvider implements TicketProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTicket() throws JSCliException {
|
||||
public String getTicket() throws TechnicalException {
|
||||
try {
|
||||
final String encodedParams =
|
||||
URLEncoder.encode("service", "UTF-8") + "=" + URLEncoder.encode(backendURL, "UTF-8");
|
||||
@ -64,14 +61,14 @@ public class CASTicketProvider implements TicketProvider {
|
||||
}
|
||||
trails++;
|
||||
if (trails > 3) {
|
||||
throw new JSCliException("exceeded number of login attempts");
|
||||
throw new TechnicalException("exceeded number of login attempts");
|
||||
}
|
||||
urlString = getGrantingTicket();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +77,7 @@ public class CASTicketProvider implements TicketProvider {
|
||||
return runAs;
|
||||
}
|
||||
|
||||
private String getGrantingTicket() throws JSCliException {
|
||||
private String getGrantingTicket() throws TechnicalException {
|
||||
grantingTicket = null;
|
||||
try {
|
||||
String password = Config.getInstance().getProperty(user + ".passWord");
|
||||
@ -93,25 +90,21 @@ public class CASTicketProvider implements TicketProvider {
|
||||
+ "=" + URLEncoder.encode(password, "UTF-8");
|
||||
grantingTicket = requestForGrantingTicket(loginURL, encodedParams);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JSCliException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new JSCliException("cas server not available: " + loginURL);
|
||||
} catch (TechnicalException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
return grantingTicket;
|
||||
}
|
||||
|
||||
private String readPasswordFromConsole() throws JSCliException {
|
||||
private String readPasswordFromConsole() throws TechnicalException {
|
||||
return passwordReader.readPassword();
|
||||
}
|
||||
|
||||
private String requestForGrantingTicket(final String urlString, final String encodedParams) throws JSCliException, FileNotFoundException {
|
||||
private String requestForGrantingTicket(final String urlString, final String encodedParams) throws TechnicalException {
|
||||
try {
|
||||
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
|
||||
return connection.getHeaderField("Location");
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +141,7 @@ public class CASTicketProvider implements TicketProvider {
|
||||
return connection;
|
||||
}
|
||||
|
||||
private void readFiledGrantingTicket() throws JSCliException {
|
||||
private void readFiledGrantingTicket() throws TechnicalException {
|
||||
final File file = getTicketFile();
|
||||
final Properties properties = loadProperties(file);
|
||||
final String filedTicket = properties.getProperty(user);
|
||||
@ -162,25 +155,25 @@ public class CASTicketProvider implements TicketProvider {
|
||||
return new File(ticketFileName);
|
||||
}
|
||||
|
||||
private void saveProperties(final String filedTicket, final File file) throws JSCliException {
|
||||
private void saveProperties(final String filedTicket, final File file) throws TechnicalException {
|
||||
final Properties properties = loadProperties(file);
|
||||
if (filedTicket != null) {
|
||||
properties.setProperty(user, filedTicket);
|
||||
try {
|
||||
properties.store(new FileOutputStream(file), "stored cas tickets");
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Properties loadProperties(final File file) throws JSCliException {
|
||||
private Properties loadProperties(final File file) throws TechnicalException {
|
||||
final Properties properties = new Properties();
|
||||
if (file.isFile() && file.canRead()) {
|
||||
try {
|
||||
properties.load(new FileReader(file));
|
||||
} catch (IOException e) {
|
||||
throw new JSCliException(e);
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
return properties;
|
@ -1,4 +1,4 @@
|
||||
package de.hsadmin.login;
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -11,6 +11,7 @@ import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.login.TicketValidator;
|
||||
|
||||
public class CASTicketValidator implements TicketValidator {
|
||||
|
||||
@ -29,20 +30,22 @@ public class CASTicketValidator implements TicketValidator {
|
||||
throw new TechnicalException("TicketValidator is not initialized.");
|
||||
}
|
||||
try {
|
||||
URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
||||
URLConnection httpConnection = url.openConnection();
|
||||
final URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
||||
final URLConnection httpConnection = url.openConnection();
|
||||
httpConnection.connect();
|
||||
InputStream inputStream = httpConnection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
final InputStream inputStream = httpConnection.getInputStream();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String nextLine = reader.readLine();
|
||||
while (nextLine != null) {
|
||||
if (nextLine.contains("<cas:user>")) {
|
||||
String user = extractUser(nextLine);
|
||||
reader.close();
|
||||
inputStream.close();
|
||||
return user;
|
||||
}
|
||||
nextLine = reader.readLine();
|
||||
}
|
||||
reader.close();
|
||||
inputStream.close();
|
||||
throw new UserException(new UserError(UserError.MSG_INVALID_TICKET));
|
||||
} catch (IOException e) {
|
@ -0,0 +1,11 @@
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
|
||||
public interface PasswordReader {
|
||||
|
||||
public String readPassword() throws TechnicalException;
|
||||
|
||||
public void println(final String text) throws TechnicalException;
|
||||
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package de.hsadmin.jscli.cas;
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import de.hsadmin.jscli.TicketProvider;
|
||||
import de.hsadmin.jscli.exception.JSCliException;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.login.TicketProvider;
|
||||
|
||||
public class TestTicketProvider implements TicketProvider {
|
||||
|
||||
@ -16,7 +14,7 @@ public class TestTicketProvider implements TicketProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTicket() throws JSCliException, FileNotFoundException {
|
||||
public String getTicket() throws TechnicalException {
|
||||
return grantingTicket;
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
package de.hsadmin.login;
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import de.hsadmin.login.TicketValidator;
|
||||
|
||||
public class TestTicketValidator implements TicketValidator {
|
||||
|
@ -0,0 +1,24 @@
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.login.TicketProvider;
|
||||
|
||||
public class TicketProviderFactory {
|
||||
|
||||
private static final String HOSTSHARING_LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
||||
private static final String HOSTSHARING_BACKEND_URL = "https://config.hostsharing.net:443/hsar/backend";
|
||||
|
||||
public static TicketProvider getInstance(final PasswordReader console, final String user, final String runAs) throws TechnicalException
|
||||
{
|
||||
final Config config = Config.getInstance();
|
||||
final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
|
||||
final String loginURL = config.getProperty("loginURL", HOSTSHARING_LOGIN_URL);
|
||||
if ("TestUmgebung".equalsIgnoreCase(loginURL)) {
|
||||
return new TestTicketProvider(user, runAs);
|
||||
} else {
|
||||
return new CASTicketProvider(console, user, runAs, backendURL, loginURL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package de.hsadmin.login.cas;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import de.hsadmin.common.config.Config;
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.login.TicketValidator;
|
||||
|
||||
public class TicketValidatorFactory {
|
||||
|
||||
public static TicketValidator getTicketValidator() throws TechnicalException {
|
||||
TicketValidator ticketValidator = null;
|
||||
if (ticketValidator == null) {
|
||||
try {
|
||||
final String property = Config.getInstance().getProperty(Config.TICKETVALIDATOR_CLASS, "de.hsadmin.login.cas.CASTicketValidator");
|
||||
final Class<?> validatorClass = Class.forName(property);
|
||||
ticketValidator = (TicketValidator) validatorClass.getDeclaredConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
return ticketValidator;
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,8 @@ public interface ValueObject {
|
||||
|
||||
public Property<?> get(String propertyName) throws UserException;
|
||||
|
||||
public Class<?> getType(String name) throws TechnicalException;
|
||||
|
||||
public boolean hasProperty(String propertyName) throws UserException;
|
||||
|
||||
public void copyPropertiesToPersistentObject(Object persistentObject)
|
||||
@ -19,5 +21,4 @@ public interface ValueObject {
|
||||
|
||||
public void copyPropertiesFromPersistentObject(Object persistentObject)
|
||||
throws UserException, TechnicalException;
|
||||
|
||||
}
|
||||
|
@ -87,13 +87,12 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
return (Class<? extends Property<T>>) getClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T getValue() throws TechnicalException {
|
||||
if (undefinedValue) {
|
||||
throw new TechnicalException("undefined value");
|
||||
}
|
||||
return (T) ReflectionUtil.invokeGetter(owningVO, getName());
|
||||
return getValueImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,7 +139,28 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
||||
|
||||
@Override
|
||||
public void copyValueFromParameterMap(Map<String, Object> rpcParameter) throws TechnicalException, UserException {
|
||||
setValue(getParameterMapMapper().readValueFromParameterMap(rpcParameter, getName()));
|
||||
final String propName = getName();
|
||||
final Class<?> propType = owningVO.getType(propName);
|
||||
final ParameterMapMapper<T> paramMapMapper = getParameterMapMapper();
|
||||
final T valueFromParameterMap = paramMapMapper.readValueFromParameterMap(rpcParameter, propName, propType);
|
||||
setValue(valueFromParameterMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initValueFromVO() throws TechnicalException, UserException {
|
||||
setValue(getValueImpl());
|
||||
}
|
||||
|
||||
protected Class<?> getFieldType() throws TechnicalException {
|
||||
try {
|
||||
return owningVO.getClass().getDeclaredField(getName()).getType();
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T getValueImpl() throws TechnicalException {
|
||||
return (T) ReflectionUtil.invokeGetter(owningVO, getName());
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,15 @@ public abstract class AbstractVO implements ValueObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void initPropertyValues() throws UserException, TechnicalException {
|
||||
final Field[] fields = getClass().getDeclaredFields();
|
||||
for (Field f : fields) {
|
||||
if (isPropertyField(f)) {
|
||||
get(f.getName()).initValueFromVO();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Property<?>> properties() throws UserException, TechnicalException {
|
||||
final List<Property<?>> result = new ArrayList<>();
|
||||
@ -61,6 +70,15 @@ public abstract class AbstractVO implements ValueObject {
|
||||
return propertiesMap.get(propertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType(String propertyName) throws TechnicalException {
|
||||
try {
|
||||
return getClass().getDeclaredField(propertyName).getType();
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProperty(final String propertyName) throws UserException {
|
||||
assert propertyName != null && propertyName.length() > 0;
|
||||
@ -113,8 +131,8 @@ public abstract class AbstractVO implements ValueObject {
|
||||
final Mapping mapping = f.getAnnotation(Mapping.class);
|
||||
if (mapping != null && newInstance instanceof AbstractProperty<?>) {
|
||||
AbstractProperty<?> prop = (AbstractProperty<?>) newInstance;
|
||||
PersistentObjectMapper<?> persistentObjectMapper = mapping.boMapping().newInstance();
|
||||
ParameterMapMapper<?> parameterMapMapper = mapping.rpcMapping().newInstance();
|
||||
PersistentObjectMapper<?> persistentObjectMapper = mapping.boMapping().getDeclaredConstructor().newInstance();
|
||||
ParameterMapMapper<?> parameterMapMapper = mapping.rpcMapping().getDeclaredConstructor().newInstance();
|
||||
prop.setParameterMapMapper(parameterMapMapper);
|
||||
prop.setPersistentObjectMapper(persistentObjectMapper);
|
||||
if (persistentObjectMapper instanceof ReferredPropertyPath) {
|
||||
@ -161,5 +179,4 @@ public abstract class AbstractVO implements ValueObject {
|
||||
}
|
||||
return rwPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class ValidationDelegate<T extends ValueObject> {
|
||||
if (rwPolicy != ReadWritePolicy.READWRITE && rwPolicy != ReadWritePolicy.WRITEONCE) {
|
||||
errors.add(UserError.MSG_NO_FIELD_WRITEACCESS, p.getName());
|
||||
} else {
|
||||
Set<ConstraintViolation<T>> validateResults = vf.getValidator().validate(prototype);
|
||||
final Set<ConstraintViolation<T>> validateResults = vf.getValidator().validate(prototype);
|
||||
if (!validateResults.isEmpty()) {
|
||||
for (ConstraintViolation<T> violation: validateResults) {
|
||||
errors.add(UserError.MSG_FIELD_DOESNOT_VALIDATE, violation.getMessage(), violation.getPropertyPath().toString(), violation.getInvalidValue().toString());
|
||||
|
@ -0,0 +1,33 @@
|
||||
package de.hsadmin.module.property;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import de.hsadmin.module.ValueObject;
|
||||
import de.hsadmin.module.impl.AbstractProperty;
|
||||
import de.hsadmin.module.property.mapping.DefaultBigDecimalParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.DefaultBigDecimalPersistentObjectMapper;
|
||||
import de.hsadmin.module.property.mapping.ParameterMapMapper;
|
||||
import de.hsadmin.module.property.mapping.PersistentObjectMapper;
|
||||
|
||||
public class BigDecimalProperty extends AbstractProperty<BigDecimal> implements Property<BigDecimal> {
|
||||
|
||||
private static final PersistentObjectMapper<BigDecimal> defaultPersistentObjectMapper;
|
||||
private static final ParameterMapMapper<BigDecimal> defaultParameterMapMapper;
|
||||
|
||||
static {
|
||||
defaultPersistentObjectMapper = new DefaultBigDecimalPersistentObjectMapper();
|
||||
defaultParameterMapMapper = new DefaultBigDecimalParameterMapMapper();
|
||||
}
|
||||
|
||||
public BigDecimalProperty(final ValueObject ownerVO, final String propertyName, final ReadWritePolicy readWritePolicy, final SearchPolicy searchPolicy, final boolean required) {
|
||||
super(ownerVO, propertyName, readWritePolicy, searchPolicy, required);
|
||||
setPersistentObjectMapper(defaultPersistentObjectMapper);
|
||||
setParameterMapMapper(defaultParameterMapMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return BigDecimal.class;
|
||||
}
|
||||
|
||||
}
|
@ -35,6 +35,7 @@ public interface Property<T> {
|
||||
|
||||
public void copyValueFromParameterMap(final Map<String, Object> rpcParameter) throws TechnicalException, UserException;
|
||||
|
||||
public void initValueFromVO() throws TechnicalException, UserException;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class DefaultBigDecimalParameterMapMapper implements ParameterMapMapper<BigDecimal> {
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final BigDecimal value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final Class<?> propertyClass) throws TechnicalException, UserException {
|
||||
final Object object = rpcParameter.get(propertyName);
|
||||
if (object instanceof BigDecimal) {
|
||||
return (BigDecimal) object;
|
||||
}
|
||||
if (object instanceof String) {
|
||||
try {
|
||||
BigDecimal value = new BigDecimal((String) object);
|
||||
return value;
|
||||
} catch (NumberFormatException exc) {
|
||||
throw new TechnicalException("invalid decimal number '" + object + "'", exc);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class DefaultBigDecimalPersistentObjectMapper implements PersistentObjectMapper<BigDecimal> {
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject, final String propertyName, final BigDecimal value) throws TechnicalException {
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal readValueFromPersistentObject(final Object persistentObject, final String propertyName) throws TechnicalException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof BigDecimal) {
|
||||
return (BigDecimal) object;
|
||||
} else {
|
||||
if (object instanceof String) {
|
||||
try {
|
||||
return new BigDecimal((String)object);
|
||||
} catch ( NumberFormatException exc ) {
|
||||
throw new TechnicalException(exc);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ public class DefaultBooleanParameterMapMapper implements
|
||||
|
||||
@Override
|
||||
public Boolean readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final String propertyName, final Class<?> propertyClass) throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
|
@ -22,16 +22,19 @@ public class DefaultDateParameterMapMapper implements ParameterMapMapper<Date> {
|
||||
|
||||
@Override
|
||||
public Date readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final String propertyName, final Class<?> propertyClass) throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Date) {
|
||||
return (Date) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
try {
|
||||
return DateUtil.DEFAULT_DATEFORMAT.parse((String) value);
|
||||
} catch (ParseException e) {
|
||||
throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, (String) value));
|
||||
final String valueAsString = ((String) value).trim();
|
||||
if (valueAsString.length() > 0) {
|
||||
try {
|
||||
return DateUtil.DEFAULT_DATEFORMAT.parse(valueAsString);
|
||||
} catch (ParseException e) {
|
||||
throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, valueAsString));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -0,0 +1,37 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserError;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
|
||||
public class DefaultEnumParameterMapMapper implements ParameterMapMapper<Enum<?>> {
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, Enum<?> value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum<?> readValueFromParameterMap(Map<String, Object> rpcParameter,
|
||||
final String propertyName, final Class<?> propertyClass)
|
||||
throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Enum<?>) {
|
||||
return (Enum<?>) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
try {
|
||||
return Enum.valueOf(propertyClass.asSubclass(Enum.class), (String) value);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new UserException(new UserError(UserError.MSG_INT_VALUE_EXPECTED, propertyName, (String) value));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
import de.hsadmin.common.util.ReflectionUtil;
|
||||
|
||||
public class DefaultEnumPersistentObjectMapper implements PersistentObjectMapper<String> {
|
||||
|
||||
@Override
|
||||
public String readValueFromPersistentObject(Object persistentObject, String propertyName)
|
||||
throws TechnicalException, UserException {
|
||||
final Object object = ReflectionUtil.invokeGetter(persistentObject, propertyName);
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
} else {
|
||||
if (object instanceof Enum) {
|
||||
return object.toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueToPersistentObject(Object persistentObject, String propertyName, String value)
|
||||
throws TechnicalException, UserException {
|
||||
|
||||
final Class<?> propertyClass = ReflectionUtil.getFieldType(persistentObject, propertyName);
|
||||
@SuppressWarnings("rawtypes")
|
||||
final Class<? extends Enum> aSubclass = propertyClass.asSubclass(Enum.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
final Enum<?> enumValue = Enum.valueOf(aSubclass, value);
|
||||
ReflectionUtil.invokeSetter(persistentObject, propertyName, enumValue);
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ public class DefaultIntegerParameterMapMapper implements ParameterMapMapper<Inte
|
||||
|
||||
@Override
|
||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, Integer value)
|
||||
final String propertyName, final Integer value)
|
||||
throws TechnicalException, UserException {
|
||||
if (value != null) {
|
||||
rpcParameter.put(propertyName, value.toString());
|
||||
@ -19,7 +19,7 @@ public class DefaultIntegerParameterMapMapper implements ParameterMapMapper<Inte
|
||||
|
||||
@Override
|
||||
public Integer readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName)
|
||||
final String propertyName, final Class<?> propertyClass)
|
||||
throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof Integer) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -37,7 +38,8 @@ public class DefaultListParameterMapMapper<VO extends ValueObject> implements Pa
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<VO> readValueFromParameterMap(Map<String, Object> rpcParameter, String propertyName)
|
||||
public List<VO> readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName, final Class<?> propertyClass)
|
||||
throws TechnicalException, UserException {
|
||||
final List<VO> value = new ArrayList<>();
|
||||
final Object list = rpcParameter.get(propertyName);
|
||||
@ -45,7 +47,7 @@ public class DefaultListParameterMapMapper<VO extends ValueObject> implements Pa
|
||||
if (list instanceof Object[]) {
|
||||
for (Object obj : (Object[])list) {
|
||||
if (obj instanceof Map<?, ?>) {
|
||||
final VO vo = (VO) elementsType.newInstance();
|
||||
final VO vo = (VO) elementsType.getDeclaredConstructor().newInstance();
|
||||
final Map<?, ?> map = (Map<?, ?>) obj;
|
||||
for (Object key : map.keySet()) {
|
||||
if (key instanceof String) {
|
||||
@ -57,7 +59,7 @@ public class DefaultListParameterMapMapper<VO extends ValueObject> implements Pa
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
return value;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -31,10 +32,10 @@ public class DefaultListPersistentObjectMapper<VO extends ValueObject> implement
|
||||
final Collection<?> coll = (Collection<?>) object;
|
||||
for (Object o : coll) {
|
||||
try {
|
||||
final VO newInstance = elementsType.newInstance();
|
||||
final VO newInstance = elementsType.getDeclaredConstructor().newInstance();
|
||||
newInstance.copyPropertiesFromPersistentObject(o);
|
||||
valueList.add(newInstance);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ public class DefaultStringParameterMapMapper implements ParameterMapMapper<Strin
|
||||
|
||||
@Override
|
||||
public String readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||
final String propertyName) throws TechnicalException, UserException {
|
||||
final String propertyName, final Class<?> propertyClass)
|
||||
throws TechnicalException, UserException {
|
||||
final Object value = rpcParameter.get(propertyName);
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
|
@ -2,6 +2,7 @@ package de.hsadmin.module.property.mapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import de.hsadmin.common.error.TechnicalException;
|
||||
import de.hsadmin.common.error.UserException;
|
||||
@ -22,7 +23,7 @@ public class DefaultStringSetParameterMapMapper implements
|
||||
|
||||
@Override
|
||||
public StringSet readValueFromParameterMap(
|
||||
final Map<String, Object> rpcParameter, final String propertyName)
|
||||
final Map<String, Object> rpcParameter, final String propertyName, final Class<?> propertyClass)
|
||||
throws TechnicalException, UserException {
|
||||
final Object rpcParam = rpcParameter.get(propertyName);
|
||||
final StringSet value = new StringSet();
|
||||
@ -35,6 +36,16 @@ public class DefaultStringSetParameterMapMapper implements
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
if (rpcParam instanceof Map<?, ?>) {
|
||||
final Map<?, ?> rpcParamMap = (Map<?, ?>) rpcParam;
|
||||
final Set<?> keySet = rpcParamMap.keySet();
|
||||
strings = new String[rpcParamMap.size()];
|
||||
for (int idx = 0; idx < strings.length; idx++) {
|
||||
final Object object = keySet.toArray()[idx];
|
||||
final String val = (String) rpcParamMap.get(object);
|
||||
strings[idx] = val;
|
||||
}
|
||||
}
|
||||
value.setStrings(strings);
|
||||
return value;
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ public interface ParameterMapMapper<T> {
|
||||
|
||||
void writeValueToParameterMap(Map<String, Object> rpcParameter, String propertyName, T value) throws TechnicalException, UserException;
|
||||
|
||||
T readValueFromParameterMap(Map<String, Object> rpcParameter, String propertyName) throws TechnicalException, UserException;
|
||||
T readValueFromParameterMap(Map<String, Object> rpcParameter, String propertyName, Class<?> propertyClass) throws TechnicalException, UserException;
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ public class ReferredStringPersistentObjectMapper implements PersistentObjectMap
|
||||
@Override
|
||||
public void writeValueToPersistentObject(final Object persistentObject,
|
||||
final String propertyName, final String value) throws TechnicalException {
|
||||
throw new TechnicalException("writeValueToPersistentObject not implemented");
|
||||
// FIXME MHOENNIG->PHORMANS: Statt dieser Exception muesste man evtl. nur sicherstellen,
|
||||
// dass der Service das Feld belegt hat, oder?
|
||||
// Verstehe ur nicht, wie das jemals funktioniert haben konnte.
|
||||
// throw new TechnicalException("writeValueToPersistentObject not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.hsadmin.service.property;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -66,7 +67,7 @@ public class PropertyService extends AbstractModule<PropertyVO> implements Prope
|
||||
continue;
|
||||
}
|
||||
final Class<?> serviceRemoteClass = Class.forName(remoteServicesProperties.getProperty(moduleName));
|
||||
final AbstractRemote<ValueObject> serviceRemote = (AbstractRemote<ValueObject>) serviceRemoteClass.newInstance();
|
||||
final AbstractRemote<ValueObject> serviceRemote = (AbstractRemote<ValueObject>) serviceRemoteClass.getDeclaredConstructor().newInstance();
|
||||
final ValueObject valueObject = serviceRemote.createValueObject();
|
||||
final Class<? extends ValueObject> voClass = valueObject.getClass();
|
||||
final List<Property<?>> propertiesList = valueObject.properties();
|
||||
@ -113,7 +114,7 @@ public class PropertyService extends AbstractModule<PropertyVO> implements Prope
|
||||
emptyList.add(vo);
|
||||
}
|
||||
}
|
||||
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
throw new TechnicalException(e);
|
||||
}
|
||||
return emptyList;
|
||||
|
14
ldap-services/.gitignore
vendored
Normal file
14
ldap-services/.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
*.class
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target
|
||||
/.settings
|
||||
/.classpath
|
||||
/.project
|
||||
/derby.log
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user