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
|
/.settings
|
||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.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
|
## pac
|
||||||
|
|
||||||
Das neue Paket-Modul ist in Entwicklung https://dev.hostsharing.net/doc/hsadmin!hs.hsadmin.jee.git/master/services!doc!package.md
|
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
|
backendURL=https://config.hostsharing.net:443/hsar/backend
|
||||||
;xmlrpcURL=https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin
|
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
|
loginURL=https://login.hostsharing.net:443/cas/v1/tickets
|
||||||
xmlrpcURL=http://localhost:8080/cust-webapp/xmlrpc/hsadmin
|
;xmlrpcURL=http://localhost:8080/cust-webapp/xmlrpc/hsadmin
|
||||||
loginURL=TestUmgebung
|
;loginURL=TestUmgebung
|
29
cli/pom.xml
29
cli/pom.xml
@ -1,19 +1,24 @@
|
|||||||
<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"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsadmin-parent</artifactId>
|
<artifactId>hsadmin-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hsadmin-cli</artifactId>
|
<artifactId>hsadmin-cli</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.3.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HSAdmin-Cli</name>
|
<name>HSAdmin-Cli</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.hsadmin</groupId>
|
||||||
|
<artifactId>framework</artifactId>
|
||||||
|
<version>${hsadmin.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlrpc</groupId>
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
<artifactId>xmlrpc-client</artifactId>
|
<artifactId>xmlrpc-client</artifactId>
|
||||||
@ -32,12 +37,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jline</groupId>
|
<groupId>jline</groupId>
|
||||||
<artifactId>jline</artifactId>
|
<artifactId>jline</artifactId>
|
||||||
<version>2.14.2</version>
|
<version>2.14.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-cli</groupId>
|
<groupId>commons-cli</groupId>
|
||||||
<artifactId>commons-cli</artifactId>
|
<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>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
@ -68,12 +78,13 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.vafer</groupId>
|
<groupId>org.vafer</groupId>
|
||||||
<artifactId>jdeb</artifactId>
|
<artifactId>jdeb</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.10</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<verbose>true</verbose>
|
<verbose>true</verbose>
|
||||||
<dataSet>
|
<dataSet>
|
||||||
<data>
|
<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>
|
<dst>hsscript-full.jar</dst>
|
||||||
<type>file</type>
|
<type>file</type>
|
||||||
<mapper>
|
<mapper>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/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
|
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
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: default-jre
|
Depends: openjdk-11-jre | openjdk-17-jre
|
||||||
Maintainer: Peter Hormanns <peter.hormanns@hostsharing.net>
|
Maintainer: Peter Hormanns <peter.hormanns@hostsharing.net>
|
||||||
Description: hostsharing command and scripting shell
|
Description: hostsharing command and scripting shell
|
||||||
Distribution: hostsharing
|
Distribution: hostsharing
|
@ -75,6 +75,12 @@ public class Main {
|
|||||||
for (String ll : lines) {
|
for (String ll : lines) {
|
||||||
console.println(ll);
|
console.println(ll);
|
||||||
}
|
}
|
||||||
|
} catch (RuntimeException re) {
|
||||||
|
if (re.getCause() instanceof JSCliException) {
|
||||||
|
console.println(findRootException(re.getCause()));
|
||||||
|
} else {
|
||||||
|
throw re;
|
||||||
|
}
|
||||||
} catch (JSCliException e) {
|
} catch (JSCliException e) {
|
||||||
console.println(findRootException(e));
|
console.println(findRootException(e));
|
||||||
}
|
}
|
||||||
@ -92,7 +98,7 @@ public class Main {
|
|||||||
return "bye".equals(trimmedCommand) || "exit".equals(trimmedCommand) || "quit".equals(trimmedCommand);
|
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;
|
Throwable cause = exp;
|
||||||
while (cause.getCause() != null && cause.getCause() != cause) {
|
while (cause.getCause() != null && cause.getCause() != cause) {
|
||||||
cause = cause.getCause();
|
cause = cause.getCause();
|
||||||
|
@ -11,7 +11,8 @@ import org.apache.xmlrpc.XmlRpcException;
|
|||||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||||
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
||||||
|
|
||||||
import de.hsadmin.jscli.conf.Config;
|
import de.hsadmin.common.config.Config;
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
|
|
||||||
public class RpcClient {
|
public class RpcClient {
|
||||||
@ -37,6 +38,8 @@ public class RpcClient {
|
|||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
|
} catch (TechnicalException e) {
|
||||||
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,9 +11,10 @@ import javax.script.ScriptEngine;
|
|||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
import javax.script.ScriptException;
|
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.console.ConsoleWrapper;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
|
import de.hsadmin.login.cas.TicketProviderFactory;
|
||||||
|
|
||||||
public class ScriptClient {
|
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 {
|
public ScriptClient(final ConsoleWrapper console, final String user, final String runAs, final String... arguments) throws JSCliException {
|
||||||
final RpcClient rpcClient = new RpcClient();
|
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 {
|
try {
|
||||||
final InputStream inputResource = getClass().getClassLoader().getResourceAsStream("js/functions.js");
|
engine = new ScriptEngineManager().getEngineByName("js");
|
||||||
engine.eval(new InputStreamReader(inputResource));
|
engine.put("casgrantingticket", TicketProviderFactory.getInstance(console, user, runAs));
|
||||||
} catch (ScriptException e) {
|
engine.put("xmlrpcclient", rpcClient);
|
||||||
throw new JSCliException(e);
|
engine.put("xmlrpcLastResult", null);
|
||||||
}
|
completionStrings = new HashSet<String>();
|
||||||
final List<String> methods = rpcClient.listMethods();
|
completionStrings.add("set");
|
||||||
for (final String method : methods) {
|
completionStrings.add("where");
|
||||||
final String[] parts = method.split("\\.");
|
considerArguments(arguments);
|
||||||
if (parts.length == 2) {
|
try {
|
||||||
final String module = parts[0];
|
final ClassLoader classLoader = getClass().getClassLoader();
|
||||||
final String function = parts[1];
|
final InputStream inputResource = classLoader.getResourceAsStream("js/functions.js");
|
||||||
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
final InputStreamReader inputStreamReader = new InputStreamReader(inputResource);
|
||||||
continue;
|
engine.eval(inputStreamReader);
|
||||||
}
|
} catch (ScriptException e) {
|
||||||
completionStrings.add(module);
|
throw new JSCliException(e);
|
||||||
final String jsFunctionIdent;
|
}
|
||||||
if ("delete".equals(function)) {
|
final List<String> methods = rpcClient.listMethods();
|
||||||
jsFunctionIdent = module + "['remove']";
|
for (final String method : methods) {
|
||||||
completionStrings.add(module + ".remove");
|
final String[] parts = method.split("\\.");
|
||||||
} else {
|
if (parts.length == 2) {
|
||||||
jsFunctionIdent = module + "['" + function + "']";
|
final String module = parts[0];
|
||||||
completionStrings.add(module + "." + function);
|
final String function = parts[1];
|
||||||
}
|
if ("system".equals(module) || "getModuleLookup".equals(function) || "createValueObject".equals(function)) {
|
||||||
try {
|
continue;
|
||||||
engine.eval(
|
}
|
||||||
"if (typeof " + module + " === 'undefined')" +
|
completionStrings.add(module);
|
||||||
" { var " + module + " = { }; };\n" +
|
final String jsFunctionIdent;
|
||||||
jsFunctionIdent +
|
if ("delete".equals(function)) {
|
||||||
" = function(json) { return hsaModuleCall('" + module + "', '" + function + "', json); }"
|
jsFunctionIdent = module + "['remove']";
|
||||||
);
|
completionStrings.add(module + ".remove");
|
||||||
} catch (ScriptException e) {
|
} else {
|
||||||
e.printStackTrace();
|
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() {
|
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,11 +1,13 @@
|
|||||||
package de.hsadmin.jscli.conf;
|
package de.hsadmin.jscli.conf;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
import org.apache.commons.cli.DefaultParser;
|
||||||
import org.apache.commons.cli.HelpFormatter;
|
import org.apache.commons.cli.HelpFormatter;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
|
||||||
|
|
||||||
|
import de.hsadmin.common.config.Config;
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
|
|
||||||
public class CommandlineParser {
|
public class CommandlineParser {
|
||||||
@ -22,7 +24,7 @@ public class CommandlineParser {
|
|||||||
opts.addOption("e", "expr", true, "expression to execute");
|
opts.addOption("e", "expr", true, "expression to execute");
|
||||||
opts.addOption("f", "file", true, "script file to execute");
|
opts.addOption("f", "file", true, "script file to execute");
|
||||||
opts.addOption("i", "interactive", false, "interactive shell");
|
opts.addOption("i", "interactive", false, "interactive shell");
|
||||||
PosixParser parser = new PosixParser();
|
DefaultParser parser = new DefaultParser();
|
||||||
try {
|
try {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
printHelp();
|
printHelp();
|
||||||
@ -38,13 +40,13 @@ public class CommandlineParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser() {
|
public String getUser() throws TechnicalException {
|
||||||
final String systemUser = System.getProperty("user.name");
|
final String systemUser = System.getProperty("user.name");
|
||||||
final String configUser = Config.getInstance().getProperty("userName", systemUser);
|
final String configUser = Config.getInstance().getProperty("userName", systemUser);
|
||||||
return cmd.getOptionValue("user", configUser);
|
return cmd.getOptionValue("user", configUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRunAs() {
|
public String getRunAs() throws TechnicalException {
|
||||||
return cmd.getOptionValue("runas", getUser());
|
return cmd.getOptionValue("runas", getUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
package de.hsadmin.jscli.conf;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class Config {
|
|
||||||
|
|
||||||
private static Config instance;
|
|
||||||
|
|
||||||
private Properties props;
|
|
||||||
|
|
||||||
private Config() {
|
|
||||||
props = new Properties();
|
|
||||||
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
|
|
||||||
if (!file.canRead()) {
|
|
||||||
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
|
|
||||||
}
|
|
||||||
if (!file.canRead()) {
|
|
||||||
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
|
|
||||||
}
|
|
||||||
if (!file.canRead()) {
|
|
||||||
file = new File("/etc/hsadmin.properties");
|
|
||||||
}
|
|
||||||
if (!file.canRead()) {
|
|
||||||
file = new File("/etc/hsadmin/hsadmin.properties");
|
|
||||||
}
|
|
||||||
if (file.canRead()) {
|
|
||||||
try {
|
|
||||||
props.load(new FileReader(file));
|
|
||||||
} catch (Exception e) {
|
|
||||||
// should not happen
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Config getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new Config();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperty(String propertyName) {
|
|
||||||
String property = props.getProperty(propertyName);
|
|
||||||
if (property == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return property.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperty(String propertyName, String defaultValue) {
|
|
||||||
return props.getProperty(propertyName, defaultValue).trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -3,7 +3,9 @@ package de.hsadmin.jscli.console;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
import de.hsadmin.jscli.exception.JSCliException;
|
||||||
|
import de.hsadmin.login.cas.PasswordReader;
|
||||||
import jline.console.ConsoleReader;
|
import jline.console.ConsoleReader;
|
||||||
import jline.console.completer.StringsCompleter;
|
import jline.console.completer.StringsCompleter;
|
||||||
import jline.console.history.FileHistory;
|
import jline.console.history.FileHistory;
|
||||||
@ -11,6 +13,7 @@ import jline.console.history.FileHistory;
|
|||||||
public class ConsoleWrapper implements PasswordReader {
|
public class ConsoleWrapper implements PasswordReader {
|
||||||
|
|
||||||
private ConsoleReader cons;
|
private ConsoleReader cons;
|
||||||
|
private FileHistory history;
|
||||||
private String prompt;
|
private String prompt;
|
||||||
|
|
||||||
public void open(final String prompt) throws JSCliException {
|
public void open(final String prompt) throws JSCliException {
|
||||||
@ -20,7 +23,8 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
cons.setExpandEvents(false);
|
cons.setExpandEvents(false);
|
||||||
cons.setPrompt(prompt);
|
cons.setPrompt(prompt);
|
||||||
final String userHome = System.getProperty("user.home");
|
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) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
@ -35,28 +39,34 @@ public class ConsoleWrapper implements PasswordReader {
|
|||||||
return line;
|
return line;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(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 {
|
try {
|
||||||
if (cons != null) {
|
if (cons != null) {
|
||||||
cons.println(text);
|
cons.println(text);
|
||||||
} else {
|
} else {
|
||||||
throw new JSCliException("cannot write console");
|
throw new TechnicalException("cannot write console");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readPassword() throws JSCliException {
|
public String readPassword() throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
final String pw = cons.readLine("Password: ", new Character('*'));
|
final String pw = cons.readLine("Password: ", Character.valueOf('*'));
|
||||||
cons.setPrompt(prompt);
|
cons.setPrompt(prompt);
|
||||||
return pw;
|
return pw;
|
||||||
} catch (IOException e) {
|
} 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);
|
var JArrayList = Java.type("java.util.ArrayList")
|
||||||
importClass(java.util.HashMap);
|
var JHashMap = Java.type("java.util.HashMap")
|
||||||
|
|
||||||
function hsaParseParam(val) {
|
function hsaParseParam(val) {
|
||||||
if (val === null) {
|
if (val === null) {
|
||||||
@ -20,7 +20,7 @@ function hsaParseParam(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hsaParseParamArray(o) {
|
function hsaParseParamArray(o) {
|
||||||
var lst = new ArrayList();
|
var lst = new JArrayList();
|
||||||
var val = '';
|
var val = '';
|
||||||
for (var idx=0; idx < o.length; idx++) {
|
for (var idx=0; idx < o.length; idx++) {
|
||||||
val = o[idx];
|
val = o[idx];
|
||||||
@ -36,7 +36,7 @@ function hsaParseParamArray(o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hsaParseParamObject(o) {
|
function hsaParseParamObject(o) {
|
||||||
var hsh = new HashMap();
|
var hsh = new JHashMap();
|
||||||
for (var key in o) {
|
for (var key in o) {
|
||||||
var val = o[key];
|
var val = o[key];
|
||||||
if (!val === null) {
|
if (!val === null) {
|
||||||
@ -73,7 +73,7 @@ function hsaToNativeJSObject(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hsaModuleCall(mod, fct, json) {
|
function hsaModuleCall(mod, fct, json) {
|
||||||
var params = new ArrayList();
|
var params = new JArrayList();
|
||||||
params.add(casgrantingticket.getRunAs());
|
params.add(casgrantingticket.getRunAs());
|
||||||
params.add(casgrantingticket.getTicket());
|
params.add(casgrantingticket.getTicket());
|
||||||
if (typeof json === "undefined") {
|
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
|
/.settings
|
||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.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
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsadmin-parent</artifactId>
|
<artifactId>hsadmin-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>cust-webapp</artifactId>
|
<artifactId>cust-webapp</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>HSAdmin XML-RPC Customers Webapp</name>
|
<name>HSAdmin XML-RPC Customers Webapp</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>framework</artifactId>
|
<artifactId>framework</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>${hsadmin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>jakarta.platform</groupId>
|
||||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
<artifactId>jakarta.jakartaee-api</artifactId>
|
||||||
<version>1.1</version>
|
<version>8.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.bval</groupId>
|
||||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
<artifactId>org.apache.bval.bundle</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>${bval.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.openjpa</groupId>
|
||||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
<artifactId>openjpa</artifactId>
|
||||||
<version>1.1</version>
|
<version>${openjpa.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.liquibase</groupId>
|
||||||
|
<artifactId>liquibase-core</artifactId>
|
||||||
|
<version>${liquibase.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlrpc</groupId>
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
<artifactId>xmlrpc-server</artifactId>
|
<artifactId>xmlrpc-server</artifactId>
|
||||||
<version>3.1.3</version>
|
<version>${xmlrpc.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
@ -50,66 +58,69 @@
|
|||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archiveClasses>true</archiveClasses>
|
<archiveClasses>true</archiveClasses>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<version>3.2.0</version>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/XmlRpcServlet.properties</exclude>
|
<exclude>**/XmlRpcServlet.properties</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>make-a-jar</id>
|
|
||||||
<phase>compile</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.apache.tomee.maven</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>
|
|
||||||
<artifactId>tomee-maven-plugin</artifactId>
|
<artifactId>tomee-maven-plugin</artifactId>
|
||||||
<version>1.7.4</version>
|
<version>${tomee.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tomeeVersion>1.7.4</tomeeVersion>
|
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||||
<tomeeClassifier>webprofile</tomeeClassifier>
|
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||||
<debug>false</debug>
|
<debug>false</debug>
|
||||||
<debugPort>8000</debugPort>
|
<debugPort>8000</debugPort>
|
||||||
<config>${project.basedir}/src/test/tomee/conf</config>
|
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||||
<libs>
|
<libs>
|
||||||
<lib>org.postgresql:postgresql:9.4.1212.jre7</lib>
|
<lib>${postgresql.lib}</lib>
|
||||||
</libs>
|
</libs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package de.hsadmin.bo.customer;
|
|
||||||
|
|
||||||
public enum AssetAction {
|
|
||||||
PAYMENT,
|
|
||||||
PAYBACK,
|
|
||||||
ADOPTION,
|
|
||||||
HANDOVER,
|
|
||||||
LOSS,
|
|
||||||
CLEARING,
|
|
||||||
PRESCRIPTION
|
|
||||||
}
|
|
@ -65,13 +65,6 @@ public class Customer implements Serializable {
|
|||||||
@Temporal(javax.persistence.TemporalType.DATE)
|
@Temporal(javax.persistence.TemporalType.DATE)
|
||||||
private Date nonDiscContract;
|
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)
|
@Column(name = "free", nullable = false)
|
||||||
private boolean free = false;
|
private boolean free = false;
|
||||||
|
|
||||||
@ -176,22 +169,6 @@ public class Customer implements Serializable {
|
|||||||
this.nonDiscContract = nonDiscContract;
|
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() {
|
public String getUidVAT() {
|
||||||
return uidVAT;
|
return uidVAT;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ import java.util.Date;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@ -24,7 +26,7 @@ public class MemberAsset implements Serializable {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "member_share_id", columnDefinition = "integer")
|
@Column(name = "member_asset_id", columnDefinition = "integer")
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
@JoinColumn(name = "bp_id", columnDefinition = "integer", nullable = false)
|
@JoinColumn(name = "bp_id", columnDefinition = "integer", nullable = false)
|
||||||
@ -36,7 +38,8 @@ public class MemberAsset implements Serializable {
|
|||||||
private Date date;
|
private Date date;
|
||||||
|
|
||||||
@Column(name="action", nullable = false)
|
@Column(name="action", nullable = false)
|
||||||
private ShareAction action;
|
@Enumerated(EnumType.STRING)
|
||||||
|
private MemberAssetAction action;
|
||||||
|
|
||||||
@Column(name="amount", nullable = false)
|
@Column(name="amount", nullable = false)
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
@ -76,16 +79,14 @@ public class MemberAsset implements Serializable {
|
|||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShareAction getAction() {
|
public MemberAssetAction getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAction(ShareAction action) {
|
public void setAction(MemberAssetAction action) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getComment() {
|
public String getComment() {
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
@ -94,4 +95,10 @@ public class MemberAsset implements Serializable {
|
|||||||
this.comment = comment;
|
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.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@ -35,7 +37,8 @@ public class MemberShare implements Serializable {
|
|||||||
private Date date;
|
private Date date;
|
||||||
|
|
||||||
@Column(name="action", nullable = false)
|
@Column(name="action", nullable = false)
|
||||||
private ShareAction action;
|
@Enumerated(EnumType.STRING)
|
||||||
|
private MemberShareAction action;
|
||||||
|
|
||||||
@Column(name="quantity", nullable = false)
|
@Column(name="quantity", nullable = false)
|
||||||
private int quantity;
|
private int quantity;
|
||||||
@ -67,11 +70,11 @@ public class MemberShare implements Serializable {
|
|||||||
this.date = date;
|
this.date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShareAction getAction() {
|
public MemberShareAction getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAction(ShareAction action) {
|
public void setAction(MemberShareAction action) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,4 +94,9 @@ public class MemberShare implements Serializable {
|
|||||||
this.comment = comment;
|
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,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.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@Table(name="domain_option")
|
@Table(name="domain_option")
|
||||||
@Entity(name="DomainOption")
|
@Entity(name="DomainOption")
|
||||||
@SequenceGenerator(name = "DomainOptionSeqGen", sequenceName = "domain_option_id_seq")
|
@SequenceGenerator(name = "DomainOptionSeqGen", sequenceName = "domain_option_id_seq")
|
||||||
@ -49,14 +51,14 @@ public class DomainOption {
|
|||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof DomainOption) {
|
if (obj instanceof DomainOption) {
|
||||||
DomainOption opt = (DomainOption) obj;
|
DomainOption opt = (DomainOption) obj;
|
||||||
return getName().equals(opt.getName());
|
return StringUtils.equals(getName(), opt.getName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getName().hashCode();
|
return (getName()!=null ? getName() : "").hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityListeners;
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
@ -30,7 +29,6 @@ import de.hsadmin.bo.customer.Customer;
|
|||||||
@Entity(name = "Pac")
|
@Entity(name = "Pac")
|
||||||
@Table(name = "packet")
|
@Table(name = "packet")
|
||||||
@SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
|
@SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
|
||||||
@EntityListeners({PacEntityListener.class})
|
|
||||||
public class Pac implements Serializable {
|
public class Pac implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -7,7 +7,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EntityListeners;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
@ -20,7 +19,6 @@ import javax.persistence.TemporalType;
|
|||||||
@Entity(name = "PacComponents")
|
@Entity(name = "PacComponents")
|
||||||
@Table(name = "packet_component")
|
@Table(name = "packet_component")
|
||||||
@SequenceGenerator(name = "PacCompSeqGen", sequenceName = "packet_component_id_seq")
|
@SequenceGenerator(name = "PacCompSeqGen", sequenceName = "packet_component_id_seq")
|
||||||
@EntityListeners({PacEntityListener.class})
|
|
||||||
public class PacComponent implements Serializable {
|
public class PacComponent implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -95,7 +93,7 @@ public class PacComponent implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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;
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ejb.EJB;
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
@ -11,6 +14,7 @@ import de.hsadmin.bo.customer.Contact;
|
|||||||
import de.hsadmin.bo.customer.Customer;
|
import de.hsadmin.bo.customer.Customer;
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.dao.customer.CustomerDao;
|
||||||
import de.hsadmin.login.RequestContext;
|
import de.hsadmin.login.RequestContext;
|
||||||
import de.hsadmin.login.RequiredScope;
|
import de.hsadmin.login.RequiredScope;
|
||||||
import de.hsadmin.login.Role;
|
import de.hsadmin.login.Role;
|
||||||
@ -24,6 +28,9 @@ public class ContactService extends AbstractModule<ContactVO> implements Contact
|
|||||||
@PersistenceContext(name="hsar")
|
@PersistenceContext(name="hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@EJB
|
||||||
|
private CustomerDao customerDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContactVO buildVO() throws TechnicalException {
|
public ContactVO buildVO() throws TechnicalException {
|
||||||
return new ContactVO();
|
return new ContactVO();
|
||||||
@ -35,7 +42,22 @@ public class ContactService extends AbstractModule<ContactVO> implements Contact
|
|||||||
throws UserException, TechnicalException {
|
throws UserException, TechnicalException {
|
||||||
final ContactVO vo = super.create(requestContext, prototype);
|
final ContactVO vo = super.create(requestContext, prototype);
|
||||||
final Contact bo = new Contact();
|
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);
|
vo.copyPropertiesToPersistentObject(bo);
|
||||||
entityManager.persist(bo);
|
entityManager.persist(bo);
|
||||||
final Contact newBO = findContactByNames(vo);
|
final Contact newBO = findContactByNames(vo);
|
||||||
@ -91,10 +113,4 @@ public class ContactService extends AbstractModule<ContactVO> implements Contact
|
|||||||
return (Contact) query.getSingleResult();
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ejb.EJB;
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.Query;
|
|
||||||
|
|
||||||
import de.hsadmin.bo.customer.Customer;
|
import de.hsadmin.bo.customer.Customer;
|
||||||
import de.hsadmin.bo.pac.Pac;
|
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.UserErrorList;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
import de.hsadmin.common.util.DateUtil;
|
import de.hsadmin.common.util.DateUtil;
|
||||||
|
import de.hsadmin.dao.customer.CustomerDao;
|
||||||
import de.hsadmin.login.RequestContext;
|
import de.hsadmin.login.RequestContext;
|
||||||
import de.hsadmin.login.RequiredScope;
|
import de.hsadmin.login.RequiredScope;
|
||||||
import de.hsadmin.login.Role;
|
import de.hsadmin.login.Role;
|
||||||
import de.hsadmin.login.ScopePolicy;
|
import de.hsadmin.login.ScopePolicy;
|
||||||
import de.hsadmin.module.impl.AbstractModule;
|
import de.hsadmin.module.impl.AbstractModule;
|
||||||
|
import de.hsadmin.module.property.StringSet;
|
||||||
|
import de.hsadmin.module.property.StringSetProperty;
|
||||||
import de.hsadmin.module.util.QueryBuilder;
|
import de.hsadmin.module.util.QueryBuilder;
|
||||||
|
|
||||||
@Stateless
|
@Stateless
|
||||||
@ -29,6 +32,9 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
|||||||
@PersistenceContext(name="hsar")
|
@PersistenceContext(name="hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@EJB
|
||||||
|
private CustomerDao customerDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomerVO buildVO() throws TechnicalException {
|
public CustomerVO buildVO() throws TechnicalException {
|
||||||
return new CustomerVO();
|
return new CustomerVO();
|
||||||
@ -41,12 +47,14 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
|||||||
final CustomerVO customerVO = super.create(requestContext, prototype);
|
final CustomerVO customerVO = super.create(requestContext, prototype);
|
||||||
final String[] priceLists = customerVO.getPriceLists();
|
final String[] priceLists = customerVO.getPriceLists();
|
||||||
if (priceLists == null) {
|
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();
|
final Customer customerBO = new Customer();
|
||||||
customerVO.copyPropertiesToPersistentObject(customerBO);
|
customerVO.copyPropertiesToPersistentObject(customerBO);
|
||||||
entityManager.persist(customerBO);
|
entityManager.persist(customerBO);
|
||||||
final Customer newBO = findCustomerByName(prototype);
|
final Customer newBO = customerDao.findCustomerByName(prototype);
|
||||||
final CustomerVO newVO = new CustomerVO();
|
final CustomerVO newVO = new CustomerVO();
|
||||||
newVO.copyPropertiesFromPersistentObject(newBO);
|
newVO.copyPropertiesFromPersistentObject(newBO);
|
||||||
return newVO;
|
return newVO;
|
||||||
@ -71,7 +79,7 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
|||||||
throws UserException, TechnicalException {
|
throws UserException, TechnicalException {
|
||||||
final List<CustomerVO> customersForUpdate = super.update(requestContext, criteria, prototype);
|
final List<CustomerVO> customersForUpdate = super.update(requestContext, criteria, prototype);
|
||||||
for (CustomerVO vo : customersForUpdate) {
|
for (CustomerVO vo : customersForUpdate) {
|
||||||
final Customer customer = findCustomerByName(vo);
|
final Customer customer = customerDao.findCustomerByName(vo);
|
||||||
prototype.copyPropertiesToPersistentObject(customer);
|
prototype.copyPropertiesToPersistentObject(customer);
|
||||||
vo.copyPropertiesFromPersistentObject(customer);
|
vo.copyPropertiesFromPersistentObject(customer);
|
||||||
}
|
}
|
||||||
@ -111,10 +119,4 @@ public class CustomerService extends AbstractModule<CustomerVO> implements Custo
|
|||||||
errors.raiseException();
|
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)
|
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||||
private Date nonDiscContract;
|
private Date nonDiscContract;
|
||||||
|
|
||||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
|
||||||
private Date sharesUpdated;
|
|
||||||
|
|
||||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
|
||||||
private Integer sharesSigned;
|
|
||||||
|
|
||||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||||
private Boolean free;
|
private Boolean free;
|
||||||
|
|
||||||
@ -74,10 +68,11 @@ public class CustomerVO extends AbstractVO {
|
|||||||
|
|
||||||
@ElementsType(SEPADirectDebitVO.class)
|
@ElementsType(SEPADirectDebitVO.class)
|
||||||
@ReadWrite(ReadWritePolicy.READ)
|
@ReadWrite(ReadWritePolicy.READ)
|
||||||
@Display(visible=DisplayPolicy.NEVER)
|
@Display(visible=DisplayPolicy.OPTIONAL)
|
||||||
private List<SEPADirectDebitVO> sepaDirectDebits;
|
private List<SEPADirectDebitVO> sepaDirectDebits;
|
||||||
|
|
||||||
@ReadWrite(ReadWritePolicy.READWRITE)
|
@ReadWrite(ReadWritePolicy.READWRITE)
|
||||||
|
@Display(visible=DisplayPolicy.NEVER)
|
||||||
private final StringSet priceLists;
|
private final StringSet priceLists;
|
||||||
|
|
||||||
public CustomerVO() throws TechnicalException {
|
public CustomerVO() throws TechnicalException {
|
||||||
@ -141,22 +136,6 @@ public class CustomerVO extends AbstractVO {
|
|||||||
this.nonDiscContract = nonDiscContract;
|
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() {
|
public Boolean getFree() {
|
||||||
return free;
|
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 + "]";
|
||||||
|
}
|
||||||
|
}
|
@ -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 java.util.List;
|
||||||
|
|
||||||
|
import javax.ejb.EJB;
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.Query;
|
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.bo.customer.SEPADirectDebit;
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.dao.customer.CustomerDao;
|
||||||
import de.hsadmin.login.RequestContext;
|
import de.hsadmin.login.RequestContext;
|
||||||
import de.hsadmin.login.RequiredScope;
|
import de.hsadmin.login.RequiredScope;
|
||||||
import de.hsadmin.login.Role;
|
import de.hsadmin.login.Role;
|
||||||
@ -25,6 +25,9 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
|||||||
@PersistenceContext(name="hsar")
|
@PersistenceContext(name="hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@EJB
|
||||||
|
private CustomerDao customerDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SEPADirectDebitVO buildVO() throws TechnicalException {
|
public SEPADirectDebitVO buildVO() throws TechnicalException {
|
||||||
return new SEPADirectDebitVO();
|
return new SEPADirectDebitVO();
|
||||||
@ -36,7 +39,7 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
|||||||
throws UserException, TechnicalException {
|
throws UserException, TechnicalException {
|
||||||
final SEPADirectDebitVO vo = super.create(requestContext, prototype);
|
final SEPADirectDebitVO vo = super.create(requestContext, prototype);
|
||||||
final SEPADirectDebit bo = new SEPADirectDebit();
|
final SEPADirectDebit bo = new SEPADirectDebit();
|
||||||
bo.setCustomer(findCustomerByName(prototype.getCustomer()));
|
bo.setCustomer(customerDao.findCustomerByName(prototype.getCustomer()));
|
||||||
vo.copyPropertiesToPersistentObject(bo);
|
vo.copyPropertiesToPersistentObject(bo);
|
||||||
entityManager.persist(bo);
|
entityManager.persist(bo);
|
||||||
final SEPADirectDebit newBO = findMandatByValues(vo);
|
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)
|
public void delete(final RequestContext requestContext, final SEPADirectDebitVO criteria)
|
||||||
throws UserException, TechnicalException {
|
throws UserException, TechnicalException {
|
||||||
super.delete(requestContext, criteria);
|
super.delete(requestContext, criteria);
|
||||||
final List<Contact> list = QueryBuilder.newBuilder(entityManager, Contact.class).getResultList(criteria);
|
final List<SEPADirectDebit> list = QueryBuilder.newBuilder(entityManager, SEPADirectDebit.class).getResultList(criteria);
|
||||||
for (Contact c : list) {
|
for (SEPADirectDebit m : list) {
|
||||||
entityManager.remove(c);
|
entityManager.remove(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +94,4 @@ public class SEPADirectDebitService extends AbstractModule<SEPADirectDebitVO> im
|
|||||||
query.setParameter("mandatSigned", prototype.get("mandatSigned").getValue());
|
query.setParameter("mandatSigned", prototype.get("mandatSigned").getValue());
|
||||||
return (SEPADirectDebit) query.getSingleResult();
|
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.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ejb.EJB;
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
@ -26,6 +27,7 @@ import de.hsadmin.login.Role;
|
|||||||
import de.hsadmin.login.ScopePolicy;
|
import de.hsadmin.login.ScopePolicy;
|
||||||
import de.hsadmin.module.impl.AbstractModule;
|
import de.hsadmin.module.impl.AbstractModule;
|
||||||
import de.hsadmin.module.util.QueryBuilder;
|
import de.hsadmin.module.util.QueryBuilder;
|
||||||
|
import de.hsadmin.dao.customer.CustomerDao;
|
||||||
|
|
||||||
@Stateless
|
@Stateless
|
||||||
public class PacService extends AbstractModule<PacVO> implements PacServiceLocal {
|
public class PacService extends AbstractModule<PacVO> implements PacServiceLocal {
|
||||||
@ -33,6 +35,9 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
|||||||
@PersistenceContext(name="hsar")
|
@PersistenceContext(name="hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@EJB
|
||||||
|
private CustomerDao customerDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacVO buildVO() throws TechnicalException {
|
public PacVO buildVO() throws TechnicalException {
|
||||||
return new PacVO();
|
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"));
|
throw new UserException(new UserError(UserError.MSG_MISSING_AUTHORIZATION, "add"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bo.setCustomer(findCustomerByName(customerProperty));
|
bo.setCustomer(customerDao.findCustomerByName(customerProperty));
|
||||||
vo.copyPropertiesToPersistentObject(bo);
|
vo.copyPropertiesToPersistentObject(bo);
|
||||||
if (bo.getCreated() == null) {
|
if (bo.getCreated() == null) {
|
||||||
bo.setCreated(new Date());
|
bo.setCreated(new Date());
|
||||||
@ -100,7 +105,7 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
|||||||
final Pac bo = findPacByName(vo.getName());
|
final Pac bo = findPacByName(vo.getName());
|
||||||
final String customerName = prototype.getCustomer();
|
final String customerName = prototype.getCustomer();
|
||||||
if (customerName != null && !customerName.isEmpty()) {
|
if (customerName != null && !customerName.isEmpty()) {
|
||||||
final Customer customer = findCustomerByName(customerName);
|
final Customer customer = customerDao.findCustomerByName(customerName);
|
||||||
bo.setCustomer(customer);
|
bo.setCustomer(customer);
|
||||||
}
|
}
|
||||||
prototype.copyPropertiesToPersistentObject(bo);
|
prototype.copyPropertiesToPersistentObject(bo);
|
||||||
@ -162,11 +167,4 @@ public class PacService extends AbstractModule<PacVO> implements PacServiceLocal
|
|||||||
query.setParameter("name", value);
|
query.setParameter("name", value);
|
||||||
return (BasePac) query.getSingleResult();
|
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,6 +7,8 @@
|
|||||||
<jta-data-source>HsarDataSource</jta-data-source>
|
<jta-data-source>HsarDataSource</jta-data-source>
|
||||||
<class>de.hsadmin.bo.customer.Contact</class>
|
<class>de.hsadmin.bo.customer.Contact</class>
|
||||||
<class>de.hsadmin.bo.customer.Customer</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.SEPADirectDebit</class>
|
||||||
<class>de.hsadmin.bo.domain.Domain</class>
|
<class>de.hsadmin.bo.domain.Domain</class>
|
||||||
<class>de.hsadmin.bo.domain.DomainOption</class>
|
<class>de.hsadmin.bo.domain.DomainOption</class>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
role=de.hsadmin.service.customer.RoleRemote
|
||||||
customer=de.hsadmin.service.customer.CustomerRemote
|
customer=de.hsadmin.service.customer.CustomerRemote
|
||||||
contact=de.hsadmin.service.customer.ContactRemote
|
contact=de.hsadmin.service.customer.ContactRemote
|
||||||
mandat=de.hsadmin.service.customer.SEPADirectDebitRemote
|
mandat=de.hsadmin.service.customer.SEPADirectDebitRemote
|
||||||
|
memberShare=de.hsadmin.service.customer.MemberShareRemote
|
||||||
|
memberAsset=de.hsadmin.service.customer.MemberAssetRemote
|
||||||
hive=de.hsadmin.service.pac.HiveRemote
|
hive=de.hsadmin.service.pac.HiveRemote
|
||||||
pac=de.hsadmin.service.pac.PacRemote
|
|
||||||
property=de.hsadmin.service.property.PropertyRemote
|
property=de.hsadmin.service.property.PropertyRemote
|
@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
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"
|
||||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
version="2.5">
|
||||||
version="2.5">
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>XmlRpcServlet</servlet-name>
|
<servlet-name>XmlRpcServlet</servlet-name>
|
||||||
@ -18,5 +17,4 @@
|
|||||||
<url-pattern>/xmlrpc/*</url-pattern>
|
<url-pattern>/xmlrpc/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
</web-app>
|
</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.validate.url=https://login.hostsharing.net:443/cas/proxyValidate
|
||||||
cas.service.url=https://config.hostsharing.net:443/hsar/backend
|
cas.service.url=https://config.hostsharing.net:443/hsar/backend
|
||||||
accountprefix.hostmaster=hsh01
|
accountprefix.hostmaster=hsh01
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsadmin-parent</artifactId>
|
<artifactId>hsadmin-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>database-webapp</artifactId>
|
<artifactId>database-webapp</artifactId>
|
||||||
@ -15,35 +15,34 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>framework</artifactId>
|
<artifactId>framework</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>${hsadmin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>cust-webapp</artifactId>
|
<artifactId>cust-webapp</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>${hsadmin.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
<artifactId>geronimo-jpa_2.2_spec</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
<artifactId>geronimo-ejb_3.1_spec</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
<artifactId>geronimo-validation_2.0_spec</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlrpc</groupId>
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
<artifactId>xmlrpc-server</artifactId>
|
<artifactId>xmlrpc-server</artifactId>
|
||||||
<version>3.1.3</version>
|
<version>${xmlrpc.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
@ -56,23 +55,17 @@
|
|||||||
<finalName>database-webapp</finalName>
|
<finalName>database-webapp</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<groupId>org.apache.tomee.maven</groupId>
|
||||||
<configuration>
|
|
||||||
<archiveClasses>true</archiveClasses>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.openejb.maven</groupId>
|
|
||||||
<artifactId>tomee-maven-plugin</artifactId>
|
<artifactId>tomee-maven-plugin</artifactId>
|
||||||
<version>1.7.4</version>
|
<version>${tomee.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tomeeVersion>1.7.4</tomeeVersion>
|
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||||
<tomeeClassifier>webprofile</tomeeClassifier>
|
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||||
<debug>false</debug>
|
<debug>false</debug>
|
||||||
<debugPort>8000</debugPort>
|
<debugPort>8000</debugPort>
|
||||||
<config>${project.basedir}/src/test/tomee/conf</config>
|
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||||
<libs>
|
<libs>
|
||||||
<lib>org.postgresql:postgresql:9.4.1212.jre7</lib>
|
<lib>${postgresql.lib}</lib>
|
||||||
</libs>
|
</libs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
1
db-migration/.gitignore
vendored
1
db-migration/.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.settings/
|
/.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)
|
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';
|
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
|
-- Table: business_partner
|
||||||
--
|
--
|
||||||
INSERT INTO business_partner (member_id, member_code, member_since, shares_signed, free, indicator_vat, exempt_vat)
|
INSERT INTO business_partner (member_id, member_code, member_since, free, indicator_vat, exempt_vat)
|
||||||
VALUES (10000, 'hsh00-hsh', current_date, 0, TRUE, 'NET', FALSE);
|
VALUES (10000, 'hsh00-hsh', current_date, TRUE, 'NET', FALSE);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- table: contact
|
-- table: contact
|
||||||
--
|
--
|
||||||
INSERT INTO contact (bp_id, salut, first_name, last_name, firma, email)
|
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;
|
SELECT bp_id, 'Herr', 'Uwe', 'Mueller', 'Hostsharing eG', 'service@hostsharing.net' 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';
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table: inet_addr
|
-- Table: inet_addr
|
||||||
@ -213,10 +199,11 @@ INSERT INTO domain_option (domain_option_name)
|
|||||||
--
|
--
|
||||||
-- table: price_list
|
-- 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
|
-- 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
@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsadmin-parent</artifactId>
|
<artifactId>hsadmin-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>db-migration</artifactId>
|
<artifactId>db-migration</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
@ -12,13 +12,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${servlet.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.liquibase</groupId>
|
<groupId>org.liquibase</groupId>
|
||||||
<artifactId>liquibase-core</artifactId>
|
<artifactId>liquibase-core</artifactId>
|
||||||
<version>3.5.3</version>
|
<version>${liquibase.version}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -26,20 +26,26 @@
|
|||||||
<finalName>db-migration</finalName>
|
<finalName>db-migration</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.openejb.maven</groupId>
|
<groupId>org.apache.tomee.maven</groupId>
|
||||||
<artifactId>tomee-maven-plugin</artifactId>
|
<artifactId>tomee-maven-plugin</artifactId>
|
||||||
<version>1.7.4</version>
|
<version>${tomee.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tomeeVersion>1.7.4</tomeeVersion>
|
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||||
<tomeeClassifier>webprofile</tomeeClassifier>
|
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||||
<debug>false</debug>
|
<debug>false</debug>
|
||||||
<debugPort>8000</debugPort>
|
<debugPort>8000</debugPort>
|
||||||
<config>${project.basedir}/src/test/tomee/conf</config>
|
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||||
<libs>
|
<libs>
|
||||||
<lib>org.postgresql:postgresql:9.4.1212.jre7</lib>
|
<lib>${postgresql.lib}</lib>
|
||||||
</libs>
|
</libs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>2.2</version>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
@ -752,4 +752,11 @@
|
|||||||
</createTable>
|
</createTable>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet author="phormanns" id="ph-20170729-01">
|
||||||
|
<dropColumn tableName="business_partner"
|
||||||
|
columnName="shares_updated"/>
|
||||||
|
<dropColumn tableName="business_partner"
|
||||||
|
columnName="shares_signed"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
changeLogFile=target/classes/liquibase/db.changelog.xml
|
changeLogFile=target/classes/liquibase/db.changelog.xml
|
||||||
driver=org.postgresql.Driver
|
driver=org.postgresql.Driver
|
||||||
url=jdbc:postgresql://localhost:5432/hsadmin_migdb
|
url=jdbc:postgresql://localhost:5432/hsadmin_db
|
||||||
username=hsadmin_dbuser
|
username=hsadmin_dbuser
|
||||||
password=SelfDefinedPassword
|
password=SelfDefinedPassword
|
||||||
verbose=true
|
verbose=true
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<tomee>
|
<tomee>
|
||||||
<Resource id="hsar-ds" type="javax.sql.DataSource">
|
<Resource id="hsar-ds" type="javax.sql.DataSource">
|
||||||
JdbcDriver = org.postgresql.Driver
|
JdbcDriver = org.postgresql.Driver
|
||||||
JdbcUrl = jdbc:postgresql://localhost:5432/hsadmin_migdb
|
JdbcUrl = jdbc:postgresql://localhost:5432/hsadmin_db
|
||||||
UserName = hsadmin_dbuser
|
UserName = hsadmin_dbuser
|
||||||
Password = SelfDefinedPassword
|
Password = SelfDefinedPassword
|
||||||
</Resource>
|
</Resource>
|
||||||
|
@ -1,60 +1,54 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsadmin-parent</artifactId>
|
<artifactId>hsadmin-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>framework</artifactId>
|
<artifactId>framework</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HSAdmin Framework</name>
|
<name>HSAdmin Framework</name>
|
||||||
|
|
||||||
<build>
|
<dependencies>
|
||||||
<pluginManagement>
|
<dependency>
|
||||||
<plugins>
|
<groupId>jakarta.platform</groupId>
|
||||||
<plugin>
|
<artifactId>jakarta.jakartaee-api</artifactId>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<version>8.0.0</version>
|
||||||
<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>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.bval</groupId>
|
||||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
<artifactId>org.apache.bval.bundle</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>${bval.version}</version>
|
||||||
<scope>provided</scope>
|
<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>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlrpc</groupId>
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
<artifactId>xmlrpc-server</artifactId>
|
<artifactId>xmlrpc-server</artifactId>
|
||||||
<version>3.1.3</version>
|
<version>${xmlrpc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>${log4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
</project>
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@ public class TechnicalException extends Exception {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public TechnicalException(String message, Exception e) {
|
||||||
|
super(message, e);
|
||||||
|
}
|
||||||
|
|
||||||
public TechnicalException(Exception e) {
|
public TechnicalException(Exception e) {
|
||||||
super(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_INVALID_DATEFORMAT = "MSG_INVALID_DATEFORMAT";
|
||||||
public static final String MSG_FIELD_REQUIRES_MINLENGTH = "MSG_FIELD_REQUIRES_MINLENGTH";
|
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_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_UNKNOWN_KEY = "MSG_UNKNOWN_KEY";
|
||||||
public static final String MSG_INT_VALUE_EXPECTED = "MSG_INT_VALUE_EXPECTED";
|
public static final String MSG_INT_VALUE_EXPECTED = "MSG_INT_VALUE_EXPECTED";
|
||||||
public static final String MSG_PAC_NOT_CANCELLED = "MSG_PAC_NOT_CANCELLED";
|
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.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
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.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserError;
|
import de.hsadmin.common.error.UserError;
|
||||||
@ -38,7 +43,7 @@ public class ReflectionUtil {
|
|||||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||||
return propertyDescriptor.getReadMethod().invoke(anObject);
|
return propertyDescriptor.getReadMethod().invoke(anObject);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
|
} 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 propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
||||||
propertyDescriptor.getWriteMethod().invoke(anObject, value);
|
propertyDescriptor.getWriteMethod().invoke(anObject, value);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
|
} 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 {
|
public static Object newInstance(final Object anObject, String propertyName) throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(propertyName, anObject.getClass());
|
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);
|
invokeSetter(anObject, propertyName, newInstance);
|
||||||
return 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);
|
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.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserError;
|
import de.hsadmin.common.error.UserError;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.login.cas.TicketValidatorFactory;
|
||||||
|
|
||||||
@Stateless
|
@Stateless
|
||||||
public class LoginService implements LoginServiceLocal {
|
public class LoginService implements LoginServiceLocal {
|
||||||
@ -15,8 +16,6 @@ public class LoginService implements LoginServiceLocal {
|
|||||||
@PersistenceContext(name = "hsar")
|
@PersistenceContext(name = "hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
private TicketValidator ticketValidator;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestContext createContext(final String ticket, final String runAsUser) throws UserException, TechnicalException {
|
public RequestContext createContext(final String ticket, final String runAsUser) throws UserException, TechnicalException {
|
||||||
if (ticket != null && !ticket.isEmpty()) {
|
if (ticket != null && !ticket.isEmpty()) {
|
||||||
@ -74,21 +73,8 @@ public class LoginService implements LoginServiceLocal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String validateTicket(final String ticket) throws TechnicalException, UserException {
|
private String validateTicket(final String ticket) throws TechnicalException, UserException {
|
||||||
final TicketValidator ticketValidator = getTicketValidator();
|
final TicketValidator ticketValidator = TicketValidatorFactory.getTicketValidator();
|
||||||
return ticketValidator.validate(ticket);
|
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.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -18,10 +17,9 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import de.hsadmin.jscli.TicketProvider;
|
import de.hsadmin.common.config.Config;
|
||||||
import de.hsadmin.jscli.conf.Config;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.console.PasswordReader;
|
import de.hsadmin.login.TicketProvider;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public class CASTicketProvider implements TicketProvider {
|
public class CASTicketProvider implements TicketProvider {
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
|
|
||||||
private String grantingTicket;
|
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.passwordReader = console;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.runAs = runAs;
|
this.runAs = runAs;
|
||||||
@ -43,7 +41,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTicket() throws JSCliException {
|
public String getTicket() throws TechnicalException {
|
||||||
try {
|
try {
|
||||||
final String encodedParams =
|
final String encodedParams =
|
||||||
URLEncoder.encode("service", "UTF-8") + "=" + URLEncoder.encode(backendURL, "UTF-8");
|
URLEncoder.encode("service", "UTF-8") + "=" + URLEncoder.encode(backendURL, "UTF-8");
|
||||||
@ -63,14 +61,14 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
}
|
}
|
||||||
trails++;
|
trails++;
|
||||||
if (trails > 3) {
|
if (trails > 3) {
|
||||||
throw new JSCliException("exceeded number of login attempts");
|
throw new TechnicalException("exceeded number of login attempts");
|
||||||
}
|
}
|
||||||
urlString = getGrantingTicket();
|
urlString = getGrantingTicket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,36 +77,34 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
return runAs;
|
return runAs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGrantingTicket() throws JSCliException {
|
private String getGrantingTicket() throws TechnicalException {
|
||||||
grantingTicket = null;
|
grantingTicket = null;
|
||||||
String password = Config.getInstance().getProperty(user + ".passWord");
|
|
||||||
if (password == null || password.length() <= 0) {
|
|
||||||
password = readPasswordFromConsole();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
String password = Config.getInstance().getProperty(user + ".passWord");
|
||||||
|
if (password == null || password.length() <= 0) {
|
||||||
|
password = readPasswordFromConsole();
|
||||||
|
}
|
||||||
String encodedParams = URLEncoder.encode("username", "UTF-8")
|
String encodedParams = URLEncoder.encode("username", "UTF-8")
|
||||||
+ "=" + URLEncoder.encode(user, "UTF-8")
|
+ "=" + URLEncoder.encode(user, "UTF-8")
|
||||||
+ "&" + URLEncoder.encode("password", "UTF-8")
|
+ "&" + URLEncoder.encode("password", "UTF-8")
|
||||||
+ "=" + URLEncoder.encode(password, "UTF-8");
|
+ "=" + URLEncoder.encode(password, "UTF-8");
|
||||||
grantingTicket = requestForGrantingTicket(loginURL, encodedParams);
|
grantingTicket = requestForGrantingTicket(loginURL, encodedParams);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new JSCliException("cas server not available: " + loginURL);
|
|
||||||
}
|
}
|
||||||
return grantingTicket;
|
return grantingTicket;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String readPasswordFromConsole() throws JSCliException {
|
private String readPasswordFromConsole() throws TechnicalException {
|
||||||
return passwordReader.readPassword();
|
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 {
|
try {
|
||||||
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
|
final HttpsURLConnection connection = doConnect(urlString, encodedParams);
|
||||||
return connection.getHeaderField("Location");
|
return connection.getHeaderField("Location");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +141,7 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFiledGrantingTicket() throws JSCliException {
|
private void readFiledGrantingTicket() throws TechnicalException {
|
||||||
final File file = getTicketFile();
|
final File file = getTicketFile();
|
||||||
final Properties properties = loadProperties(file);
|
final Properties properties = loadProperties(file);
|
||||||
final String filedTicket = properties.getProperty(user);
|
final String filedTicket = properties.getProperty(user);
|
||||||
@ -159,25 +155,25 @@ public class CASTicketProvider implements TicketProvider {
|
|||||||
return new File(ticketFileName);
|
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);
|
final Properties properties = loadProperties(file);
|
||||||
if (filedTicket != null) {
|
if (filedTicket != null) {
|
||||||
properties.setProperty(user, filedTicket);
|
properties.setProperty(user, filedTicket);
|
||||||
try {
|
try {
|
||||||
properties.store(new FileOutputStream(file), "stored cas tickets");
|
properties.store(new FileOutputStream(file), "stored cas tickets");
|
||||||
} catch (IOException e) {
|
} 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();
|
final Properties properties = new Properties();
|
||||||
if (file.isFile() && file.canRead()) {
|
if (file.isFile() && file.canRead()) {
|
||||||
try {
|
try {
|
||||||
properties.load(new FileReader(file));
|
properties.load(new FileReader(file));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new JSCliException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
@ -1,4 +1,4 @@
|
|||||||
package de.hsadmin.login;
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
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.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserError;
|
import de.hsadmin.common.error.UserError;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.login.TicketValidator;
|
||||||
|
|
||||||
public class CASTicketValidator implements TicketValidator {
|
public class CASTicketValidator implements TicketValidator {
|
||||||
|
|
||||||
@ -29,20 +30,22 @@ public class CASTicketValidator implements TicketValidator {
|
|||||||
throw new TechnicalException("TicketValidator is not initialized.");
|
throw new TechnicalException("TicketValidator is not initialized.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
final URL url = new URL(proxyValidateURL + "?service=" + proxyServiceURL + "&ticket=" + ticket);
|
||||||
URLConnection httpConnection = url.openConnection();
|
final URLConnection httpConnection = url.openConnection();
|
||||||
httpConnection.connect();
|
httpConnection.connect();
|
||||||
InputStream inputStream = httpConnection.getInputStream();
|
final InputStream inputStream = httpConnection.getInputStream();
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
String nextLine = reader.readLine();
|
String nextLine = reader.readLine();
|
||||||
while (nextLine != null) {
|
while (nextLine != null) {
|
||||||
if (nextLine.contains("<cas:user>")) {
|
if (nextLine.contains("<cas:user>")) {
|
||||||
String user = extractUser(nextLine);
|
String user = extractUser(nextLine);
|
||||||
|
reader.close();
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
nextLine = reader.readLine();
|
nextLine = reader.readLine();
|
||||||
}
|
}
|
||||||
|
reader.close();
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
throw new UserException(new UserError(UserError.MSG_INVALID_TICKET));
|
throw new UserException(new UserError(UserError.MSG_INVALID_TICKET));
|
||||||
} catch (IOException e) {
|
} 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.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.login.TicketProvider;
|
||||||
import de.hsadmin.jscli.TicketProvider;
|
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public class TestTicketProvider implements TicketProvider {
|
public class TestTicketProvider implements TicketProvider {
|
||||||
|
|
||||||
@ -16,7 +14,7 @@ public class TestTicketProvider implements TicketProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTicket() throws JSCliException, FileNotFoundException {
|
public String getTicket() throws TechnicalException {
|
||||||
return grantingTicket;
|
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 {
|
public class TestTicketValidator implements TicketValidator {
|
||||||
|
|
@ -1,16 +1,15 @@
|
|||||||
package de.hsadmin.jscli.cas;
|
package de.hsadmin.login.cas;
|
||||||
|
|
||||||
import de.hsadmin.jscli.TicketProvider;
|
import de.hsadmin.common.config.Config;
|
||||||
import de.hsadmin.jscli.conf.Config;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.jscli.console.PasswordReader;
|
import de.hsadmin.login.TicketProvider;
|
||||||
import de.hsadmin.jscli.exception.JSCliException;
|
|
||||||
|
|
||||||
public class TicketProviderFactory {
|
public class TicketProviderFactory {
|
||||||
|
|
||||||
private static final String HOSTSHARING_LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
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";
|
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
|
public static TicketProvider getInstance(final PasswordReader console, final String user, final String runAs) throws TechnicalException
|
||||||
{
|
{
|
||||||
final Config config = Config.getInstance();
|
final Config config = Config.getInstance();
|
||||||
final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
|
final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
|
@ -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 Property<?> get(String propertyName) throws UserException;
|
||||||
|
|
||||||
|
public Class<?> getType(String name) throws TechnicalException;
|
||||||
|
|
||||||
public boolean hasProperty(String propertyName) throws UserException;
|
public boolean hasProperty(String propertyName) throws UserException;
|
||||||
|
|
||||||
public void copyPropertiesToPersistentObject(Object persistentObject)
|
public void copyPropertiesToPersistentObject(Object persistentObject)
|
||||||
@ -19,5 +21,4 @@ public interface ValueObject {
|
|||||||
|
|
||||||
public void copyPropertiesFromPersistentObject(Object persistentObject)
|
public void copyPropertiesFromPersistentObject(Object persistentObject)
|
||||||
throws UserException, TechnicalException;
|
throws UserException, TechnicalException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,13 +87,12 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
|||||||
return (Class<? extends Property<T>>) getClass();
|
return (Class<? extends Property<T>>) getClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public T getValue() throws TechnicalException {
|
public T getValue() throws TechnicalException {
|
||||||
if (undefinedValue) {
|
if (undefinedValue) {
|
||||||
throw new TechnicalException("undefined value");
|
throw new TechnicalException("undefined value");
|
||||||
}
|
}
|
||||||
return (T) ReflectionUtil.invokeGetter(owningVO, getName());
|
return getValueImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,7 +139,28 @@ public abstract class AbstractProperty<T> implements Property<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copyValueFromParameterMap(Map<String, Object> rpcParameter) throws TechnicalException, UserException {
|
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
|
@Override
|
||||||
public List<Property<?>> properties() throws UserException, TechnicalException {
|
public List<Property<?>> properties() throws UserException, TechnicalException {
|
||||||
final List<Property<?>> result = new ArrayList<>();
|
final List<Property<?>> result = new ArrayList<>();
|
||||||
@ -61,6 +70,15 @@ public abstract class AbstractVO implements ValueObject {
|
|||||||
return propertiesMap.get(propertyName);
|
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
|
@Override
|
||||||
public boolean hasProperty(final String propertyName) throws UserException {
|
public boolean hasProperty(final String propertyName) throws UserException {
|
||||||
assert propertyName != null && propertyName.length() > 0;
|
assert propertyName != null && propertyName.length() > 0;
|
||||||
@ -86,7 +104,7 @@ public abstract class AbstractVO implements ValueObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPropertyField(final Field f) {
|
private boolean isPropertyField(final Field f) {
|
||||||
ReadWrite annotation = f.getAnnotation(ReadWrite.class);
|
final ReadWrite annotation = f.getAnnotation(ReadWrite.class);
|
||||||
return annotation != null;
|
return annotation != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,16 +120,19 @@ public abstract class AbstractVO implements ValueObject {
|
|||||||
final Class<?> type = Class.forName("de.hsadmin.module.property." + simplePropertyClassName + "Property");
|
final Class<?> type = Class.forName("de.hsadmin.module.property." + simplePropertyClassName + "Property");
|
||||||
final Constructor<?> constructor = type.getConstructor(ValueObject.class, String.class, ReadWritePolicy.class, SearchPolicy.class, boolean.class);
|
final Constructor<?> constructor = type.getConstructor(ValueObject.class, String.class, ReadWritePolicy.class, SearchPolicy.class, boolean.class);
|
||||||
final Property<?> newInstance = (Property<?>) constructor.newInstance(this, f.getName(), getReadWritePolicy(f), getSearchPolicy(f), isRequired(f));
|
final Property<?> newInstance = (Property<?>) constructor.newInstance(this, f.getName(), getReadWritePolicy(f), getSearchPolicy(f), isRequired(f));
|
||||||
set(f.getName(), newInstance);
|
final String propertyName = f.getName();
|
||||||
|
assert propertyName != null && propertyName.length() > 0;
|
||||||
|
assert newInstance != null;
|
||||||
|
propertiesMap.put(propertyName, newInstance);
|
||||||
if (ContainsElements.class.isAssignableFrom(type)) {
|
if (ContainsElements.class.isAssignableFrom(type)) {
|
||||||
ContainsElements container = (ContainsElements) newInstance;
|
ContainsElements container = (ContainsElements) newInstance;
|
||||||
container.setElementsType(getElementsType(f));
|
container.setElementsType(getElementsType(f));
|
||||||
}
|
}
|
||||||
Mapping mapping = f.getAnnotation(Mapping.class);
|
final Mapping mapping = f.getAnnotation(Mapping.class);
|
||||||
if (mapping != null && newInstance instanceof AbstractProperty<?>) {
|
if (mapping != null && newInstance instanceof AbstractProperty<?>) {
|
||||||
AbstractProperty<?> prop = (AbstractProperty<?>) newInstance;
|
AbstractProperty<?> prop = (AbstractProperty<?>) newInstance;
|
||||||
PersistentObjectMapper<?> persistentObjectMapper = mapping.boMapping().newInstance();
|
PersistentObjectMapper<?> persistentObjectMapper = mapping.boMapping().getDeclaredConstructor().newInstance();
|
||||||
ParameterMapMapper<?> parameterMapMapper = mapping.rpcMapping().newInstance();
|
ParameterMapMapper<?> parameterMapMapper = mapping.rpcMapping().getDeclaredConstructor().newInstance();
|
||||||
prop.setParameterMapMapper(parameterMapMapper);
|
prop.setParameterMapMapper(parameterMapMapper);
|
||||||
prop.setPersistentObjectMapper(persistentObjectMapper);
|
prop.setPersistentObjectMapper(persistentObjectMapper);
|
||||||
if (persistentObjectMapper instanceof ReferredPropertyPath) {
|
if (persistentObjectMapper instanceof ReferredPropertyPath) {
|
||||||
@ -119,17 +140,11 @@ public abstract class AbstractVO implements ValueObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException
|
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException
|
||||||
| NoSuchMethodException | SecurityException | UserException | ClassNotFoundException e) {
|
| NoSuchMethodException | SecurityException | ClassNotFoundException e) {
|
||||||
throw new TechnicalException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set(final String propertyName, final Property<?> propertyInstance) throws UserException {
|
|
||||||
assert propertyName != null && propertyName.length() > 0;
|
|
||||||
assert propertyInstance != null;
|
|
||||||
propertiesMap.put(propertyName, propertyInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SearchPolicy getSearchPolicy(final Field f) {
|
private SearchPolicy getSearchPolicy(final Field f) {
|
||||||
final Search search = f.getAnnotation(Search.class);
|
final Search search = f.getAnnotation(Search.class);
|
||||||
SearchPolicy searchPolicy = SearchPolicy.NONE;
|
SearchPolicy searchPolicy = SearchPolicy.NONE;
|
||||||
@ -164,5 +179,4 @@ public abstract class AbstractVO implements ValueObject {
|
|||||||
}
|
}
|
||||||
return rwPolicy;
|
return rwPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class ValidationDelegate<T extends ValueObject> {
|
|||||||
if (rwPolicy != ReadWritePolicy.READWRITE && rwPolicy != ReadWritePolicy.WRITEONCE) {
|
if (rwPolicy != ReadWritePolicy.READWRITE && rwPolicy != ReadWritePolicy.WRITEONCE) {
|
||||||
errors.add(UserError.MSG_NO_FIELD_WRITEACCESS, p.getName());
|
errors.add(UserError.MSG_NO_FIELD_WRITEACCESS, p.getName());
|
||||||
} else {
|
} else {
|
||||||
Set<ConstraintViolation<T>> validateResults = vf.getValidator().validate(prototype);
|
final Set<ConstraintViolation<T>> validateResults = vf.getValidator().validate(prototype);
|
||||||
if (!validateResults.isEmpty()) {
|
if (!validateResults.isEmpty()) {
|
||||||
for (ConstraintViolation<T> violation: validateResults) {
|
for (ConstraintViolation<T> violation: validateResults) {
|
||||||
errors.add(UserError.MSG_FIELD_DOESNOT_VALIDATE, violation.getMessage(), violation.getPropertyPath().toString(), violation.getInvalidValue().toString());
|
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 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
|
@Override
|
||||||
public Boolean readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
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);
|
final Object value = rpcParameter.get(propertyName);
|
||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
return (Boolean) value;
|
return (Boolean) value;
|
||||||
|
@ -22,16 +22,19 @@ public class DefaultDateParameterMapMapper implements ParameterMapMapper<Date> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
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);
|
final Object value = rpcParameter.get(propertyName);
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
return (Date) value;
|
return (Date) value;
|
||||||
}
|
}
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
try {
|
final String valueAsString = ((String) value).trim();
|
||||||
return DateUtil.DEFAULT_DATEFORMAT.parse((String) value);
|
if (valueAsString.length() > 0) {
|
||||||
} catch (ParseException e) {
|
try {
|
||||||
throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, (String) value));
|
return DateUtil.DEFAULT_DATEFORMAT.parse(valueAsString);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new UserException(new UserError(UserError.MSG_INVALID_DATEFORMAT, propertyName, valueAsString));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
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
|
@Override
|
||||||
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
public void writeValueToParameterMap(final Map<String, Object> rpcParameter,
|
||||||
final String propertyName, Integer value)
|
final String propertyName, final Integer value)
|
||||||
throws TechnicalException, UserException {
|
throws TechnicalException, UserException {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
rpcParameter.put(propertyName, value.toString());
|
rpcParameter.put(propertyName, value.toString());
|
||||||
@ -19,7 +19,7 @@ public class DefaultIntegerParameterMapMapper implements ParameterMapMapper<Inte
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
public Integer readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
||||||
final String propertyName)
|
final String propertyName, final Class<?> propertyClass)
|
||||||
throws TechnicalException, UserException {
|
throws TechnicalException, UserException {
|
||||||
final Object value = rpcParameter.get(propertyName);
|
final Object value = rpcParameter.get(propertyName);
|
||||||
if (value instanceof Integer) {
|
if (value instanceof Integer) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.hsadmin.module.property.mapping;
|
package de.hsadmin.module.property.mapping;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -37,7 +38,8 @@ public class DefaultListParameterMapMapper<VO extends ValueObject> implements Pa
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@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 {
|
throws TechnicalException, UserException {
|
||||||
final List<VO> value = new ArrayList<>();
|
final List<VO> value = new ArrayList<>();
|
||||||
final Object list = rpcParameter.get(propertyName);
|
final Object list = rpcParameter.get(propertyName);
|
||||||
@ -45,7 +47,7 @@ public class DefaultListParameterMapMapper<VO extends ValueObject> implements Pa
|
|||||||
if (list instanceof Object[]) {
|
if (list instanceof Object[]) {
|
||||||
for (Object obj : (Object[])list) {
|
for (Object obj : (Object[])list) {
|
||||||
if (obj instanceof Map<?, ?>) {
|
if (obj instanceof Map<?, ?>) {
|
||||||
final VO vo = (VO) elementsType.newInstance();
|
final VO vo = (VO) elementsType.getDeclaredConstructor().newInstance();
|
||||||
final Map<?, ?> map = (Map<?, ?>) obj;
|
final Map<?, ?> map = (Map<?, ?>) obj;
|
||||||
for (Object key : map.keySet()) {
|
for (Object key : map.keySet()) {
|
||||||
if (key instanceof String) {
|
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);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.hsadmin.module.property.mapping;
|
package de.hsadmin.module.property.mapping;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,10 +32,10 @@ public class DefaultListPersistentObjectMapper<VO extends ValueObject> implement
|
|||||||
final Collection<?> coll = (Collection<?>) object;
|
final Collection<?> coll = (Collection<?>) object;
|
||||||
for (Object o : coll) {
|
for (Object o : coll) {
|
||||||
try {
|
try {
|
||||||
final VO newInstance = elementsType.newInstance();
|
final VO newInstance = elementsType.getDeclaredConstructor().newInstance();
|
||||||
newInstance.copyPropertiesFromPersistentObject(o);
|
newInstance.copyPropertiesFromPersistentObject(o);
|
||||||
valueList.add(newInstance);
|
valueList.add(newInstance);
|
||||||
} catch (InstantiationException | IllegalAccessException e) {
|
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
throw new TechnicalException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ public class DefaultStringParameterMapMapper implements ParameterMapMapper<Strin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readValueFromParameterMap(final Map<String, Object> rpcParameter,
|
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);
|
final Object value = rpcParameter.get(propertyName);
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return (String) value;
|
return (String) value;
|
||||||
|
@ -2,6 +2,7 @@ package de.hsadmin.module.property.mapping;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
@ -22,7 +23,7 @@ public class DefaultStringSetParameterMapMapper implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringSet readValueFromParameterMap(
|
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 {
|
throws TechnicalException, UserException {
|
||||||
final Object rpcParam = rpcParameter.get(propertyName);
|
final Object rpcParam = rpcParameter.get(propertyName);
|
||||||
final StringSet value = new StringSet();
|
final StringSet value = new StringSet();
|
||||||
@ -35,6 +36,16 @@ public class DefaultStringSetParameterMapMapper implements
|
|||||||
idx++;
|
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);
|
value.setStrings(strings);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ public interface ParameterMapMapper<T> {
|
|||||||
|
|
||||||
void writeValueToParameterMap(Map<String, Object> rpcParameter, String propertyName, T value) throws TechnicalException, UserException;
|
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
|
@Override
|
||||||
public void writeValueToPersistentObject(final Object persistentObject,
|
public void writeValueToPersistentObject(final Object persistentObject,
|
||||||
final String propertyName, final String value) throws TechnicalException {
|
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,7 +1,7 @@
|
|||||||
package de.hsadmin.service.property;
|
package de.hsadmin.service.property;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -14,6 +14,7 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
import de.hsadmin.common.error.TechnicalException;
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
import de.hsadmin.common.error.UserException;
|
import de.hsadmin.common.error.UserException;
|
||||||
|
import de.hsadmin.common.util.ReflectionUtil;
|
||||||
import de.hsadmin.login.RequestContext;
|
import de.hsadmin.login.RequestContext;
|
||||||
import de.hsadmin.login.RequiredScope;
|
import de.hsadmin.login.RequiredScope;
|
||||||
import de.hsadmin.login.Role;
|
import de.hsadmin.login.Role;
|
||||||
@ -22,6 +23,7 @@ import de.hsadmin.module.ValueObject;
|
|||||||
import de.hsadmin.module.impl.AbstractModule;
|
import de.hsadmin.module.impl.AbstractModule;
|
||||||
import de.hsadmin.module.property.Display;
|
import de.hsadmin.module.property.Display;
|
||||||
import de.hsadmin.module.property.DisplayPolicy;
|
import de.hsadmin.module.property.DisplayPolicy;
|
||||||
|
import de.hsadmin.module.property.Property;
|
||||||
import de.hsadmin.module.property.ReadWrite;
|
import de.hsadmin.module.property.ReadWrite;
|
||||||
import de.hsadmin.module.property.ReadWritePolicy;
|
import de.hsadmin.module.property.ReadWritePolicy;
|
||||||
import de.hsadmin.module.property.Search;
|
import de.hsadmin.module.property.Search;
|
||||||
@ -31,6 +33,8 @@ import de.hsadmin.xmlrpc.AbstractRemote;
|
|||||||
@Stateless
|
@Stateless
|
||||||
public class PropertyService extends AbstractModule<PropertyVO> implements PropertyServiceLocal {
|
public class PropertyService extends AbstractModule<PropertyVO> implements PropertyServiceLocal {
|
||||||
|
|
||||||
|
public static final String DEFAULT_VALIDATION_REGEXP = "[a-zA-Z0-9\\_\\-\\.\\,\\ ]*";
|
||||||
|
|
||||||
@PersistenceContext(name="hsar")
|
@PersistenceContext(name="hsar")
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
@ -47,6 +51,7 @@ public class PropertyService extends AbstractModule<PropertyVO> implements Prope
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@RequiredScope({@ScopePolicy(Role.ANY)})
|
@RequiredScope({@ScopePolicy(Role.ANY)})
|
||||||
public List<PropertyVO> read(final RequestContext requestContext, final PropertyVO criteria)
|
public List<PropertyVO> read(final RequestContext requestContext, final PropertyVO criteria)
|
||||||
throws UserException, TechnicalException {
|
throws UserException, TechnicalException {
|
||||||
@ -55,65 +60,78 @@ public class PropertyService extends AbstractModule<PropertyVO> implements Prope
|
|||||||
final String requestedModuleName = criteria.getModule();
|
final String requestedModuleName = criteria.getModule();
|
||||||
try {
|
try {
|
||||||
remoteServicesProperties.load(getClass().getClassLoader().getResourceAsStream("org/apache/xmlrpc/webserver/XmlRpcServlet.properties"));
|
remoteServicesProperties.load(getClass().getClassLoader().getResourceAsStream("org/apache/xmlrpc/webserver/XmlRpcServlet.properties"));
|
||||||
final Enumeration<?> propertyNames = remoteServicesProperties.propertyNames();
|
final Enumeration<?> remoteModuleNames = remoteServicesProperties.propertyNames();
|
||||||
while (propertyNames.hasMoreElements()) {
|
while (remoteModuleNames.hasMoreElements()) {
|
||||||
final String properyName = (String) propertyNames.nextElement();
|
final String moduleName = (String) remoteModuleNames.nextElement();
|
||||||
if (requestedModuleName != null && !requestedModuleName.equals(properyName)) {
|
if (requestedModuleName != null && !requestedModuleName.equals(moduleName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Class<?> serviceRemoteClass = Class.forName(remoteServicesProperties.getProperty(properyName));
|
final Class<?> serviceRemoteClass = Class.forName(remoteServicesProperties.getProperty(moduleName));
|
||||||
@SuppressWarnings("unchecked")
|
final AbstractRemote<ValueObject> serviceRemote = (AbstractRemote<ValueObject>) serviceRemoteClass.getDeclaredConstructor().newInstance();
|
||||||
final AbstractRemote<ValueObject> serviceRemote = (AbstractRemote<ValueObject>) serviceRemoteClass.newInstance();
|
|
||||||
final ValueObject valueObject = serviceRemote.createValueObject();
|
final ValueObject valueObject = serviceRemote.createValueObject();
|
||||||
final Field[] declaredFields = valueObject.getClass().getDeclaredFields();
|
final Class<? extends ValueObject> voClass = valueObject.getClass();
|
||||||
for (Field f : declaredFields) {
|
final List<Property<?>> propertiesList = valueObject.properties();
|
||||||
|
for (final Property<?> prop : propertiesList) {
|
||||||
final PropertyVO vo = buildVO();
|
final PropertyVO vo = buildVO();
|
||||||
vo.setModule(properyName);
|
final String propName = prop.getName();
|
||||||
vo.setName(f.getName());
|
setStringValue(vo, "module", moduleName);
|
||||||
final ReadWrite readWrite = f.getAnnotation(ReadWrite.class);
|
setStringValue(vo, "name", propName);
|
||||||
|
final ReadWrite readWrite = (ReadWrite) ReflectionUtil.getAnnotation(voClass, propName, ReadWrite.class);
|
||||||
if (readWrite == null) {
|
if (readWrite == null) {
|
||||||
vo.setReadwriteable(ReadWritePolicy.NONE.name().toLowerCase());
|
setStringValue(vo, "readwriteable", ReadWritePolicy.NONE.name().toLowerCase());
|
||||||
} else {
|
} else {
|
||||||
vo.setReadwriteable(readWrite.value().name().toLowerCase());
|
setStringValue(vo, "readwriteable", readWrite.value().name().toLowerCase());
|
||||||
}
|
}
|
||||||
final Search search = f.getAnnotation(Search.class);
|
final Search search = (Search) ReflectionUtil.getAnnotation(voClass, propName, Search.class);
|
||||||
if (search == null) {
|
if (search == null) {
|
||||||
vo.setSearchable(SearchPolicy.NONE.name().toLowerCase());
|
setStringValue(vo, "searchable", SearchPolicy.NONE.name().toLowerCase());
|
||||||
} else {
|
} else {
|
||||||
vo.setSearchable(search.value().name().toLowerCase());
|
setStringValue(vo, "searchable", search.value().name().toLowerCase());
|
||||||
}
|
}
|
||||||
final Display sequence = f.getAnnotation(Display.class);
|
final Display sequence = (Display) ReflectionUtil.getAnnotation(voClass, propName, Display.class);
|
||||||
if (sequence == null) {
|
if (sequence == null) {
|
||||||
vo.setDisplaySequence(Integer.valueOf(9999));
|
setIntValue(vo, "displaySequence", 9999);
|
||||||
vo.setDisplayVisible(DisplayPolicy.ALWAYS.name().toLowerCase());;
|
setStringValue(vo, "displayVisible", DisplayPolicy.ALWAYS.name().toLowerCase());
|
||||||
} else {
|
} else {
|
||||||
vo.setDisplaySequence(sequence.sequence());
|
setIntValue(vo, "displaySequence", sequence.sequence());
|
||||||
vo.setDisplayVisible(sequence.visible().name().toLowerCase());;
|
setStringValue(vo, "displayVisible", sequence.visible().name().toLowerCase());
|
||||||
}
|
}
|
||||||
final Pattern pattern = f.getAnnotation(Pattern.class);
|
final Pattern pattern = (Pattern) ReflectionUtil.getAnnotation(voClass, propName, Pattern.class);
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
vo.setValidationRegexp("[a-zA-Z0-9\\_\\-\\.\\,\\ ]*");
|
setStringValue(vo, "validationRegexp", DEFAULT_VALIDATION_REGEXP);
|
||||||
} else {
|
} else {
|
||||||
vo.setValidationRegexp(pattern.regexp());
|
setStringValue(vo, "validationRegexp", pattern.regexp());
|
||||||
}
|
}
|
||||||
final Size size = f.getAnnotation(Size.class);
|
final Size size = (Size) ReflectionUtil.getAnnotation(voClass, propName, Size.class);
|
||||||
if (size == null) {
|
if (size == null) {
|
||||||
vo.setMinLength(Integer.valueOf(0));
|
setIntValue(vo, "minLength", 0);
|
||||||
vo.setMaxLength(Integer.valueOf(999));
|
setIntValue(vo, "maxLength", 999);
|
||||||
} else {
|
} else {
|
||||||
vo.setMinLength(size.min());
|
setIntValue(vo, "minLength", size.min());
|
||||||
vo.setMaxLength(size.max());
|
setIntValue(vo, "maxLength", size.max());
|
||||||
}
|
}
|
||||||
vo.setType(printableTypeName(valueObject.get(f.getName()).getValueType()));
|
setStringValue(vo, "type", printableTypeName(valueObject.get(propName).getValueType()));
|
||||||
emptyList.add(vo);
|
emptyList.add(vo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
throw new TechnicalException(e);
|
throw new TechnicalException(e);
|
||||||
}
|
}
|
||||||
return emptyList;
|
return emptyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setStringValue(final PropertyVO vo, final String propertyName, final String value) throws TechnicalException, UserException {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Property<String> property = (Property<String>) vo.get(propertyName);
|
||||||
|
property.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setIntValue(final PropertyVO vo, final String propertyName, final int value) throws TechnicalException, UserException {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Property<Integer> property = (Property<Integer>) vo.get(propertyName);
|
||||||
|
property.setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
private String printableTypeName(Class<?> type) {
|
private String printableTypeName(Class<?> type) {
|
||||||
String name = type.getName().toLowerCase();
|
String name = type.getName().toLowerCase();
|
||||||
if (name.indexOf('.') >= 0) {
|
if (name.indexOf('.') >= 0) {
|
||||||
|
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
|
110
ldap-services/pom.xml
Normal file
110
ldap-services/pom.xml
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
<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.4</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>ldap-webapp</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
<name>HSAdmin XML-RPC LDAP Account Webapp</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.hsadmin</groupId>
|
||||||
|
<artifactId>framework</artifactId>
|
||||||
|
<version>${hsadmin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
|
<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.1_spec</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
|
<artifactId>geronimo-validation_2.0_spec</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.bval</groupId>
|
||||||
|
<artifactId>org.apache.bval.bundle</artifactId>
|
||||||
|
<version>${bval.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</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>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
|
<artifactId>xmlrpc-server</artifactId>
|
||||||
|
<version>${xmlrpc.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<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.0.0</version>
|
||||||
|
<configuration>
|
||||||
|
<archiveClasses>true</archiveClasses>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/XmlRpcServlet.properties</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.openejb.maven</groupId>
|
||||||
|
<artifactId>tomee-maven-plugin</artifactId>
|
||||||
|
<version>${tomee.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<tomeeVersion>${tomee.version}</tomeeVersion>
|
||||||
|
<tomeeClassifier>webprofile</tomeeClassifier>
|
||||||
|
<debug>false</debug>
|
||||||
|
<debugPort>8000</debugPort>
|
||||||
|
<context>ldap-webapp</context>
|
||||||
|
<config>${project.basedir}/src/test/tomee/conf</config>
|
||||||
|
<libs>
|
||||||
|
<lib>${postgresql.lib}</lib>
|
||||||
|
</libs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user