Compare commits
No commits in common. "e8c256da9c8108fbbab467d9cc9b69ef42a17736" and "96611786871881b3c0e160e6d9003db9c46c9ff4" have entirely different histories.
e8c256da9c
...
9661178687
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/qserv-test/
|
40
Makefile
40
Makefile
@ -1,40 +0,0 @@
|
|||||||
SHELL := /bin/bash
|
|
||||||
|
|
||||||
info:
|
|
||||||
@echo "Achtung: nur auf Entwicklungs- und Testservern einsetzen!"
|
|
||||||
@echo "make build: build the jar files"
|
|
||||||
@echo "make psql: start psql shell on the database"
|
|
||||||
@echo "make resetdata: reset the data in the database"
|
|
||||||
@echo "make run: run catalina and watch the output"
|
|
||||||
@echo "make test: run all continuous integration tests"
|
|
||||||
@echo "make testdomain: run one specific test for domains"
|
|
||||||
|
|
||||||
build:
|
|
||||||
source ~/.profile
|
|
||||||
cd ~/hsadmin/util && mvn clean install
|
|
||||||
cd ~/hsadmin/qserv && mvn clean install
|
|
||||||
cd ~/hsadmin/hsarback && mvn package -DskipTests
|
|
||||||
cp ~/hsadmin/qserv/target/hsadmin-*.jar ~/tomcat7/webapps/hsar/WEB-INF/lib/
|
|
||||||
cp ~/hsadmin/util/target/hsadmin-*.jar ~/tomcat7/webapps/hsar/WEB-INF/lib/
|
|
||||||
cp ~/hsadmin/hsarback/target/hsar.war ~/tomcat7/webapps
|
|
||||||
|
|
||||||
|
|
||||||
resetdata:
|
|
||||||
psql -U tim03_hsatest < ~/hsadmin/hsarback/database/dropschema.sql
|
|
||||||
psql -U tim03_hsatest < ~/hsadmin/hsarback/database/schema.sql
|
|
||||||
psql -U tim03_hsatest < ~/hsadmin/hsarback/database/data.sql
|
|
||||||
|
|
||||||
test: resetdata
|
|
||||||
source ~/.profile
|
|
||||||
cd ~/hsadmin/hsarback && mvn test -Dtest=ContinuousIntegrationTest
|
|
||||||
|
|
||||||
testdomain: resetdata
|
|
||||||
source ~/.profile
|
|
||||||
cd ~/hsadmin/hsarback && mvn test -Dtest=InitDataTest && mvn test -Dtest=DomainTest
|
|
||||||
|
|
||||||
run:
|
|
||||||
source ~/.profile
|
|
||||||
cd ~/tomcatmq && ./bin/catalina.sh run
|
|
||||||
|
|
||||||
psql:
|
|
||||||
WHOAMI=`whoami` && psql -U $${WHOAMI//\-/_}
|
|
@ -209,14 +209,6 @@ INSERT INTO domain_option (domain_option_name)
|
|||||||
VALUES ('autoconfig');
|
VALUES ('autoconfig');
|
||||||
INSERT INTO domain_option (domain_option_name)
|
INSERT INTO domain_option (domain_option_name)
|
||||||
VALUES ('dkim');
|
VALUES ('dkim');
|
||||||
INSERT INTO domain_option (domain_option_name)
|
|
||||||
VALUES ('passenger');
|
|
||||||
INSERT INTO domain_option (domain_option_name)
|
|
||||||
VALUES ('passengerfriendlyerrorpages');
|
|
||||||
INSERT INTO domain_option (domain_option_name)
|
|
||||||
VALUES ('cgi');
|
|
||||||
INSERT INTO domain_option (domain_option_name)
|
|
||||||
VALUES ('fastcgi');
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- table: price_list
|
-- table: price_list
|
||||||
|
@ -1,19 +1,85 @@
|
|||||||
|
DROP VIEW ipconfig;
|
||||||
|
|
||||||
ALTER TABLE domain
|
ALTER TABLE packet
|
||||||
ADD COLUMN passenger_python character varying(256) DEFAULT '/usr/bin/python3',
|
ALTER COLUMN packet_name TYPE VARCHAR(6);
|
||||||
ADD COLUMN passenger_nodejs character varying(256) DEFAULT '/usr/bin/node',
|
ALTER TABLE packet
|
||||||
ADD COLUMN passenger_ruby character varying(256) DEFAULT '/usr/bin/ruby',
|
ALTER COLUMN hive_id DROP NOT NULL;
|
||||||
ADD COLUMN fcgi_php_bin character varying(256) DEFAULT '/usr/lib/cgi-bin/php';
|
|
||||||
|
|
||||||
INSERT INTO domain_option (domain_option_name) VALUES
|
UPDATE packet SET packet_name='vm10' || substr(packet_name,4,2) WHERE packet_name LIKE 'srv%';
|
||||||
('passenger'),
|
|
||||||
('passengerfriendlyerrorpages'),
|
|
||||||
('cgi'),
|
|
||||||
('fastcgi');
|
|
||||||
|
|
||||||
INSERT INTO domain__domain_option ( domain_option_id, domain_id )
|
CREATE VIEW ipconfig AS
|
||||||
SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='cgi' ), domain_id FROM domain;
|
SELECT DISTINCT ON (theunion.ipv4) theunion.ipv4,
|
||||||
INSERT INTO domain__domain_option ( domain_option_id, domain_id )
|
theunion.name,
|
||||||
SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='fastcgi' ), domain_id FROM domain;
|
theunion.alias,
|
||||||
INSERT INTO domain__domain_option ( domain_option_id, domain_id )
|
theunion.hivename
|
||||||
SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='passenger' ), domain_id FROM domain;
|
FROM ( SELECT h.hive_name AS hivename,
|
||||||
|
ip.inet_addr AS ipv4,
|
||||||
|
'eth0:'::text || p.packet_name::text AS alias,
|
||||||
|
p.packet_name AS name,
|
||||||
|
2 AS prio
|
||||||
|
FROM inet_addr ip
|
||||||
|
JOIN packet p ON p.cur_inet_addr_id = ip.inet_addr_id
|
||||||
|
JOIN hive h ON h.hive_id = p.hive_id
|
||||||
|
UNION
|
||||||
|
SELECT h.hive_name AS hivename,
|
||||||
|
ip.inet_addr AS ipv4,
|
||||||
|
'eth0'::text AS alias,
|
||||||
|
h.hive_name AS name,
|
||||||
|
1 AS prio
|
||||||
|
FROM inet_addr ip
|
||||||
|
JOIN hive h ON h.inet_addr_id = ip.inet_addr_id
|
||||||
|
ORDER BY 2, 5) theunion;
|
||||||
|
|
||||||
|
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
|
||||||
|
VALUES ('SRV/CLD', 'Cloud Server', 0, true, 3000);
|
||||||
|
|
||||||
|
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||||
|
VALUES ('BANDWIDTH', 'Bandbreite 95/5 (Mbit/s)', 0, true);
|
||||||
|
|
||||||
|
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||||
|
VALUES ('SLAINFR8H', 'HS Ext. Support (24x7 8h) for Infrastructure', 0, true);
|
||||||
|
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||||
|
VALUES ('SLAINFR4H', 'HS Ext. Support (24x7 4h) for Infrastructure', 0, true);
|
||||||
|
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||||
|
VALUES ('SLAINFR2H', 'HS Ext. Support (24x7 2h) for Infrastructure', 0, true);
|
||||||
|
|
||||||
|
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, 1, 102400000, 1, 1, 0, false, 3011 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='CPU';
|
||||||
|
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, 1024, 102400000, 1024, 1024, 0, false, 3012 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='RAM';
|
||||||
|
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, 0, 102400000, 250, 250, 0, false, 3013 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='TRAFFIC';
|
||||||
|
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, 0, 1000, 0, 1, 0, false, 3017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='BANDWIDTH';
|
||||||
|
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, 25600, 102400000, 25600, 25600, 0, false, 3014 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='QUOTA';
|
||||||
|
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, 0, 102400000, 0, 256000, 0, false, 3015 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='STORAGE';
|
||||||
|
|
||||||
|
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, 1, 1, 1, 1, 0, false, 3136 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLABASIC';
|
||||||
|
|
||||||
|
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, 0, 1, 0, 1, 0, false, 3122 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR8H';
|
||||||
|
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, 0, 1, 0, 1, 0, false, 3125 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR4H';
|
||||||
|
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, 0, 1, 0, 1, 0, false, 3151 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR2H';
|
||||||
|
|
||||||
|
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, 0, 1000, 0, 1, 0, false, 2017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='BANDWIDTH';
|
||||||
|
UPDATE component SET min_quantity=0 WHERE component_id=38; -- min. Traffic für Managed Server auf 0
|
||||||
|
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3011, 15, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3012, 5, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3013, 5, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3014, 5, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3015, 5, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3017, 2, 19.0, 1);
|
||||||
|
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3136, 10, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3122, 40, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3125, 80, 19.0, 1);
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (3151, 160, 19.0, 1);
|
||||||
|
|
||||||
|
INSERT INTO price (article_number, price, vat, price_list) VALUES (2017, 2, 19.0, 1);
|
||||||
|
@ -319,11 +319,7 @@ CREATE TABLE domain (
|
|||||||
domain_dns_master character varying(64),
|
domain_dns_master character varying(64),
|
||||||
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
|
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
|
||||||
domain_owner integer NOT NULL,
|
domain_owner integer NOT NULL,
|
||||||
valid_subdomain_names character varying(256) DEFAULT 'www' NOT NULL,
|
valid_subdomain_names character varying(256) DEFAULT 'www' NOT NULL
|
||||||
passenger_python character varying(256) NULL,
|
|
||||||
passenger_nodejs character varying(256) NULL,
|
|
||||||
passenger_ruby character varying(256) NULL,
|
|
||||||
fcgi_php_bin character varying(256) NULL
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,43 +5,26 @@
|
|||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsar</artifactId>
|
<artifactId>hsar</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
<name>HSAdmin Stable Backend Webapp</name>
|
<name>HSAdmin Stable Backend Webapp</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
<maven.test.skip>true</maven.test.skip>
|
||||||
</properties>
|
</properties>
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>local</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/local-resources</directory>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin.core</groupId>
|
<groupId>de.hsadmin.core</groupId>
|
||||||
<artifactId>hsadmin-util</artifactId>
|
<artifactId>hsadmin-util</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin.core</groupId>
|
<groupId>de.hsadmin.core</groupId>
|
||||||
<artifactId>hsadmin-qserv</artifactId>
|
<artifactId>hsadmin-qserv</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-httpclient</groupId>
|
<groupId>commons-httpclient</groupId>
|
||||||
@ -70,13 +53,18 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
<version>1.7</version>
|
<version>2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.openjpa</groupId>
|
<groupId>org.apache.openjpa</groupId>
|
||||||
<artifactId>openjpa</artifactId>
|
<artifactId>openjpa</artifactId>
|
||||||
<version>2.4.3</version>
|
<version>3.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.activemq</groupId>
|
||||||
|
<artifactId>activemq-client</artifactId>
|
||||||
|
<version>5.17.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -90,18 +78,6 @@
|
|||||||
<version>4.0.1</version>
|
<version>4.0.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.activemq</groupId>
|
|
||||||
<artifactId>activemq-all</artifactId>
|
|
||||||
<version>5.5.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
|
||||||
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>hsar</finalName>
|
<finalName>hsar</finalName>
|
||||||
@ -116,8 +92,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -51,14 +51,6 @@ public class DomainRemote extends AbstractRemote {
|
|||||||
}
|
}
|
||||||
final String validsubdomains = dom.getValidsubdomainnames();
|
final String validsubdomains = dom.getValidsubdomainnames();
|
||||||
resultMap.put("validsubdomainnames", validsubdomains);
|
resultMap.put("validsubdomainnames", validsubdomains);
|
||||||
final String passengerpython = dom.getPassengerpython();
|
|
||||||
resultMap.put("passengerpython", passengerpython);
|
|
||||||
final String passengernodejs = dom.getPassengernodejs();
|
|
||||||
resultMap.put("passengernodejs", passengernodejs);
|
|
||||||
final String passengerruby = dom.getPassengerruby();
|
|
||||||
resultMap.put("passengerruby", passengerruby);
|
|
||||||
final String fcgiphpbin = dom.getFcgiphpbin();
|
|
||||||
resultMap.put("fcgiphpbin", fcgiphpbin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,22 +92,6 @@ public class DomainRemote extends AbstractRemote {
|
|||||||
if (validsubdomains != null && validsubdomains instanceof String) {
|
if (validsubdomains != null && validsubdomains instanceof String) {
|
||||||
dom.setValidsubdomainnames((String) validsubdomains);
|
dom.setValidsubdomainnames((String) validsubdomains);
|
||||||
}
|
}
|
||||||
final Object passengerpython = setParams.get("passengerpython");
|
|
||||||
if (passengerpython != null && passengerpython instanceof String) {
|
|
||||||
dom.setPassengerpython((String) passengerpython);
|
|
||||||
}
|
|
||||||
final Object passengernodejs = setParams.get("passengernodejs");
|
|
||||||
if (passengernodejs != null && passengernodejs instanceof String) {
|
|
||||||
dom.setPassengernodejs((String) passengernodejs);
|
|
||||||
}
|
|
||||||
final Object passengerruby = setParams.get("passengerruby");
|
|
||||||
if (passengerruby != null && passengerruby instanceof String) {
|
|
||||||
dom.setPassengerruby((String) passengerruby);
|
|
||||||
}
|
|
||||||
final Object fcgiphpbin = setParams.get("fcgiphpbin");
|
|
||||||
if (fcgiphpbin != null && fcgiphpbin instanceof String) {
|
|
||||||
dom.setFcgiphpbin((String) fcgiphpbin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,8 +23,9 @@ public class RoleRemote implements IRemote {
|
|||||||
Transaction transaction = new Transaction(user);
|
Transaction transaction = new Transaction(user);
|
||||||
if (transaction.login(user, ticket)) {
|
if (transaction.login(user, ticket)) {
|
||||||
String role = "USER";
|
String role = "USER";
|
||||||
String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer");
|
Config config = Config.getInstance();
|
||||||
String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster");
|
String accoutPrefixCustomer = config.getProperty("accountprefix.customer");
|
||||||
|
String accoutPrefixHostmaster = config.getProperty("accountprefix.hostmaster");
|
||||||
Pac pac = transaction.getLoginUser().getPac();
|
Pac pac = transaction.getLoginUser().getPac();
|
||||||
String pacName = pac.getName();
|
String pacName = pac.getName();
|
||||||
if (accoutPrefixCustomer.equals(pacName)) {
|
if (accoutPrefixCustomer.equals(pacName)) {
|
||||||
|
@ -121,10 +121,6 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
domainadmins.add(domUserName);
|
domainadmins.add(domUserName);
|
||||||
final Pac domPac = domUser.getPac();
|
final Pac domPac = domUser.getPac();
|
||||||
final String validSubdomainNames = dom.getValidsubdomainnames();
|
final String validSubdomainNames = dom.getValidsubdomainnames();
|
||||||
final String passengerPython = dom.getPassengerpython();
|
|
||||||
final String passengerNodejs = dom.getPassengernodejs();
|
|
||||||
final String passengerRuby = dom.getPassengerruby();
|
|
||||||
final String fcgiPhpBin = dom.getFcgiphpbin();
|
|
||||||
final INetAddress domINetAddr = domPac.getCurINetAddr();
|
final INetAddress domINetAddr = domPac.getCurINetAddr();
|
||||||
writer.println(" \"domain\": \"" + domName + "\"");
|
writer.println(" \"domain\": \"" + domName + "\"");
|
||||||
writer.println(" , \"pac\": \"" + domPac.getName() + "\"");
|
writer.println(" , \"pac\": \"" + domPac.getName() + "\"");
|
||||||
@ -152,18 +148,6 @@ public class JsonPillarServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
writer.println(" }");
|
writer.println(" }");
|
||||||
writer.println(" , \"validsubdomains\": \"" + validSubdomainNames + "\"");
|
writer.println(" , \"validsubdomains\": \"" + validSubdomainNames + "\"");
|
||||||
if (passengerPython != null && passengerPython.length() > 0) {
|
|
||||||
writer.println(" , \"passengerpython\": \"" + passengerPython + "\"");
|
|
||||||
}
|
|
||||||
if (passengerNodejs != null && passengerNodejs.length() > 0) {
|
|
||||||
writer.println(" , \"passengernodejs\": \"" + passengerNodejs + "\"");
|
|
||||||
}
|
|
||||||
if (passengerRuby != null && passengerRuby.length() > 0) {
|
|
||||||
writer.println(" , \"passengerruby\": \"" + passengerRuby + "\"");
|
|
||||||
}
|
|
||||||
if (fcgiPhpBin != null && fcgiPhpBin.length() > 0) {
|
|
||||||
writer.println(" , \"fcgiphpbin\": \"" + fcgiPhpBin + "\"");
|
|
||||||
}
|
|
||||||
writer.println(" }");
|
writer.println(" }");
|
||||||
}
|
}
|
||||||
writer.println(" ]");
|
writer.println(" ]");
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package de.hsadmin.servlets;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContextEvent;
|
|
||||||
import javax.servlet.ServletContextListener;
|
|
||||||
|
|
||||||
import de.hsadmin.core.model.PersistenceManager;
|
|
||||||
|
|
||||||
public class PersistenceManagerContextListener implements ServletContextListener {
|
|
||||||
|
|
||||||
public PersistenceManagerContextListener() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void contextDestroyed(ServletContextEvent contextEvent) {
|
|
||||||
System.out.println("PersistenceManager.contextDestroyed()");
|
|
||||||
PersistenceManager.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void contextInitialized(ServletContextEvent contextEvent) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -2,6 +2,8 @@ package de.hsadmin.servlets;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.jms.ExceptionListener;
|
import javax.jms.ExceptionListener;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
@ -10,13 +12,9 @@ import javax.jms.MessageListener;
|
|||||||
import javax.jms.ObjectMessage;
|
import javax.jms.ObjectMessage;
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
import javax.jms.QueueConnection;
|
import javax.jms.QueueConnection;
|
||||||
import javax.jms.QueueConnectionFactory;
|
|
||||||
import javax.jms.QueueReceiver;
|
import javax.jms.QueueReceiver;
|
||||||
import javax.jms.QueueSession;
|
import javax.jms.QueueSession;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.servlet.ServletConfig;
|
import javax.servlet.ServletConfig;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
@ -24,11 +22,14 @@ import javax.servlet.http.HttpServlet;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
|
|
||||||
import de.hsadmin.core.model.TechnicalException;
|
import de.hsadmin.core.model.TechnicalException;
|
||||||
import de.hsadmin.core.model.TicketValidator;
|
import de.hsadmin.core.model.TicketValidator;
|
||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
import de.hsadmin.core.qserv.Processor;
|
import de.hsadmin.core.qserv.Processor;
|
||||||
import de.hsadmin.core.qserv.QueueTask;
|
import de.hsadmin.core.qserv.QueueTask;
|
||||||
|
import de.hsadmin.core.qserv.TaskTransfer;
|
||||||
import de.hsadmin.core.util.Config;
|
import de.hsadmin.core.util.Config;
|
||||||
|
|
||||||
public class QueueStatusReceiverServlet extends HttpServlet
|
public class QueueStatusReceiverServlet extends HttpServlet
|
||||||
@ -36,9 +37,10 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
|||||||
|
|
||||||
private static final long serialVersionUID = -5701350884034782083L;
|
private static final long serialVersionUID = -5701350884034782083L;
|
||||||
|
|
||||||
|
private String jmsUrl;
|
||||||
private String jmsUser;
|
private String jmsUser;
|
||||||
private String jmsPass;
|
private String jmsPass;
|
||||||
private QueueConnectionFactory queueConnectionFactory;
|
private String jmsStatusQueue;
|
||||||
private QueueConnection queueConnection;
|
private QueueConnection queueConnection;
|
||||||
private QueueSession queueSession;
|
private QueueSession queueSession;
|
||||||
private boolean isConnected;
|
private boolean isConnected;
|
||||||
@ -54,27 +56,24 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
|||||||
isConnected = false;
|
isConnected = false;
|
||||||
messageCount = 0;
|
messageCount = 0;
|
||||||
errorCount = 0;
|
errorCount = 0;
|
||||||
try {
|
connect();
|
||||||
connect();
|
|
||||||
} catch (NamingException e) {
|
|
||||||
throw new ServletException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect() throws NamingException {
|
private void connect() {
|
||||||
Config config = Config.getInstance();
|
Config config = Config.getInstance();
|
||||||
|
jmsUrl = config.getProperty("hsadmin.jms.url", "tcp://localhost:61616");
|
||||||
jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
|
jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
|
||||||
jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
|
jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
|
||||||
InitialContext ctx = new InitialContext();
|
jmsStatusQueue = config.getProperty("hsadmin.jms.status-queue", "queue.Status");
|
||||||
Context env = (Context) ctx.lookup("java:comp/env");
|
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl);
|
||||||
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
|
mqConnectionFactory.setTrustAllPackages(true);
|
||||||
int timeoutCounter = 10;
|
int timeoutCounter = 10;
|
||||||
while (!isConnected && (timeoutCounter > 0)) {
|
while (!isConnected && (timeoutCounter > 0)) {
|
||||||
try {
|
try {
|
||||||
queueConnection = queueConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
queueConnection = mqConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
||||||
queueConnection.setExceptionListener(this);
|
queueConnection.setExceptionListener(this);
|
||||||
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
Queue queue = (Queue) env.lookup("jms/hsadminStatus");
|
Queue queue = queueSession.createQueue(jmsStatusQueue);
|
||||||
queueConnection.start();
|
queueConnection.start();
|
||||||
QueueReceiver receiver = queueSession.createReceiver(queue);
|
QueueReceiver receiver = queueSession.createReceiver(queue);
|
||||||
receiver.setMessageListener(this);
|
receiver.setMessageListener(this);
|
||||||
@ -113,24 +112,38 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(Message jmsMessage) {
|
public void onMessage(Message jmsMessage) {
|
||||||
|
assert jmsMessage != null;
|
||||||
Transaction transaction = null;
|
Transaction transaction = null;
|
||||||
messageCount++;
|
messageCount++;
|
||||||
try {
|
try {
|
||||||
ObjectMessage objMessage = (ObjectMessage) jmsMessage;
|
ObjectMessage objMessage = (ObjectMessage) jmsMessage;
|
||||||
QueueTask detachedQT = (QueueTask) objMessage.getObject();
|
final Serializable object = objMessage.getObject();
|
||||||
transaction = new Transaction("statusreceiver");
|
if (object != null) {
|
||||||
transaction.beginTransaction();
|
TaskTransfer detachedQT = (TaskTransfer) object;
|
||||||
EntityManager em = transaction.getEntityManager();
|
transaction = new Transaction("statusreceiver");
|
||||||
em.clear();
|
transaction.beginTransaction();
|
||||||
QueueTask persistentQT = em.find(QueueTask.class, detachedQT.getId());
|
EntityManager em = transaction.getEntityManager();
|
||||||
persistentQT.assign(detachedQT);
|
em.clear();
|
||||||
Processor processor = persistentQT.getProcessor();
|
final long queueTaskId = detachedQT.getId();
|
||||||
if (processor != null) {
|
QueueTask persistentQT = em.find(QueueTask.class, queueTaskId);
|
||||||
processor.finalize(transaction, persistentQT);
|
if (persistentQT == null) {
|
||||||
|
errorCount++;
|
||||||
|
throw new TechnicalException("QueueTask not found, id: " + queueTaskId);
|
||||||
|
}
|
||||||
|
persistentQT.assign(detachedQT);
|
||||||
|
Processor processor = persistentQT.getProcessor();
|
||||||
|
if (processor != null) {
|
||||||
|
processor.finalize(transaction, persistentQT);
|
||||||
|
}
|
||||||
|
em.persist(persistentQT);
|
||||||
|
em.flush();
|
||||||
|
transaction.commitTransaction();
|
||||||
|
} else {
|
||||||
|
errorCount++;
|
||||||
|
final String err = "Deserialization failed " + new Date();
|
||||||
|
System.out.println(err);
|
||||||
|
throw new TechnicalException(err);
|
||||||
}
|
}
|
||||||
em.persist(persistentQT);
|
|
||||||
em.flush();
|
|
||||||
transaction.commitTransaction();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
if (transaction != null) transaction.rollbackTransaction();
|
if (transaction != null) transaction.rollbackTransaction();
|
||||||
@ -144,7 +157,7 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
|||||||
public void onException(JMSException exception) {
|
public void onException(JMSException exception) {
|
||||||
close();
|
close();
|
||||||
try { Thread.sleep(10000); } catch (InterruptedException e) { }
|
try { Thread.sleep(10000); } catch (InterruptedException e) { }
|
||||||
try { connect(); } catch (NamingException e) { }
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,8 @@
|
|||||||
|
|
||||||
DocumentRoot /home/doms/${dom.name}/htdocs
|
DocumentRoot /home/doms/${dom.name}/htdocs
|
||||||
|
|
||||||
#if( ${cgi} )
|
|
||||||
Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
|
Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
|
||||||
#end
|
|
||||||
#if( ${fastcgi} )
|
|
||||||
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
|
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
|
||||||
#end
|
|
||||||
|
|
||||||
<Directory />
|
<Directory />
|
||||||
PassengerEnabled Off
|
PassengerEnabled Off
|
||||||
@ -30,42 +26,21 @@
|
|||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /home/doms/${dom.name}/>
|
<Directory /home/doms/${dom.name}/>
|
||||||
#if( ${passenger} )
|
|
||||||
PassengerEnabled On
|
PassengerEnabled On
|
||||||
# PassengerPreloadBundler On
|
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
|
||||||
#else
|
|
||||||
PassengerEnabled Off
|
|
||||||
#end
|
|
||||||
#if( ${passengerfriendlyerrorpages} )
|
|
||||||
PassengerFriendlyErrorPages On
|
|
||||||
#end
|
|
||||||
#if( ${passengerpython} )
|
|
||||||
PassengerPython ${passengerpython}
|
|
||||||
#end
|
|
||||||
#if( ${passengernodejs} )
|
|
||||||
PassengerNodejs ${passengernodejs}
|
|
||||||
#end
|
|
||||||
#if( ${passengerruby} )
|
|
||||||
PassengerRuby ${passengerruby}
|
|
||||||
#end
|
|
||||||
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
|
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
#if( ${cgi} )
|
|
||||||
<Location /cgi-bin/>
|
<Location /cgi-bin/>
|
||||||
PassengerEnabled Off
|
PassengerEnabled Off
|
||||||
SetHandler cgi-script
|
SetHandler cgi-script
|
||||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||||
</Location>
|
</Location>
|
||||||
#end
|
|
||||||
|
|
||||||
#if( ${fastcgi} )
|
|
||||||
<Location /fastcgi-bin/>
|
<Location /fastcgi-bin/>
|
||||||
PassengerEnabled Off
|
PassengerEnabled Off
|
||||||
SetHandler fcgid-script
|
SetHandler fcgid-script
|
||||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||||
</Location>
|
</Location>
|
||||||
#end
|
|
||||||
|
|
||||||
#if( ${autoconfig} )
|
#if( ${autoconfig} )
|
||||||
<Location /autodiscover/autodiscover.xml>
|
<Location /autodiscover/autodiscover.xml>
|
||||||
@ -82,12 +57,8 @@
|
|||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteOptions Inherit
|
RewriteOptions Inherit
|
||||||
|
|
||||||
#if( ${cgi} )
|
|
||||||
RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
||||||
#end
|
|
||||||
#if( ${fastcgi} )
|
|
||||||
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
||||||
#end
|
|
||||||
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
|
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
|
||||||
RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d
|
RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d
|
||||||
RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last]
|
RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last]
|
||||||
@ -100,13 +71,8 @@
|
|||||||
RewriteRule ^(.*) - [redirect=404,last]
|
RewriteRule ^(.*) - [redirect=404,last]
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#if( ${fastcgi} )
|
AddType application/x-httpd-php .php .php5 .php4 .php3
|
||||||
#if( ${fcgiphpbin} )
|
Action application/x-httpd-php /fastcgi-bin/phpstub
|
||||||
FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin}
|
|
||||||
#end
|
|
||||||
AddType application/x-httpd-php .php
|
|
||||||
Action application/x-httpd-php /fastcgi-bin/hs-phpstub
|
|
||||||
#end
|
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
<VirtualHost ${pac.curINetAddr.inet4Addr}:443 ${pac.oldINetAddr.inet4Addr}:443 [${pac.curINetAddr.inet6Addr}]:443 [${pac.oldINetAddr.inet6Addr}]:443>
|
<VirtualHost ${pac.curINetAddr.inet4Addr}:443 ${pac.oldINetAddr.inet4Addr}:443 [${pac.curINetAddr.inet6Addr}]:443 [${pac.oldINetAddr.inet6Addr}]:443>
|
||||||
@ -128,12 +94,8 @@
|
|||||||
|
|
||||||
DocumentRoot /home/doms/${dom.name}/htdocs-ssl
|
DocumentRoot /home/doms/${dom.name}/htdocs-ssl
|
||||||
|
|
||||||
#if( ${cgi} )
|
|
||||||
Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
|
Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
|
||||||
#end
|
|
||||||
#if( ${fastcgi} )
|
|
||||||
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
|
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
|
||||||
#end
|
|
||||||
|
|
||||||
<Directory />
|
<Directory />
|
||||||
SSLRequireSSL On
|
SSLRequireSSL On
|
||||||
@ -142,42 +104,21 @@
|
|||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /home/doms/${dom.name}/>
|
<Directory /home/doms/${dom.name}/>
|
||||||
#if( ${passenger} )
|
|
||||||
PassengerEnabled On
|
PassengerEnabled On
|
||||||
# PassengerPreloadBundler On
|
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
|
||||||
#else
|
|
||||||
PassengerEnabled Off
|
|
||||||
#end
|
|
||||||
#if( ${passengerfriendlyerrorpages} )
|
|
||||||
PassengerFriendlyErrorPages On
|
|
||||||
#end
|
|
||||||
#if( ${passengerpython} )
|
|
||||||
PassengerPython ${passengerpython}
|
|
||||||
#end
|
|
||||||
#if( ${passengernodejs} )
|
|
||||||
PassengerNodejs ${passengernodejs}
|
|
||||||
#end
|
|
||||||
#if( ${passengerruby} )
|
|
||||||
PassengerRuby ${passengerruby}
|
|
||||||
#end
|
|
||||||
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
|
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
#if( ${cgi} )
|
|
||||||
<Location /cgi-bin/>
|
<Location /cgi-bin/>
|
||||||
PassengerEnabled Off
|
PassengerEnabled Off
|
||||||
SetHandler cgi-script
|
SetHandler cgi-script
|
||||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||||
</Location>
|
</Location>
|
||||||
#end
|
|
||||||
|
|
||||||
#if( ${fastcgi} )
|
|
||||||
<Location /fastcgi-bin/>
|
<Location /fastcgi-bin/>
|
||||||
PassengerEnabled Off
|
PassengerEnabled Off
|
||||||
SetHandler fcgid-script
|
SetHandler fcgid-script
|
||||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||||
</Location>
|
</Location>
|
||||||
#end
|
|
||||||
|
|
||||||
#if( ${autoconfig} )
|
#if( ${autoconfig} )
|
||||||
<Location /autodiscover/autodiscover.xml>
|
<Location /autodiscover/autodiscover.xml>
|
||||||
@ -194,12 +135,8 @@
|
|||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteOptions Inherit
|
RewriteOptions Inherit
|
||||||
|
|
||||||
#if( ${cgi} )
|
|
||||||
RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
||||||
#end
|
|
||||||
#if( ${fastcgi} )
|
|
||||||
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
||||||
#end
|
|
||||||
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
|
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
|
||||||
RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d
|
RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d
|
||||||
RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last]
|
RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last]
|
||||||
@ -212,11 +149,7 @@
|
|||||||
RewriteRule ^(.*) - [redirect=404,last]
|
RewriteRule ^(.*) - [redirect=404,last]
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#if( ${fastcgi} )
|
AddType application/x-httpd-php .php .php5 .php4 .php3
|
||||||
#if( ${fcgiphpbin} )
|
Action application/x-httpd-php /fastcgi-bin/phpstub
|
||||||
FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin}
|
|
||||||
#end
|
|
||||||
AddType application/x-httpd-php .php
|
|
||||||
Action application/x-httpd-php /fastcgi-bin/hs-phpstub
|
|
||||||
#end
|
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
@ -5,29 +5,4 @@
|
|||||||
global="jdbc/HSAdminDB"
|
global="jdbc/HSAdminDB"
|
||||||
type="javax.sql.DataSource"/>
|
type="javax.sql.DataSource"/>
|
||||||
|
|
||||||
<ResourceLink
|
|
||||||
name="jms/QueueCF"
|
|
||||||
global="jms/QueueCF"
|
|
||||||
type="javax.jms.QueueConnectionFactory"/>
|
|
||||||
|
|
||||||
<ResourceLink
|
|
||||||
name="jms/hsadminSystem-h99"
|
|
||||||
global="jms/hsadminSystem-h99"
|
|
||||||
type="javax.jms.Queue"/>
|
|
||||||
|
|
||||||
<ResourceLink
|
|
||||||
name="jms/hsadminSystem-testmail"
|
|
||||||
global="jms/hsadminSystem-testmail"
|
|
||||||
type="javax.jms.Queue"/>
|
|
||||||
|
|
||||||
<ResourceLink
|
|
||||||
name="jms/hsadminSystem-testdns"
|
|
||||||
global="jms/hsadminSystem-testdns"
|
|
||||||
type="javax.jms.Queue"/>
|
|
||||||
|
|
||||||
<ResourceLink
|
|
||||||
name="jms/hsadminStatus"
|
|
||||||
global="jms/hsadminStatus"
|
|
||||||
type="javax.jms.Queue"/>
|
|
||||||
|
|
||||||
</Context>
|
</Context>
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
<?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" transaction-type="RESOURCE_LOCAL">
|
|
||||||
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
|
||||||
<non-jta-data-source>java:/comp/env/jdbc/HSAdminDB</non-jta-data-source>
|
|
||||||
<class>de.hsadmin.core.qserv.QueueTask</class>
|
|
||||||
<class>de.hsadmin.mods.cust.Customer</class>
|
|
||||||
<class>de.hsadmin.mods.cust.Contact</class>
|
|
||||||
<class>de.hsadmin.mods.pac.Pac</class>
|
|
||||||
<class>de.hsadmin.mods.pac.BasePac</class>
|
|
||||||
<class>de.hsadmin.mods.pac.BaseComponent</class>
|
|
||||||
<class>de.hsadmin.mods.pac.Component</class>
|
|
||||||
<class>de.hsadmin.mods.pac.PacComponent</class>
|
|
||||||
<class>de.hsadmin.mods.pac.Hive</class>
|
|
||||||
<class>de.hsadmin.mods.pac.INetAddress</class>
|
|
||||||
<class>de.hsadmin.mods.user.UnixUser</class>
|
|
||||||
<class>de.hsadmin.mods.dom.Domain</class>
|
|
||||||
<class>de.hsadmin.mods.dom.DomainOption</class>
|
|
||||||
<class>de.hsadmin.mods.email.EMailAddress</class>
|
|
||||||
<class>de.hsadmin.mods.email.EMailAlias</class>
|
|
||||||
<class>de.hsadmin.mods.db.DatabaseUser</class>
|
|
||||||
<class>de.hsadmin.mods.db.MySqlUser</class>
|
|
||||||
<class>de.hsadmin.mods.db.PgSqlUser</class>
|
|
||||||
<class>de.hsadmin.mods.db.Database</class>
|
|
||||||
<class>de.hsadmin.mods.db.MySqlDatabase</class>
|
|
||||||
<class>de.hsadmin.mods.db.PgSqlDatabase</class>
|
|
||||||
<properties>
|
|
||||||
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
|
|
||||||
<property name="openjpa.Compatibility" value="QuotedNumbersInQueries=true"/>
|
|
||||||
|
|
||||||
<property name="openjpa.Log" value="SQL=TRACE"/>
|
|
||||||
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72"/>
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
</persistence-unit>
|
|
||||||
</persistence>
|
|
@ -4,10 +4,6 @@
|
|||||||
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">
|
||||||
|
|
||||||
<listener>
|
|
||||||
<listener-class>de.hsadmin.servlets.PersistenceManagerContextListener</listener-class>
|
|
||||||
</listener>
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>Queue Status Servlet</servlet-name>
|
<servlet-name>Queue Status Servlet</servlet-name>
|
||||||
<servlet-class>de.hsadmin.servlets.QueueStatusReceiverServlet</servlet-class>
|
<servlet-class>de.hsadmin.servlets.QueueStatusReceiverServlet</servlet-class>
|
||||||
@ -57,36 +53,5 @@
|
|||||||
<res-auth>Container</res-auth>
|
<res-auth>Container</res-auth>
|
||||||
</resource-ref>
|
</resource-ref>
|
||||||
|
|
||||||
<resource-ref>
|
|
||||||
<res-ref-name>jms/QueueCF</res-ref-name>
|
|
||||||
<res-type>javax.jms.QueueConnectionFactory</res-type>
|
|
||||||
<res-auth>Container</res-auth>
|
|
||||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
|
||||||
</resource-ref>
|
|
||||||
|
|
||||||
<resource-ref>
|
|
||||||
<res-ref-name>jms/hsadminSystem-h99</res-ref-name>
|
|
||||||
<res-type>javax.jms.Queue</res-type>
|
|
||||||
<res-auth>Container</res-auth>
|
|
||||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
|
||||||
</resource-ref>
|
|
||||||
<resource-ref>
|
|
||||||
<res-ref-name>jms/hsadminSystem-testdns</res-ref-name>
|
|
||||||
<res-type>javax.jms.Queue</res-type>
|
|
||||||
<res-auth>Container</res-auth>
|
|
||||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
|
||||||
</resource-ref>
|
|
||||||
<resource-ref>
|
|
||||||
<res-ref-name>jms/hsadminSystem-testmail</res-ref-name>
|
|
||||||
<res-type>javax.jms.Queue</res-type>
|
|
||||||
<res-auth>Container</res-auth>
|
|
||||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
|
||||||
</resource-ref>
|
|
||||||
<resource-ref>
|
|
||||||
<res-ref-name>jms/hsadminStatus</res-ref-name>
|
|
||||||
<res-type>javax.jms.Queue</res-type>
|
|
||||||
<res-auth>Container</res-auth>
|
|
||||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
|
||||||
</resource-ref>
|
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import java.io.IOException;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.apache.xmlrpc.XmlRpcException;
|
import org.apache.xmlrpc.XmlRpcException;
|
||||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||||
@ -62,7 +61,7 @@ public class DomainTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateWithoutPermissionFail() {
|
public void testUpdate() {
|
||||||
String user = "aaa00";
|
String user = "aaa00";
|
||||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||||
Map<String, String> setParams = new HashMap<String, String>();
|
Map<String, String> setParams = new HashMap<String, String>();
|
||||||
@ -100,129 +99,6 @@ public class DomainTest {
|
|||||||
assertEquals(count + 1, getDomsCount());
|
assertEquals(count + 1, getDomsCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateDomain() {
|
|
||||||
String user = "aaa00";
|
|
||||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
|
||||||
|
|
||||||
// first create the domain
|
|
||||||
Map<String, Object> setParams = new HashMap<String, Object>();
|
|
||||||
setParams.put("name", "exampleupdate.de");
|
|
||||||
setParams.put("user", "aaa00-admin");
|
|
||||||
Object[] params = new Object[] { user,
|
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
||||||
setParams };
|
|
||||||
try {
|
|
||||||
Object execute = client.execute(MODULE + ".add", params);
|
|
||||||
assertTrue(execute instanceof Map<?, ?>);
|
|
||||||
} catch (XmlRpcException e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// check initial values
|
|
||||||
Map<String, String> whereParams = new HashMap<String, String>();
|
|
||||||
whereParams.put("name", "exampleupdate.de");
|
|
||||||
params = new Object[] { user,
|
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
||||||
whereParams };
|
|
||||||
try {
|
|
||||||
Object execute = client.execute(MODULE + ".search", params);
|
|
||||||
if (execute instanceof Object[]) {
|
|
||||||
Object[] result = (Object[]) execute;
|
|
||||||
assertTrue("expected 1 result, but got " + result.length, 1 == result.length);
|
|
||||||
for (Object o : result) {
|
|
||||||
if (o instanceof Map<?, ?>) {
|
|
||||||
Map<?, ?> row = (Map<?, ?>) o;
|
|
||||||
assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name")));
|
|
||||||
assertTrue("ValidSubdomainNames should be * but is " + row.get("validsubdomainnames"), "*".equals(row.get("validsubdomainnames")));
|
|
||||||
String defaultPassengerPython = "";
|
|
||||||
|
|
||||||
assertTrue("PassengerPython should be empty but is " + row.get("passengerpython"), isNullOrEmpty(row.get("passengerpython")));
|
|
||||||
assertTrue("PassengerNodejs should be empty but is " + row.get("passengernodejs"), isNullOrEmpty(row.get("passengernodejs")));
|
|
||||||
assertTrue("PassengerRuby should be empty but is " + row.get("passengerruby"), isNullOrEmpty(row.get("passengerruby")));
|
|
||||||
assertTrue("FcgiPhpBin should be empty but is " + row.get("fcgiphpbin"), isNullOrEmpty(row.get("fcgiphpbin")));
|
|
||||||
|
|
||||||
String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]);
|
|
||||||
String[] expectedDomainOptions = new String[] {"htdocsfallback", "cgi", "fastcgi", "passenger", "indexes", "dkim", "autoconfig", "greylisting", "includes", "letsencrypt", "multiviews"};
|
|
||||||
Arrays.sort(expectedDomainOptions);
|
|
||||||
Arrays.sort(checkDomainOptions);
|
|
||||||
assertTrue("Default Domainoptions should be " + Arrays.toString(expectedDomainOptions) + " but are " + Arrays.toString(checkDomainOptions),
|
|
||||||
Arrays.toString(expectedDomainOptions).equals(Arrays.toString(checkDomainOptions)));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fail("Map<?, ?> expected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fail("Object[] expected");
|
|
||||||
}
|
|
||||||
} catch (XmlRpcException e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// now update the domain
|
|
||||||
setParams = new HashMap<String, Object>();
|
|
||||||
setParams.put("validsubdomainnames", "www2");
|
|
||||||
|
|
||||||
String newPassengerPython = "/home/pacs/aaa00/users/admin/.venv/bin/python3";
|
|
||||||
setParams.put("passengerpython", newPassengerPython);
|
|
||||||
String newPassengerRuby = "/home/pacs/aaa00/users/admin/.rbenv/shims/ruby";
|
|
||||||
setParams.put("passengerruby", newPassengerRuby);
|
|
||||||
String newPassengerNodejs = "/home/pacs/aaa00/users/admin/.nvm/versions/node/v18.19.0/bin/node";
|
|
||||||
setParams.put("passengernodejs", newPassengerNodejs);
|
|
||||||
String newFcgiPhpBin = "/usr/lib/cgi-bin/php8.1";
|
|
||||||
setParams.put("fcgiphpbin", newFcgiPhpBin);
|
|
||||||
|
|
||||||
String[] newDomainOptions = new String[] {"greylisting", "letsencrypt", "passenger", "passengerfriendlyerrorpages", "cgi", "fastcgi"};
|
|
||||||
setParams.put("domainoptions", newDomainOptions);
|
|
||||||
|
|
||||||
whereParams = new HashMap<String, String>();
|
|
||||||
whereParams.put("name", "exampleupdate.de");
|
|
||||||
params = new Object[] { user,
|
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
|
||||||
setParams, whereParams };
|
|
||||||
try {
|
|
||||||
Object execute = client.execute(MODULE + ".update", params);
|
|
||||||
if (execute instanceof Object[]) {
|
|
||||||
Object[] result = (Object[]) execute;
|
|
||||||
assertTrue("expected 1 result, but got " + result.length, 1 == result.length);
|
|
||||||
for (Object o : result) {
|
|
||||||
if (o instanceof Map<?, ?>) {
|
|
||||||
Map<?, ?> row = (Map<?, ?>) o;
|
|
||||||
assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name")));
|
|
||||||
assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames")));
|
|
||||||
|
|
||||||
assertTrue("PassengerPython should be " + newPassengerPython + " but is " + row.get("passengerpython"), newPassengerPython.equals(row.get("passengerpython")));
|
|
||||||
assertTrue("PassengerNodejs should be " + newPassengerNodejs + " but is " + row.get("passengernodejs"), newPassengerNodejs.equals(row.get("passengernodejs")));
|
|
||||||
assertTrue("PassengerRuby should be " + newPassengerRuby + " but is " + row.get("passengerruby"), newPassengerRuby.equals(row.get("passengerruby")));
|
|
||||||
assertTrue("FcgiPhpBin should be " + newFcgiPhpBin + " but is " + row.get("fcgiphpbin"), newFcgiPhpBin.equals(row.get("fcgiphpbin")));
|
|
||||||
|
|
||||||
String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]);
|
|
||||||
Arrays.sort(newDomainOptions);
|
|
||||||
Arrays.sort(checkDomainOptions);
|
|
||||||
assertTrue("Domainoptions should be " + Arrays.toString(newDomainOptions) + " but are " + Arrays.toString(checkDomainOptions),
|
|
||||||
Arrays.toString(newDomainOptions).equals(Arrays.toString(checkDomainOptions)));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fail("Map<?, ?> expected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fail("Object[] expected");
|
|
||||||
}
|
|
||||||
} catch (XmlRpcException e) {
|
|
||||||
fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean isNullOrEmpty(Object s) {
|
|
||||||
if (s == null) return true;
|
|
||||||
if (((String)s).equals("")) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateForeignSubdomain() throws UnknownHostException, IOException {
|
public void testCreateForeignSubdomain() throws UnknownHostException, IOException {
|
||||||
int count = getDomsCount();
|
int count = getDomsCount();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>hsadmin-qserv</artifactId>
|
<artifactId>hsadmin-qserv</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HSAdmin-QServ</name>
|
<name>HSAdmin-QServ</name>
|
||||||
@ -17,10 +17,15 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.hsadmin.core</groupId>
|
||||||
|
<artifactId>hsadmin-util</artifactId>
|
||||||
|
<version>4.0.18</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin.core</groupId>
|
<groupId>de.hsadmin.core</groupId>
|
||||||
<artifactId>hsadmin-qserv</artifactId>
|
<artifactId>hsadmin-qserv</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.activemq</groupId>
|
<groupId>org.apache.activemq</groupId>
|
||||||
@ -79,6 +84,15 @@
|
|||||||
<prefix>/usr/local/lib/hostsharing/hsadmin</prefix>
|
<prefix>/usr/local/lib/hostsharing/hsadmin</prefix>
|
||||||
</mapper>
|
</mapper>
|
||||||
</data>
|
</data>
|
||||||
|
<data>
|
||||||
|
<src>src/deb/init/init_hive_mysqldb.sh</src>
|
||||||
|
<type>file</type>
|
||||||
|
<mapper>
|
||||||
|
<type>perm</type>
|
||||||
|
<prefix>/usr/local/lib/hostsharing/hsadmin/tools/</prefix>
|
||||||
|
<filemode>754</filemode>
|
||||||
|
</mapper>
|
||||||
|
</data>
|
||||||
<data>
|
<data>
|
||||||
<src>src/deb/systemd/hsadmin-qserv.service</src>
|
<src>src/deb/systemd/hsadmin-qserv.service</src>
|
||||||
<type>file</type>
|
<type>file</type>
|
||||||
|
50
qserv-deploy/src/deb/init/init_hive_mysqldb.sh
Normal file
50
qserv-deploy/src/deb/init/init_hive_mysqldb.sh
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mysql --defaults-file=/root/.my.cnf mysql <<EOSQL
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS kill_by_user;
|
||||||
|
DROP PROCEDURE IF EXISTS kill_by_database;
|
||||||
|
|
||||||
|
DELIMITER //
|
||||||
|
|
||||||
|
CREATE PROCEDURE kill_by_user (IN user_name VARCHAR(64) CHARSET utf8)
|
||||||
|
BEGIN
|
||||||
|
DECLARE query_id INT;
|
||||||
|
DECLARE iteration_complete INT DEFAULT 0;
|
||||||
|
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE user = user_name;
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
|
||||||
|
OPEN select_cursor;
|
||||||
|
cursor_loop: LOOP
|
||||||
|
FETCH select_cursor INTO query_id;
|
||||||
|
IF iteration_complete THEN
|
||||||
|
LEAVE cursor_loop;
|
||||||
|
END IF;
|
||||||
|
KILL query_id;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE select_cursor;
|
||||||
|
END
|
||||||
|
//
|
||||||
|
|
||||||
|
CREATE PROCEDURE kill_by_database (IN database_name VARCHAR(64))
|
||||||
|
BEGIN
|
||||||
|
DECLARE query_id INT;
|
||||||
|
DECLARE iteration_complete INT DEFAULT 0;
|
||||||
|
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE db = database_name;
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
|
||||||
|
OPEN select_cursor;
|
||||||
|
cursor_loop: LOOP
|
||||||
|
FETCH select_cursor INTO query_id;
|
||||||
|
IF iteration_complete THEN
|
||||||
|
LEAVE cursor_loop;
|
||||||
|
END IF;
|
||||||
|
KILL query_id;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE select_cursor;
|
||||||
|
END
|
||||||
|
//
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
EOSQL
|
||||||
|
|
||||||
|
echo "installed mysql procedures for hsadmin-qserv"
|
@ -4,9 +4,11 @@ After=network.target nss-lookup.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
WorkingDirectory=/usr/local/lib/hostsharing/hsadmin/qserv
|
||||||
Environment="PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
Environment="PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||||
Environment="JAVA_OPTS=-Xbootclasspath/a:/etc/hsadmin/qserv/ -Djavax.net.ssl.keyStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/etc/hsadmin/qserv/truststore -Djavax.net.ssl.trustStorePassword=password -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*"
|
Environment="JAVA_OPTS=-Xbootclasspath/a:/etc/hsadmin/qserv/ -Djavax.net.ssl.keyStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/etc/hsadmin/qserv/truststore -Djavax.net.ssl.trustStorePassword=password -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*"
|
||||||
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar /etc/hsadmin/qserv/qserv.properties
|
ExecStartPre=/bin/bash /usr/local/lib/hostsharing/hsadmin/tools/init_hive_mysqldb.sh
|
||||||
|
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar
|
||||||
StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err
|
StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
Restart=always
|
Restart=always
|
||||||
|
2
qserv/.gitignore
vendored
2
qserv/.gitignore
vendored
@ -4,4 +4,4 @@
|
|||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.settings/
|
.settings/
|
||||||
|
hsadmin.properties
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
hsadmin.jms.url=ssl://hsh02.hostsharing.net:61617
|
|
||||||
hsadmin.jms.username=user-h98
|
|
||||||
hsadmin.jms.password=kein-echtes-ppasswort
|
|
||||||
hsadmin.jms.system-queue=queue.hsadminSystem-h98
|
|
||||||
hsadmin.jms.status-queue=queue.hsadminStatus
|
|
||||||
accountprefix.customer=hsh00
|
|
||||||
accountprefix.hostmaster=hsh01
|
|
||||||
queues.dns=testdns
|
|
||||||
queues.mail=testmail
|
|
||||||
hsadmin.smtp.from=nobody@hostsharing.net
|
|
||||||
hsadmin.smtp.cc=hostmaster@hostsharing.net
|
|
||||||
loginURL=TestUmgebung
|
|
||||||
backendURL=https://config.hostsharing.net:443/hsar/backend
|
|
||||||
xmlrpcURL=http://localhost:8080/hsar/xmlrpc/hsadmin
|
|
@ -4,16 +4,16 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.hsadmin.core</groupId>
|
<groupId>de.hsadmin.core</groupId>
|
||||||
<artifactId>hsadmin-qserv</artifactId>
|
<artifactId>hsadmin-qserv</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>8</java.version>
|
<java.version>11</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin.core</groupId>
|
<groupId>de.hsadmin.core</groupId>
|
||||||
<artifactId>hsadmin-util</artifactId>
|
<artifactId>hsadmin-util</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
@ -27,13 +27,13 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.velocity</groupId>
|
<groupId>org.apache.velocity</groupId>
|
||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
<version>1.7</version>
|
<version>2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.openjpa</groupId>
|
<groupId>org.apache.openjpa</groupId>
|
||||||
<artifactId>openjpa</artifactId>
|
<artifactId>openjpa</artifactId>
|
||||||
<version>2.4.3</version>
|
<version>3.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -43,15 +43,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.activemq</groupId>
|
<groupId>org.apache.activemq</groupId>
|
||||||
<artifactId>activemq-all</artifactId>
|
<artifactId>activemq-client</artifactId>
|
||||||
<version>5.5.0</version>
|
<version>5.17.5</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
|
||||||
<artifactId>geronimo-jms_1.1_spec</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
@ -61,14 +54,14 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.openjpa</groupId>
|
<groupId>org.apache.openjpa</groupId>
|
||||||
<artifactId>openjpa-maven-plugin</artifactId>
|
<artifactId>openjpa-maven-plugin</artifactId>
|
||||||
<version>2.4.3</version>
|
<version>3.2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<includes>
|
<includes>
|
||||||
**/QueueTask.class,**/Domain.class,**/DomainOption.class,**/EMailAddress.class,**/EMailAlias.class,**/Customer.class,**/Contact.class,**/UnixUser.class,**/Pac.class,**/BasePac.class,**/BaseComponent.class,**/PacComponent.class,**/Component.class,**/Hive.class,**/INetAddress.class,**/Database.class,**/DatabaseUser.class,**/PgSqlDatabase.class,**/MySqlDatabase.class,**/PgSqlUser.class,**/MySqlUser.class
|
**/QueueTask.class,**/Domain.class,**/DomainOption.class,**/EMailAddress.class,**/EMailAlias.class,**/Customer.class,**/Contact.class,**/UnixUser.class,**/Pac.class,**/BasePac.class,**/BaseComponent.class,**/PacComponent.class,**/Component.class,**/Hive.class,**/INetAddress.class,**/Database.class,**/DatabaseUser.class,**/PgSqlDatabase.class,**/MySqlDatabase.class,**/PgSqlUser.class,**/MySqlUser.class
|
||||||
@ -89,40 +82,5 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.eclipse.m2e</groupId>
|
|
||||||
<artifactId>lifecycle-mapping</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<configuration>
|
|
||||||
<lifecycleMappingMetadata>
|
|
||||||
<pluginExecutions>
|
|
||||||
<pluginExecution>
|
|
||||||
<pluginExecutionFilter>
|
|
||||||
<groupId>
|
|
||||||
org.apache.openjpa
|
|
||||||
</groupId>
|
|
||||||
<artifactId>
|
|
||||||
openjpa-maven-plugin
|
|
||||||
</artifactId>
|
|
||||||
<versionRange>
|
|
||||||
[2.4.3,)
|
|
||||||
</versionRange>
|
|
||||||
<goals>
|
|
||||||
<goal>enhance</goal>
|
|
||||||
</goals>
|
|
||||||
</pluginExecutionFilter>
|
|
||||||
<action>
|
|
||||||
<ignore></ignore>
|
|
||||||
</action>
|
|
||||||
</pluginExecution>
|
|
||||||
</pluginExecutions>
|
|
||||||
</lifecycleMappingMetadata>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
@ -14,6 +14,7 @@ import de.hsadmin.core.qserv.EntityProcessorFactory;
|
|||||||
import de.hsadmin.core.qserv.NullProcessor;
|
import de.hsadmin.core.qserv.NullProcessor;
|
||||||
import de.hsadmin.core.qserv.Processor;
|
import de.hsadmin.core.qserv.Processor;
|
||||||
import de.hsadmin.core.qserv.QueueTask;
|
import de.hsadmin.core.qserv.QueueTask;
|
||||||
|
import de.hsadmin.core.qserv.TaskTransfer;
|
||||||
import de.hsadmin.core.util.HSAdminException;
|
import de.hsadmin.core.util.HSAdminException;
|
||||||
import de.hsadmin.mods.user.UnixUser;
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
@ -199,8 +200,10 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
|||||||
StringBuilder details = new StringBuilder();
|
StringBuilder details = new StringBuilder();
|
||||||
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;
|
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;
|
||||||
QueueTask task = new QueueTask(user, title, details.toString(), proc);
|
QueueTask task = new QueueTask(user, title, details.toString(), proc);
|
||||||
transaction.getEntityManager().persist(task);
|
final EntityManager entityManager = transaction.getEntityManager();
|
||||||
transaction.enqueue(entity.getHiveName(), task);
|
entityManager.persist(task);
|
||||||
|
entityManager.refresh(task);
|
||||||
|
transaction.enqueue(entity.getHiveName(), TaskTransfer.getTransferObject(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(StackTraceElement[] stackTrace) {
|
public String toString(StackTraceElement[] stackTrace) {
|
||||||
|
@ -2,6 +2,8 @@ package de.hsadmin.core.model;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
@ -13,6 +15,8 @@ public class PersistenceManager {
|
|||||||
|
|
||||||
private Map<String, EntityManagerFactory> persistenceUnits;
|
private Map<String, EntityManagerFactory> persistenceUnits;
|
||||||
|
|
||||||
|
private Logger logger = Logger.getLogger(PersistenceManager.class.getName());
|
||||||
|
|
||||||
public static EntityManager getEntityManager(String persistUnitName) {
|
public static EntityManager getEntityManager(String persistUnitName) {
|
||||||
EntityManagerFactory emf = PersistenceManager.getInstance().getEMF(persistUnitName);
|
EntityManagerFactory emf = PersistenceManager.getInstance().getEMF(persistUnitName);
|
||||||
return emf.createEntityManager();
|
return emf.createEntityManager();
|
||||||
@ -31,6 +35,7 @@ public class PersistenceManager {
|
|||||||
if (emf == null) {
|
if (emf == null) {
|
||||||
emf = Persistence.createEntityManagerFactory(persistUnitName);
|
emf = Persistence.createEntityManagerFactory(persistUnitName);
|
||||||
persistenceUnits.put(persistUnitName, emf);
|
persistenceUnits.put(persistUnitName, emf);
|
||||||
|
logger.log(Level.INFO, "Create Persistence Unit: " + persistUnitName);
|
||||||
}
|
}
|
||||||
return emf;
|
return emf;
|
||||||
}
|
}
|
||||||
@ -43,11 +48,11 @@ public class PersistenceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void closeFactories() {
|
private void closeFactories() {
|
||||||
for (String puName : persistenceUnits.keySet()) {
|
for (String persistUnitName : persistenceUnits.keySet()) {
|
||||||
System.out.println("Persistence Unit: " + puName);
|
logger.log(Level.INFO, "Close Persistence Unit: " + persistUnitName);
|
||||||
EntityManagerFactory emf = persistenceUnits.get(puName);
|
EntityManagerFactory emf = persistenceUnits.get(persistUnitName);
|
||||||
emf.close();
|
emf.close();
|
||||||
persistenceUnits.remove(puName);
|
persistenceUnits.remove(persistUnitName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,20 +6,20 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.jms.JMSException;
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
|
import javax.jms.QueueConnection;
|
||||||
import javax.jms.QueueConnectionFactory;
|
import javax.jms.QueueConnectionFactory;
|
||||||
import javax.naming.Context;
|
import javax.jms.QueueSession;
|
||||||
import javax.naming.InitialContext;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityTransaction;
|
import javax.persistence.EntityTransaction;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
|
||||||
//import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||||
|
|
||||||
import de.hsadmin.core.qserv.QueueClient;
|
import de.hsadmin.core.qserv.QueueClient;
|
||||||
import de.hsadmin.core.qserv.QueueTask;
|
import de.hsadmin.core.qserv.TaskTransfer;
|
||||||
import de.hsadmin.core.util.Config;
|
import de.hsadmin.core.util.Config;
|
||||||
import de.hsadmin.mods.cust.Customer;
|
import de.hsadmin.mods.cust.Customer;
|
||||||
import de.hsadmin.mods.pac.Pac;
|
import de.hsadmin.mods.pac.Pac;
|
||||||
@ -32,24 +32,23 @@ public class Transaction {
|
|||||||
private String loginName;
|
private String loginName;
|
||||||
private Map<String, QueueTaskStore> taskStores;
|
private Map<String, QueueTaskStore> taskStores;
|
||||||
private boolean transactionActive;
|
private boolean transactionActive;
|
||||||
private InitialContext ctx;
|
private Config config;
|
||||||
|
private String jmsServerUrl;
|
||||||
|
private String jmsUsername;
|
||||||
|
private String jmsPassword;
|
||||||
|
|
||||||
public Transaction(String loginName) {
|
public Transaction(String loginName) {
|
||||||
|
this.config = Config.getInstance();
|
||||||
|
this.jmsServerUrl = config.getProperty("hsadmin.jms.url", "tcp://localhost:61616");
|
||||||
|
this.jmsUsername = config.getProperty("hsadmin.jms.username", "hsar");
|
||||||
|
this.jmsPassword = config.getProperty("hsadmin.jms.password", "default");
|
||||||
this.transactionActive = false;
|
this.transactionActive = false;
|
||||||
this.entityManager = PersistenceManager.getEntityManager("hsadmin");
|
this.entityManager = PersistenceManager.getEntityManager("hsadmin");
|
||||||
this.loginName = loginName;
|
this.loginName = loginName;
|
||||||
this.taskStores = new HashMap<String, QueueTaskStore>();
|
this.taskStores = new HashMap<String, QueueTaskStore>();
|
||||||
try {
|
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsServerUrl);
|
||||||
ctx = new InitialContext();
|
mqConnectionFactory.setTrustAllPackages(true);
|
||||||
Context env = (Context) ctx.lookup("java:comp/env");
|
this.queueConnectionFactory = mqConnectionFactory;
|
||||||
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
|
|
||||||
// if (queueConnectionFactory instanceof ActiveMQConnectionFactory) {
|
|
||||||
// ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory;
|
|
||||||
// activeMQconnectionFatory.setTrustAllPackages(true);
|
|
||||||
// }
|
|
||||||
} catch (NamingException e) {
|
|
||||||
throw new TechnicalException("no jms queue: jms/QueueCF", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityManager getEntityManager() {
|
public EntityManager getEntityManager() {
|
||||||
@ -61,15 +60,14 @@ public class Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Queue lookupJMSQueue(String queueName) {
|
public Queue lookupJMSQueue(String queueName) {
|
||||||
if (ctx != null) {
|
try {
|
||||||
try {
|
final QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
|
||||||
Context env = (Context) ctx.lookup("java:comp/env");
|
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
||||||
return (Queue) env.lookup("jms/" + queueName);
|
final Queue queue = session.createQueue(queueName);
|
||||||
} catch (NamingException e) {
|
return queue;
|
||||||
throw new TechnicalException("no jms queue: jms/" + queueName, e);
|
} catch (JMSException e) {
|
||||||
}
|
throw new TechnicalException("no jms queue: jms/" + queueName, e);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLoginName() {
|
public String getLoginName() {
|
||||||
@ -79,7 +77,7 @@ public class Transaction {
|
|||||||
throw new TechnicalException("no login");
|
throw new TechnicalException("no login");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enqueue(String hiveName, QueueTask task) {
|
public void enqueue(String hiveName, TaskTransfer task) {
|
||||||
QueueTaskStore taskStore = taskStores.get(hiveName);
|
QueueTaskStore taskStore = taskStores.get(hiveName);
|
||||||
if (taskStore == null) {
|
if (taskStore == null) {
|
||||||
taskStore = new QueueTaskStore();
|
taskStore = new QueueTaskStore();
|
||||||
@ -91,13 +89,13 @@ public class Transaction {
|
|||||||
private void sendAll() {
|
private void sendAll() {
|
||||||
for (String hive : taskStores.keySet()) {
|
for (String hive : taskStores.keySet()) {
|
||||||
QueueTaskStore store = taskStores.get(hive);
|
QueueTaskStore store = taskStores.get(hive);
|
||||||
String queueName = "hsadminSystem-" + hive;
|
String queueName = "queue.hsadminSystem-" + hive;
|
||||||
Queue jmsSystemQueue = lookupJMSQueue(queueName);
|
Queue jmsSystemQueue = lookupJMSQueue(queueName);
|
||||||
QueueClient qClient = null;
|
QueueClient qClient = null;
|
||||||
try {
|
try {
|
||||||
qClient = new QueueClient(queueConnectionFactory, jmsSystemQueue);
|
qClient = new QueueClient(queueConnectionFactory, jmsSystemQueue);
|
||||||
for (QueueTask task : store.getTasks()) {
|
for (TaskTransfer taskTransfer : store.getTasks()) {
|
||||||
qClient.send(task);
|
qClient.send(taskTransfer);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new TechnicalException(e);
|
throw new TechnicalException(e);
|
||||||
@ -147,11 +145,13 @@ public class Transaction {
|
|||||||
if (transactionActive) {
|
if (transactionActive) {
|
||||||
rollbackTransaction();
|
rollbackTransaction();
|
||||||
}
|
}
|
||||||
entityManager.close();
|
if (entityManager != null) {
|
||||||
|
entityManager.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detach entities from hibernate session.
|
* Detach entities from JPA session.
|
||||||
* Used to detach entities before update. Makes it possible to compare
|
* Used to detach entities before update. Makes it possible to compare
|
||||||
* old and new attribute values.
|
* old and new attribute values.
|
||||||
*/
|
*/
|
||||||
@ -163,17 +163,17 @@ public class Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class QueueTaskStore {
|
class QueueTaskStore {
|
||||||
private List<QueueTask> taskList;
|
private List<TaskTransfer> taskList;
|
||||||
QueueTaskStore() {
|
QueueTaskStore() {
|
||||||
taskList = new ArrayList<QueueTask>();
|
taskList = new ArrayList<TaskTransfer>();
|
||||||
}
|
}
|
||||||
public void clear() {
|
public void clear() {
|
||||||
taskList = new ArrayList<QueueTask>();
|
taskList = new ArrayList<TaskTransfer>();
|
||||||
}
|
}
|
||||||
void add(QueueTask t) {
|
void add(TaskTransfer t) {
|
||||||
taskList.add(t);
|
taskList.add(t);
|
||||||
}
|
}
|
||||||
Iterable<QueueTask> getTasks() {
|
Iterable<TaskTransfer> getTasks() {
|
||||||
return taskList;
|
return taskList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,10 +181,10 @@ public class Transaction {
|
|||||||
public UnixUser getLoginUser() {
|
public UnixUser getLoginUser() {
|
||||||
String loginName = getLoginName();
|
String loginName = getLoginName();
|
||||||
if (loginName != null && loginName.length() == 2) {
|
if (loginName != null && loginName.length() == 2) {
|
||||||
loginName = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
|
loginName = config.getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
|
||||||
}
|
}
|
||||||
if (loginName != null && loginName.length() == 3) {
|
if (loginName != null && loginName.length() == 3) {
|
||||||
loginName = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
|
loginName = config.getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
|
||||||
}
|
}
|
||||||
Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
|
Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
|
||||||
userQuery.setParameter("username", loginName);
|
userQuery.setParameter("username", loginName);
|
||||||
@ -200,7 +200,7 @@ public class Transaction {
|
|||||||
if (ticketUser != null && ticketUser.length() == 2) {
|
if (ticketUser != null && ticketUser.length() == 2) {
|
||||||
return true; // 2-letter hostmaster
|
return true; // 2-letter hostmaster
|
||||||
}
|
}
|
||||||
String hostmasterAccountPrefix = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-";
|
String hostmasterAccountPrefix = config.getProperty("accountprefix.hostmaster", "hsh01") + "-";
|
||||||
if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) {
|
if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) {
|
||||||
return true; // hsh01 hostmaster
|
return true; // hsh01 hostmaster
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ public class Transaction {
|
|||||||
String pacName = unixUser.getPac().getName();
|
String pacName = unixUser.getPac().getName();
|
||||||
return ticketUser.equals(pacName); // pac-admin
|
return ticketUser.equals(pacName); // pac-admin
|
||||||
}
|
}
|
||||||
String memberAccountPrefix = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-";
|
String memberAccountPrefix = config.getProperty("accountprefix.customer", "hsh00") + "-";
|
||||||
if (ticketUser != null && (ticketUser.length() == 3 || (ticketUser.length() >= 9 && ticketUser.startsWith(memberAccountPrefix)))) {
|
if (ticketUser != null && (ticketUser.length() == 3 || (ticketUser.length() >= 9 && ticketUser.startsWith(memberAccountPrefix)))) {
|
||||||
Query memberQuery = getEntityManager().createQuery("SELECT c FROM Customers c WHERE c.name = :membername");
|
Query memberQuery = getEntityManager().createQuery("SELECT c FROM Customers c WHERE c.name = :membername");
|
||||||
memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser);
|
memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser);
|
||||||
|
@ -14,4 +14,9 @@ abstract public class AbstractProcessor implements Processor {
|
|||||||
task.done();
|
task.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "a Processor of class " + this.getClass().getCanonicalName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class JDBCProcessor extends AbstractProcessor {
|
|||||||
throw new ProcessorException("cannot connect to '" + url + "'");
|
throw new ProcessorException("cannot connect to '" + url + "'");
|
||||||
Statement s = c.createStatement();
|
Statement s = c.createStatement();
|
||||||
for (String sqlStatement : sql) {
|
for (String sqlStatement : sql) {
|
||||||
System.out.println("SQL: " + sqlStatement);
|
LOG.fine("SQL: " + sqlStatement);
|
||||||
s.execute(sqlStatement);
|
s.execute(sqlStatement);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -67,7 +67,7 @@ public class JDBCProcessor extends AbstractProcessor {
|
|||||||
exc = aSqlExc;
|
exc = aSqlExc;
|
||||||
}
|
}
|
||||||
errorMsg = exc.getMessage();
|
errorMsg = exc.getMessage();
|
||||||
System.out.println("ERR: " + errorMsg);
|
LOG.severe("ERR: " + errorMsg);
|
||||||
throw new ProcessorException(aSqlExc.getMessage() + ", reason: " + errorMsg);
|
throw new ProcessorException(aSqlExc.getMessage() + ", reason: " + errorMsg);
|
||||||
} catch (Exception aExc) {
|
} catch (Exception aExc) {
|
||||||
throw new ProcessorException(aExc.getMessage());
|
throw new ProcessorException(aExc.getMessage());
|
||||||
|
@ -3,7 +3,7 @@ package de.hsadmin.core.qserv;
|
|||||||
|
|
||||||
public class NullProcessor extends AbstractProcessor {
|
public class NullProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = -3667951484545665538L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object process() throws ProcessorException {
|
public Object process() throws ProcessorException {
|
||||||
|
@ -18,7 +18,7 @@ import de.hsadmin.core.util.Config;
|
|||||||
*
|
*
|
||||||
* @author mi
|
* @author mi
|
||||||
*/
|
*/
|
||||||
public class QueueClient extends QueueCommons {
|
public class QueueClient {
|
||||||
|
|
||||||
private QueueConnectionFactory jmsConnectionFactory;
|
private QueueConnectionFactory jmsConnectionFactory;
|
||||||
private Queue jmsSystemQueue;
|
private Queue jmsSystemQueue;
|
||||||
@ -36,11 +36,11 @@ public class QueueClient extends QueueCommons {
|
|||||||
String jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
|
String jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
|
||||||
String jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
|
String jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
|
||||||
jmsConnection = jmsConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
jmsConnection = jmsConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
||||||
jmsSession = jmsConnection.createQueueSession(DEFAULT, Session.AUTO_ACKNOWLEDGE);
|
jmsSession = jmsConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
jmsSender = jmsSession.createSender(jmsSystemQueue);
|
jmsSender = jmsSession.createSender(jmsSystemQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(QueueTask task) throws ProcessorException {
|
public void send(TaskTransfer task) throws ProcessorException {
|
||||||
try {
|
try {
|
||||||
ObjectMessage jmsMessage = jmsSession.createObjectMessage(task);
|
ObjectMessage jmsMessage = jmsSession.createObjectMessage(task);
|
||||||
jmsSender.send(jmsMessage);
|
jmsSender.send(jmsMessage);
|
||||||
@ -55,7 +55,7 @@ public class QueueClient extends QueueCommons {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String queueName(Queue jmsSystemQueue2) {
|
private String queueName(Queue jmsSystemQueue) {
|
||||||
try {
|
try {
|
||||||
return jmsSystemQueue.getQueueName();
|
return jmsSystemQueue.getQueueName();
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package de.hsadmin.core.qserv;
|
|
||||||
|
|
||||||
public class QueueCommons
|
|
||||||
{
|
|
||||||
protected static final boolean TRANSACTED = true;
|
|
||||||
protected static final boolean IMMEDIATE = false;
|
|
||||||
protected static final boolean DEFAULT = IMMEDIATE;
|
|
||||||
|
|
||||||
public QueueCommons()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +1,8 @@
|
|||||||
package de.hsadmin.core.qserv;
|
package de.hsadmin.core.qserv;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.jms.Connection;
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.jms.Destination;
|
|
||||||
import javax.jms.ExceptionListener;
|
import javax.jms.ExceptionListener;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
@ -17,90 +11,82 @@ import javax.jms.MessageProducer;
|
|||||||
import javax.jms.ObjectMessage;
|
import javax.jms.ObjectMessage;
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
import javax.jms.QueueConnection;
|
import javax.jms.QueueConnection;
|
||||||
import javax.jms.QueueConnectionFactory;
|
|
||||||
import javax.jms.QueueReceiver;
|
import javax.jms.QueueReceiver;
|
||||||
import javax.jms.QueueSession;
|
import javax.jms.QueueSession;
|
||||||
import javax.jms.Session;
|
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
|
|
||||||
public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener {
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
|
|
||||||
private static final String VERSION_NO = "4.0.11";
|
import de.hsadmin.core.util.Config;
|
||||||
|
|
||||||
|
public class QueueServer implements MessageListener, ExceptionListener {
|
||||||
|
|
||||||
|
private static final String VERSION_NO = "4.0.16";
|
||||||
|
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
private QueueConnection conn;
|
|
||||||
private QueueSession queueSession;
|
private String jmsUrl;
|
||||||
private String jmsStatusQueue;
|
private String jmsUsername;
|
||||||
private String jmsPassWord;
|
private String jmsPassword;
|
||||||
private String jmsUserName;
|
|
||||||
private String jmsSystemQueue;
|
private String jmsSystemQueue;
|
||||||
private String jmsFactory;
|
private String jmsStatusQueue;
|
||||||
private String serviceEMail;
|
private String serviceEMail;
|
||||||
private String fromEMail;
|
private String fromEMail;
|
||||||
|
|
||||||
|
private QueueConnection queueConnection;
|
||||||
|
private boolean isConnected;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the QueueServer, using the arguments as ConnectionFactory
|
* Runs the QueueServer.
|
||||||
* and Topic names.
|
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
File propFile = new File(System.getProperty("user.dir"), "conf/qserv.properties");
|
final Config config = Config.getInstance();
|
||||||
if (args.length == 1) {
|
System.setProperty("java.util.logging.config.file", config.getProperty("hsadmin.log.config", System.getProperty("user.home") + "/.hsadmin.log.properties"));
|
||||||
propFile = new File(args[0]);
|
|
||||||
} else {
|
|
||||||
if (args.length != 0) {
|
|
||||||
throw new Exception(userHelp(propFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FileInputStream propStream = new FileInputStream(propFile);
|
|
||||||
Properties props = new Properties(System.getProperties());
|
|
||||||
props.load(propStream);
|
|
||||||
propStream.close();
|
|
||||||
System.setProperty("java.util.logging.config.file", props.getProperty("hsadmin.log.config", System.getProperty("user.home") + "/.hsadmin.log.properties"));
|
|
||||||
final QueueServer qServ = new QueueServer();
|
final QueueServer qServ = new QueueServer();
|
||||||
qServ.setJmsFactory(props.getProperty("hsadmin.jms.factory"));
|
qServ.setJmsURL(config.getProperty("hsadmin.jms.url"));
|
||||||
qServ.setJmsSystemQueue(props.getProperty("hsadmin.jms.system-queue"));
|
qServ.setJmsSystemQueue(config.getProperty("hsadmin.jms.system-queue"));
|
||||||
qServ.setJmsStatusQueue(props.getProperty("hsadmin.jms.status-queue"));
|
qServ.setJmsStatusQueue(config.getProperty("hsadmin.jms.status-queue"));
|
||||||
qServ.setJmsUserName(props.getProperty("hsadmin.jms.username"));
|
qServ.setJmsUserName(config.getProperty("hsadmin.jms.username"));
|
||||||
qServ.setJmsPassWord(props.getProperty("hsadmin.jms.password"));
|
qServ.setJmsPassWord(config.getProperty("hsadmin.jms.password"));
|
||||||
qServ.setServiceEMail(props.getProperty("hsadmin.log.email"));
|
qServ.setServiceEMail(config.getProperty("hsadmin.log.email"));
|
||||||
qServ.setFromEMail(props.getProperty("hsadmin.log.from"));
|
qServ.setFromEMail(config.getProperty("hsadmin.log.from"));
|
||||||
Logger logger = Logger.getLogger("de.hsadmin.core.qserv");
|
Logger logger = Logger.getLogger("de.hsadmin.core.qserv");
|
||||||
logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:"
|
logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:"
|
||||||
+ "\nqueue server: " + props.getProperty("hsadmin.jms.factory")
|
+ "\nsystem queue: " + config.getProperty("hsadmin.jms.system-queue")
|
||||||
+ "\nsystem queue: " + props.getProperty("hsadmin.jms.system-queue")
|
+ "\nstatus queue: " + config.getProperty("hsadmin.jms.status-queue")
|
||||||
+ "\nstatus queue: " + props.getProperty("hsadmin.jms.status-queue")
|
+ "\nqueue user: " + config.getProperty("hsadmin.jms.username"));
|
||||||
+ "\nqueue user: " + props.getProperty("hsadmin.jms.username"));
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
qServ.close();
|
qServ.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
while (!qServ.connect()) {
|
|
||||||
Thread.sleep(10000);
|
|
||||||
}
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.sleep(10000);
|
if (!qServ.isConnected()) {
|
||||||
|
qServ.connect();
|
||||||
|
}
|
||||||
|
Thread.sleep(30000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String userHelp(File propFile) {
|
protected void close() {
|
||||||
return "Wrong number of arguments.\n"
|
if (queueConnection != null) {
|
||||||
+ "With no arguments '"
|
try {
|
||||||
+ propFile
|
queueConnection.close();
|
||||||
+ "' will be used as config file.\n"
|
} catch (JMSException e) {
|
||||||
+ "Or give a properties file as single argument.\n\n"
|
logger.log(Level.SEVERE, e.getMessage());
|
||||||
+ "Example config file:\n\n"
|
}
|
||||||
+ "hsadmin.jms.factory=QueueCF\n"
|
}
|
||||||
+ "hsadmin.jms.system-queue=hive-h01\n"
|
|
||||||
+ "hsadmin.jms.status-queue=queue/hsadminStatus\n"
|
|
||||||
+ "hsadmin.jms.username=hive-h01\n"
|
|
||||||
+ "hsadmin.jms.password=geheimeskennwort\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueueServer() {
|
public QueueServer() {
|
||||||
logger = Logger.getLogger("de.hsadmin.core.qserv");
|
logger = Logger.getLogger("de.hsadmin.core.qserv");
|
||||||
|
queueConnection = null;
|
||||||
|
isConnected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isConnected() {
|
||||||
|
return isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setServiceEMail(String emailAddress) {
|
private void setServiceEMail(String emailAddress) {
|
||||||
@ -119,32 +105,31 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean connect() {
|
private void connect() {
|
||||||
// create JMS connection and session
|
|
||||||
try {
|
try {
|
||||||
Context ctx = new InitialContext();
|
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl);
|
||||||
QueueConnectionFactory connectionFactory =
|
mqConnectionFactory.setTrustAllPackages(true);
|
||||||
(QueueConnectionFactory) ctx.lookup(jmsFactory);
|
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
|
||||||
conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord);
|
queueConnection.setExceptionListener(this);
|
||||||
conn.setExceptionListener(this);
|
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
||||||
queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
Queue queue = session.createQueue(jmsSystemQueue);
|
||||||
Queue queue = (Queue) ctx.lookup(jmsSystemQueue);
|
queueConnection.start();
|
||||||
conn.start();
|
final QueueReceiver receiver = session.createReceiver(queue);
|
||||||
QueueReceiver receiver = queueSession.createReceiver(queue);
|
|
||||||
receiver.setMessageListener(this);
|
receiver.setMessageListener(this);
|
||||||
return true;
|
isConnected = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING, e.getMessage(), e);
|
logger.log(Level.WARNING, e.getMessage(), e);
|
||||||
return false;
|
isConnected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void onMessage(Message jmsMessage) {
|
public synchronized void onMessage(final Message jmsMessage) {
|
||||||
|
assert jmsMessage != null;
|
||||||
logger.log(Level.INFO, jmsMessage.toString());
|
logger.log(Level.INFO, jmsMessage.toString());
|
||||||
QueueTask task = null;
|
TaskTransfer task = null;
|
||||||
try {
|
try {
|
||||||
ObjectMessage jmsObjectMessage = (ObjectMessage) jmsMessage;
|
ObjectMessage jmsObjectMessage = (ObjectMessage) jmsMessage;
|
||||||
task = (QueueTask) jmsObjectMessage.getObject();
|
task = (TaskTransfer) jmsObjectMessage.getObject();
|
||||||
Processor processor = task.getProcessor();
|
Processor processor = task.getProcessor();
|
||||||
logger.log(Level.INFO, "processing (" + task.getTitle() + " | started("
|
logger.log(Level.INFO, "processing (" + task.getTitle() + " | started("
|
||||||
+ task.getStarted() + ") |" + task.getDetails() + "|"
|
+ task.getStarted() + ") |" + task.getDetails() + "|"
|
||||||
@ -154,12 +139,12 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
|
|||||||
logger.log(Level.INFO, "done");
|
logger.log(Level.INFO, "done");
|
||||||
} catch (ProcessorException e) {
|
} catch (ProcessorException e) {
|
||||||
logException(e);
|
logException(e);
|
||||||
task.setException(e);
|
task.setException(e.getMessage());
|
||||||
SmtpHelper.send(fromEMail, serviceEMail, jmsSystemQueue, processor.logInfo());
|
SmtpHelper.send(fromEMail, serviceEMail, jmsSystemQueue, processor.logInfo());
|
||||||
}
|
}
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
logException(throwable);
|
logException(throwable);
|
||||||
task.setException(throwable);
|
task.setException(throwable.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
sendStatus(task);
|
sendStatus(task);
|
||||||
notifyAll();
|
notifyAll();
|
||||||
@ -178,70 +163,53 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
|
|||||||
public void onException(JMSException e) {
|
public void onException(JMSException e) {
|
||||||
logger.log(Level.WARNING, e.getMessage(), e);
|
logger.log(Level.WARNING, e.getMessage(), e);
|
||||||
close();
|
close();
|
||||||
while (!connect()) {
|
isConnected = false;
|
||||||
try {
|
|
||||||
Thread.sleep(10000);
|
|
||||||
} catch (InterruptedException e1) { }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
protected void sendStatus(TaskTransfer queueMessage) {
|
||||||
if (queueSession != null) {
|
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl);
|
||||||
try {
|
mqConnectionFactory.setTrustAllPackages(true);
|
||||||
queueSession.close();
|
QueueConnection queueConnection = null;
|
||||||
} catch (JMSException e1) { }
|
|
||||||
}
|
|
||||||
if (conn != null) {
|
|
||||||
try {
|
|
||||||
conn.close();
|
|
||||||
} catch (JMSException e1) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void sendStatus(QueueTask queueMessage) {
|
|
||||||
MessageProducer producer = null;
|
MessageProducer producer = null;
|
||||||
Session statusSession = null;
|
QueueSession session = null;
|
||||||
Connection statusConnection = null;
|
|
||||||
try {
|
try {
|
||||||
logger.log(Level.INFO, "sendStatus(" + queueMessage + ")");
|
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
|
||||||
Context ctx = new InitialContext();
|
queueConnection.setExceptionListener(this);
|
||||||
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(jmsFactory);
|
session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
||||||
Destination queue = (Destination) ctx.lookup(jmsStatusQueue);
|
final Queue queue = session.createQueue(jmsStatusQueue);
|
||||||
statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord);
|
queueConnection.start();
|
||||||
statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
producer = session.createProducer(queue);
|
||||||
producer = statusSession.createProducer(queue);
|
final ObjectMessage statusMessage = session.createObjectMessage(queueMessage);
|
||||||
ObjectMessage statusMessage = statusSession.createObjectMessage(queueMessage);
|
|
||||||
logger.log(Level.INFO, "send(" + statusMessage + ")");
|
|
||||||
producer.send(statusMessage);
|
producer.send(statusMessage);
|
||||||
|
logger.log(Level.INFO, "send(" + statusMessage + ")");
|
||||||
} catch (Exception statusException) {
|
} catch (Exception statusException) {
|
||||||
logger.log(Level.SEVERE, statusException.getMessage(), statusException);
|
logger.log(Level.SEVERE, statusException.getMessage(), statusException);
|
||||||
} finally {
|
} finally {
|
||||||
// close JMS
|
if (producer != null) try { producer.close(); } catch (Exception e) { }
|
||||||
try { producer.close(); } catch (Exception exc) { }
|
if (session != null) try { session.close(); } catch (Exception e) { }
|
||||||
try { statusSession.close(); } catch (Exception exc) { }
|
if (queueConnection != null) try { queueConnection.close(); } catch (Exception e) { }
|
||||||
try { statusConnection.close(); } catch (Exception exc) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJmsStatusQueue(String property) {
|
private void setJmsURL(String property) {
|
||||||
jmsStatusQueue = property;
|
jmsUrl = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJmsPassWord(String property) {
|
public void setJmsPassWord(String property) {
|
||||||
jmsPassWord = property;
|
jmsPassword = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJmsUserName(String property) {
|
public void setJmsUserName(String property) {
|
||||||
jmsUserName = property;
|
jmsUsername = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJmsSystemQueue(String property) {
|
public void setJmsSystemQueue(String property) {
|
||||||
jmsSystemQueue = property;
|
jmsSystemQueue = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJmsFactory(String property) {
|
public void setJmsStatusQueue(String property) {
|
||||||
jmsFactory = property;
|
jmsStatusQueue = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -223,14 +223,13 @@ public class QueueTask extends AbstractEntity implements Serializable {
|
|||||||
* assigns all data field of qt to this instance, with
|
* assigns all data field of qt to this instance, with
|
||||||
* the exception of the id
|
* the exception of the id
|
||||||
*/
|
*/
|
||||||
public void assign(QueueTask qt) {
|
public void assign(TaskTransfer qt) {
|
||||||
this.user = qt.user;
|
this.title = qt.getTitle();
|
||||||
this.title = qt.title;
|
this.details = qt.getDetails();
|
||||||
this.details = qt.details;
|
this.started = qt.getStarted();
|
||||||
this.started = qt.started;
|
this.finished = qt.getFinished();
|
||||||
this.finished = qt.finished;
|
this.proc = qt.getProcessor();
|
||||||
this.proc = qt.proc;
|
this.exception = qt.getException();
|
||||||
this.exception = qt.exception;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,7 @@ package de.hsadmin.core.qserv;
|
|||||||
*/
|
*/
|
||||||
public class ShellProcessor extends AbstractProcessor {
|
public class ShellProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = -8340381162948081669L;
|
||||||
|
|
||||||
private String aSystemCall;
|
private String aSystemCall;
|
||||||
private String aInput;
|
private String aInput;
|
||||||
|
@ -6,6 +6,7 @@ import java.io.Writer;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.apache.commons.net.smtp.SMTPClient;
|
import org.apache.commons.net.smtp.SMTPClient;
|
||||||
import org.apache.commons.net.smtp.SMTPReply;
|
import org.apache.commons.net.smtp.SMTPReply;
|
||||||
@ -16,6 +17,8 @@ import de.hsadmin.core.util.HSAdminException;
|
|||||||
|
|
||||||
public class SmtpHelper {
|
public class SmtpHelper {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(SmtpHelper.class.getName());
|
||||||
|
|
||||||
public static void send(String fromAddress, String toAddress, String subject, String text)
|
public static void send(String fromAddress, String toAddress, String subject, String text)
|
||||||
throws HSAdminException {
|
throws HSAdminException {
|
||||||
send(fromAddress, toAddress, null, subject, text);
|
send(fromAddress, toAddress, null, subject, text);
|
||||||
@ -24,9 +27,10 @@ public class SmtpHelper {
|
|||||||
public static void send(String fromAddress, String toAddress, String ccAddress, String subject, String text)
|
public static void send(String fromAddress, String toAddress, String ccAddress, String subject, String text)
|
||||||
throws HSAdminException {
|
throws HSAdminException {
|
||||||
try {
|
try {
|
||||||
SMTPClient client = new SMTPClient();
|
final SMTPClient client = new SMTPClient();
|
||||||
String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName();
|
String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName();
|
||||||
String smtpHost = Config.getInstance().getProperty("smtp.host");
|
final Config config = Config.getInstance();
|
||||||
|
String smtpHost = config.getProperty("smtp.host");
|
||||||
if (smtpHost == null || smtpHost.trim().isEmpty()) {
|
if (smtpHost == null || smtpHost.trim().isEmpty()) {
|
||||||
smtpHost = "localhost";
|
smtpHost = "localhost";
|
||||||
}
|
}
|
||||||
@ -34,11 +38,10 @@ public class SmtpHelper {
|
|||||||
if (subject.toLowerCase().contains("error")) {
|
if (subject.toLowerCase().contains("error")) {
|
||||||
throw new HSAdminException("Konnte Mail nicht senden");
|
throw new HSAdminException("Konnte Mail nicht senden");
|
||||||
}
|
}
|
||||||
System.out.println("------------------------");
|
LOG.finer("From: " + fromAddress);
|
||||||
System.out.println("From: " + fromAddress);
|
LOG.finer("To: " + toAddress);
|
||||||
System.out.println("To: " + toAddress);
|
LOG.finer("Subject: " + subject);
|
||||||
System.out.println("Subject: " + subject);
|
LOG.finer(text);
|
||||||
System.out.println("\n" + text);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.connect(smtpHost, 25);
|
client.connect(smtpHost, 25);
|
||||||
|
130
qserv/src/main/java/de/hsadmin/core/qserv/TaskTransfer.java
Normal file
130
qserv/src/main/java/de/hsadmin/core/qserv/TaskTransfer.java
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
package de.hsadmin.core.qserv;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
|
public class TaskTransfer implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2120247737335542484L;
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
private String unixuser;
|
||||||
|
private Date started;
|
||||||
|
private Date finished;
|
||||||
|
private String title;
|
||||||
|
private String details;
|
||||||
|
private Processor proc;
|
||||||
|
private String exception;
|
||||||
|
|
||||||
|
public TaskTransfer() {
|
||||||
|
id = 0L;
|
||||||
|
unixuser = "anonymous";
|
||||||
|
started = new Date();
|
||||||
|
finished = null;
|
||||||
|
title = "untitled";
|
||||||
|
details = "none";
|
||||||
|
setProcessor(new NullProcessor());
|
||||||
|
setException("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskTransfer(long id, String unixuser, Date started, Date finished, String title, String details, Processor proc, String exception) {
|
||||||
|
this.id = id;
|
||||||
|
this.unixuser = unixuser;
|
||||||
|
this.started = started;
|
||||||
|
this.finished = finished;
|
||||||
|
this.title = title;
|
||||||
|
this.details = details;
|
||||||
|
this.setProcessor(proc);
|
||||||
|
this.setException(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnixuser() {
|
||||||
|
return unixuser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnixuser(String unixuser) {
|
||||||
|
this.unixuser = unixuser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStarted() {
|
||||||
|
return started;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStarted(Date started) {
|
||||||
|
this.started = started;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFinished() {
|
||||||
|
return finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinished(Date finished) {
|
||||||
|
this.finished = finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetails() {
|
||||||
|
return details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDetails(String details) {
|
||||||
|
this.details = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Processor getProcessor() {
|
||||||
|
return proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcessor(Processor proc) {
|
||||||
|
this.proc = proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getException() {
|
||||||
|
return exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setException(String exception) {
|
||||||
|
this.exception = exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return Long.toString(id) + "|" + title + "|" + started.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TaskTransfer getTransferObject(QueueTask task) {
|
||||||
|
long id = task.getId();
|
||||||
|
final UnixUser user = task.getUser();
|
||||||
|
String username = "anonymous";
|
||||||
|
if (user == null) {
|
||||||
|
username = "anonymous";
|
||||||
|
} else {
|
||||||
|
username = user.getName();
|
||||||
|
}
|
||||||
|
Date started = task.getStarted();
|
||||||
|
Date finished = task.getFinished();
|
||||||
|
String title = task.getTitle();
|
||||||
|
String details = task.getDetails();
|
||||||
|
Processor proc = task.getProcessor();
|
||||||
|
String exception = task.getException();
|
||||||
|
return new TaskTransfer(id, username, started, finished, title, details, proc, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
|
|
||||||
public class WaitingTasksProcessor extends AbstractProcessor {
|
public class WaitingTasksProcessor extends AbstractProcessor {
|
||||||
@ -29,8 +31,10 @@ public class WaitingTasksProcessor extends AbstractProcessor {
|
|||||||
for (WaitingProcessor p : waitingTasks) {
|
for (WaitingProcessor p : waitingTasks) {
|
||||||
QueueTask wTask =
|
QueueTask wTask =
|
||||||
new QueueTask(task.getUser(), task.getTitle() + " / " + p.getTitle(), task.getTitle() + " / " + p.getTitle(), p.getProc());
|
new QueueTask(task.getUser(), task.getTitle() + " / " + p.getTitle(), task.getTitle() + " / " + p.getTitle(), p.getProc());
|
||||||
transaction.getEntityManager().persist(wTask);
|
final EntityManager entityManager = transaction.getEntityManager();
|
||||||
transaction.enqueue(p.getHost(), wTask);
|
entityManager.persist(wTask);
|
||||||
|
entityManager.refresh(wTask);
|
||||||
|
transaction.enqueue(p.getHost(), TaskTransfer.getTransferObject(wTask));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.finalize(transaction, task);
|
super.finalize(transaction, task);
|
||||||
|
@ -55,10 +55,6 @@ public class Domain extends AbstractEntity {
|
|||||||
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
|
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
|
||||||
private String dnsMaster;
|
private String dnsMaster;
|
||||||
|
|
||||||
@AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE)
|
|
||||||
@Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)")
|
|
||||||
private String validsubdomainnames;
|
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-zA-Z0-9\\-\\.]*", rw=ReadWriteAccess.READWRITE, referTo=DomainOption.class, selectableValues=DomainOptionValues.class)
|
@AnnFieldIO(validation="[a-zA-Z0-9\\-\\.]*", rw=ReadWriteAccess.READWRITE, referTo=DomainOption.class, selectableValues=DomainOptionValues.class)
|
||||||
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
|
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
|
||||||
@JoinTable(name="domain__domain_option",
|
@JoinTable(name="domain__domain_option",
|
||||||
@ -66,21 +62,9 @@ public class Domain extends AbstractEntity {
|
|||||||
inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")})
|
inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")})
|
||||||
private Set<DomainOption> domainoptions;
|
private Set<DomainOption> domainoptions;
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
|
@AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE)
|
||||||
@Column(name = "passenger_python", columnDefinition = "character varying(256)")
|
@Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)")
|
||||||
private String passengerpython;
|
private String validsubdomainnames;
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
|
|
||||||
@Column(name = "passenger_nodejs", columnDefinition = "character varying(256)")
|
|
||||||
private String passengernodejs;
|
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
|
|
||||||
@Column(name = "passenger_ruby", columnDefinition = "character varying(256)")
|
|
||||||
private String passengerruby;
|
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
|
|
||||||
@Column(name = "fcgi_php_bin", columnDefinition = "character varying(256)")
|
|
||||||
private String fcgiphpbin;
|
|
||||||
|
|
||||||
public Domain() {
|
public Domain() {
|
||||||
}
|
}
|
||||||
@ -191,14 +175,6 @@ public class Domain extends AbstractEntity {
|
|||||||
"obj.user=:loginUser";
|
"obj.user=:loginUser";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValidsubdomainnames() {
|
|
||||||
return validsubdomainnames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidsubdomainnames(String validSubdomainNames) {
|
|
||||||
this.validsubdomainnames = validSubdomainNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<DomainOption> getDomainoptions() {
|
public Set<DomainOption> getDomainoptions() {
|
||||||
return domainoptions;
|
return domainoptions;
|
||||||
}
|
}
|
||||||
@ -207,48 +183,12 @@ public class Domain extends AbstractEntity {
|
|||||||
this.domainoptions = domainOptions;
|
this.domainoptions = domainOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassengerpython() {
|
public String getValidsubdomainnames() {
|
||||||
if (passengerpython == null) {
|
return validsubdomainnames;
|
||||||
return "/usr/bin/python3";
|
|
||||||
}
|
|
||||||
return passengerpython;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPassengerpython(String value) {
|
public void setValidsubdomainnames(String validSubdomainNames) {
|
||||||
this.passengerpython = value;
|
this.validsubdomainnames = validSubdomainNames;
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassengernodejs() {
|
|
||||||
if (passengernodejs == null) {
|
|
||||||
return "/usr/bin/node";
|
|
||||||
}
|
|
||||||
return passengernodejs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassengernodejs(String value) {
|
|
||||||
this.passengernodejs = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassengerruby() {
|
|
||||||
if (passengerruby == null) {
|
|
||||||
return "/usr/bin/ruby";
|
|
||||||
}
|
|
||||||
return passengerruby;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassengerruby(String value) {
|
|
||||||
this.passengerruby = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFcgiphpbin() {
|
|
||||||
if (fcgiphpbin == null) {
|
|
||||||
return "/usr/lib/cgi-bin/php";
|
|
||||||
}
|
|
||||||
return fcgiphpbin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFcgiphpbin(String value) {
|
|
||||||
this.fcgiphpbin = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServeraliases() {
|
public String getServeraliases() {
|
||||||
|
@ -30,10 +30,6 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
|||||||
public static final String DOMOPT_LETSENCRYPT = "letsencrypt";
|
public static final String DOMOPT_LETSENCRYPT = "letsencrypt";
|
||||||
public static final String DOMOPT_AUTOCONFIG = "autoconfig";
|
public static final String DOMOPT_AUTOCONFIG = "autoconfig";
|
||||||
public static final String DOMOPT_DKIM = "dkim";
|
public static final String DOMOPT_DKIM = "dkim";
|
||||||
public static final String DOMOPT_PASSENGER = "passenger";
|
|
||||||
public static final String DOMOPT_PASSENGERFRIENDLYERRORPAGES = "passengerfriendlyerrorpages";
|
|
||||||
public static final String DOMOPT_CGI = "cgi";
|
|
||||||
public static final String DOMOPT_FASTCGI = "fastcgi";
|
|
||||||
|
|
||||||
public static final String[] ALL_DOMOPTS =
|
public static final String[] ALL_DOMOPTS =
|
||||||
new String[] {
|
new String[] {
|
||||||
@ -45,21 +41,18 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
|||||||
DOMOPT_BACKUPFOREXTERNALMX,
|
DOMOPT_BACKUPFOREXTERNALMX,
|
||||||
DOMOPT_LETSENCRYPT,
|
DOMOPT_LETSENCRYPT,
|
||||||
DOMOPT_AUTOCONFIG,
|
DOMOPT_AUTOCONFIG,
|
||||||
DOMOPT_DKIM,
|
DOMOPT_DKIM
|
||||||
DOMOPT_PASSENGER,
|
|
||||||
DOMOPT_PASSENGERFRIENDLYERRORPAGES,
|
|
||||||
DOMOPT_CGI,
|
|
||||||
DOMOPT_FASTCGI
|
|
||||||
};
|
};
|
||||||
public static final String[] DEFAULT_DOMOPTS =
|
public static final String[] DEFAULT_DOMOPTS =
|
||||||
new String[] {
|
new String[] {
|
||||||
DOMOPT_GREYLISTING,
|
DOMOPT_GREYLISTING,
|
||||||
|
DOMOPT_MULTIVIEWS,
|
||||||
DOMOPT_INDEXES,
|
DOMOPT_INDEXES,
|
||||||
DOMOPT_HTDOCSFALLBACK,
|
DOMOPT_HTDOCSFALLBACK,
|
||||||
|
DOMOPT_INCLUDES,
|
||||||
DOMOPT_LETSENCRYPT,
|
DOMOPT_LETSENCRYPT,
|
||||||
DOMOPT_AUTOCONFIG,
|
DOMOPT_AUTOCONFIG,
|
||||||
DOMOPT_DKIM,
|
DOMOPT_DKIM
|
||||||
DOMOPT_FASTCGI
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,10 +27,6 @@ public class DomainOptionValues extends DefaultSelectableValues {
|
|||||||
list.add(new BooleanListValue("letsencrypt"));
|
list.add(new BooleanListValue("letsencrypt"));
|
||||||
list.add(new BooleanListValue("autoconfig"));
|
list.add(new BooleanListValue("autoconfig"));
|
||||||
list.add(new BooleanListValue("dkim"));
|
list.add(new BooleanListValue("dkim"));
|
||||||
list.add(new BooleanListValue("passenger"));
|
|
||||||
list.add(new BooleanListValue("passengerfriendlyerrorpages"));
|
|
||||||
list.add(new BooleanListValue("cgi"));
|
|
||||||
list.add(new BooleanListValue("fastcgi"));
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
|
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
|
||||||
templateVars, "/etc/bind/named-hsh.conf.tmp", true),
|
templateVars, "/etc/bind/named-hsh.conf.tmp", true),
|
||||||
new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
|
new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
|
||||||
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )")
|
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm",
|
new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm",
|
||||||
templateVars, "/etc/postgrey/whitelist_recipients.tmp", true),
|
templateVars, "/etc/postgrey/whitelist_recipients.tmp", true),
|
||||||
new ShellProcessor(" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) " +
|
new ShellProcessor(" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) " +
|
||||||
"|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && systemctl restart postgrey.service )")
|
"|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,14 +237,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
|
new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
|
||||||
);
|
);
|
||||||
domDirsProcessor.appendProcessor(
|
domDirsProcessor.appendProcessor(
|
||||||
new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi/hs-phpstub", userName, pacName, "755")
|
new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755")
|
||||||
);
|
);
|
||||||
domDirsProcessor.appendProcessor(
|
domDirsProcessor.appendProcessor(
|
||||||
new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi-ssl/hs-phpstub", userName, pacName, "755")
|
new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755")
|
||||||
);
|
|
||||||
domDirsProcessor.appendProcessor(
|
|
||||||
new ShellProcessor("chattr +i " + domainDir + "/fastcgi/hs-phpstub && " +
|
|
||||||
"chattr +i " + domainDir + "/fastcgi-ssl/hs-phpstub")
|
|
||||||
);
|
);
|
||||||
domDirsProcessor.appendProcessor(
|
domDirsProcessor.appendProcessor(
|
||||||
new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " +
|
new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " +
|
||||||
@ -267,14 +263,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE);
|
ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE);
|
||||||
ifOption(templateVars, query, "letsencrypt", Boolean.TRUE, Boolean.FALSE);
|
ifOption(templateVars, query, "letsencrypt", Boolean.TRUE, Boolean.FALSE);
|
||||||
ifOption(templateVars, query, "autoconfig", Boolean.TRUE, Boolean.FALSE);
|
ifOption(templateVars, query, "autoconfig", Boolean.TRUE, Boolean.FALSE);
|
||||||
ifOption(templateVars, query, "passenger", Boolean.TRUE, Boolean.FALSE);
|
|
||||||
ifOption(templateVars, query, "passengerfriendlyerrorpages", Boolean.TRUE, Boolean.FALSE);
|
|
||||||
ifOption(templateVars, query, "cgi", Boolean.TRUE, Boolean.FALSE);
|
|
||||||
ifOption(templateVars, query, "fastcgi", Boolean.TRUE, Boolean.FALSE);
|
|
||||||
setPathInTemplate(templateVars, "passengerpython", "/usr/bin/python3", dom.getPassengerpython());
|
|
||||||
setPathInTemplate(templateVars, "passengernodejs", "/usr/bin/node", dom.getPassengernodejs());
|
|
||||||
setPathInTemplate(templateVars, "passengerruby", "/usr/bin/ruby", dom.getPassengerruby());
|
|
||||||
setPathInTemplate(templateVars, "fcgiphpbin", "/usr/lib/cgi-bin/php", dom.getFcgiphpbin());
|
|
||||||
final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE);
|
final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE);
|
||||||
final Processor domSetupProcessor = new CompoundProcessor(
|
final Processor domSetupProcessor = new CompoundProcessor(
|
||||||
isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"),
|
isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"),
|
||||||
@ -299,19 +287,11 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
" || (mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName +
|
" || (mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName +
|
||||||
" && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
" && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||||
" && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
" && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||||
" && systemctl reload apache2.service >/dev/null 2>&1)")
|
" && invoke-rc.d apache2 reload >/dev/null 2>&1)")
|
||||||
);
|
);
|
||||||
return domSetupProcessor;
|
return domSetupProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPathInTemplate(final Map<String, Object> templateVars, final String templateVariable, final String defaultPath, final String actualPath) {
|
|
||||||
String pathVariable = actualPath;
|
|
||||||
if (pathVariable == null || pathVariable.isEmpty()) {
|
|
||||||
pathVariable = defaultPath;
|
|
||||||
}
|
|
||||||
templateVars.put(templateVariable, pathVariable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ifOption(Map<String, Object> templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) {
|
private void ifOption(Map<String, Object> templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) {
|
||||||
query.setParameter("option", option);
|
query.setParameter("option", option);
|
||||||
if (query.getResultList().isEmpty()) {
|
if (query.getResultList().isEmpty()) {
|
||||||
@ -340,7 +320,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
" && mkdir " + homedir + "/doms.bak" +
|
" && mkdir " + homedir + "/doms.bak" +
|
||||||
" && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" +
|
" && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" +
|
||||||
" && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" +
|
" && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" +
|
||||||
" && systemctl reload apache2.service >/dev/null 2>&1");
|
// " && salt-call state.sls pacs " +
|
||||||
|
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
new ShellProcessor("rm -f /home/doms/" + domname +
|
new ShellProcessor("rm -f /home/doms/" + domname +
|
||||||
@ -352,10 +333,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
" && rm -f /etc/apache2/pems-generated/" + domname + ".crt" +
|
" && rm -f /etc/apache2/pems-generated/" + domname + ".crt" +
|
||||||
" && rm -f /etc/apache2/pems-generated/" + domname + ".key" +
|
" && rm -f /etc/apache2/pems-generated/" + domname + ".key" +
|
||||||
" && rm -f /etc/apache2/pems-generated/" + domname + ".chain" +
|
" && rm -f /etc/apache2/pems-generated/" + domname + ".chain" +
|
||||||
" && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/hs-phpstub" +
|
|
||||||
" && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/hs-phpstub" +
|
|
||||||
" && rm -rf " + homedir + "/doms/" + domname +
|
" && rm -rf " + homedir + "/doms/" + domname +
|
||||||
" && systemctl reload apache2.service >/dev/null 2>&1");
|
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createTriggerAcmebotProcessor(final EntityManager em, final Domain dom) {
|
private Processor createTriggerAcmebotProcessor(final EntityManager em, final Domain dom) {
|
||||||
|
@ -113,7 +113,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" +
|
return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" +
|
||||||
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
||||||
" && rm -f /etc/bind/pri." + domName +
|
" && rm -f /etc/bind/pri." + domName +
|
||||||
" && systemctl reload named.service");
|
" && invoke-rc.d bind9 reload");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createAccountingRulesProc() {
|
private Processor createAccountingRulesProc() {
|
||||||
@ -142,13 +142,13 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
|
|
||||||
private Processor createLinkSiteProc(final String pacDomain) {
|
private Processor createLinkSiteProc(final String pacDomain) {
|
||||||
return new ShellProcessor("ln -sf /etc/apache2/sites-available/" + pacDomain + " /etc/apache2/sites-enabled/97-" + pacDomain
|
return new ShellProcessor("ln -sf /etc/apache2/sites-available/" + pacDomain + " /etc/apache2/sites-enabled/97-" + pacDomain
|
||||||
+ " && systemctl reload apache2.service >/dev/null 2>&1");
|
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createUnlinkSiteProc(final String pacDomain) {
|
private Processor createUnlinkSiteProc(final String pacDomain) {
|
||||||
return new ShellProcessor("rm -f /etc/apache2/sites-enabled/97-" + pacDomain
|
return new ShellProcessor("rm -f /etc/apache2/sites-enabled/97-" + pacDomain
|
||||||
+ " && rm -f /etc/apache2/sites-available/" + pacDomain + ""
|
+ " && rm -f /etc/apache2/sites-available/" + pacDomain + ""
|
||||||
+ " && systemctl reload apache2.service >/dev/null 2>&1");
|
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createZonefileProc(final EntityManager em, final Pac pac) {
|
private Processor createZonefileProc(final EntityManager em, final Pac pac) {
|
||||||
@ -281,7 +281,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
|
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
|
||||||
templateVars, "/etc/bind/named-hsh.conf.tmp", true),
|
templateVars, "/etc/bind/named-hsh.conf.tmp", true),
|
||||||
new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
|
new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
|
||||||
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )")
|
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.hsadmin.core</groupId>
|
<groupId>de.hsadmin.core</groupId>
|
||||||
<artifactId>hsadmin-util</artifactId>
|
<artifactId>hsadmin-util</artifactId>
|
||||||
<version>4.0.15</version>
|
<version>4.0.18</version>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>8</java.version>
|
<java.version>11</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -24,8 +24,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.11.0</version>
|
<version>3.11.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>11</source>
|
||||||
<target>8</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -11,31 +11,42 @@ public class Config {
|
|||||||
|
|
||||||
private static Logger LOG = Logger.getLogger(Config.class.getName());
|
private static Logger LOG = Logger.getLogger(Config.class.getName());
|
||||||
|
|
||||||
private Properties props;
|
private static final String userDir = System.getProperty("user.dir");
|
||||||
|
private static final String userHome = System.getProperty("user.home");
|
||||||
|
|
||||||
|
private final Properties props;
|
||||||
|
|
||||||
private Config() {
|
private Config() {
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
|
initPropertiesFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPropertiesFromFile() {
|
||||||
|
final String baseName = "hsadmin";
|
||||||
|
File file = new File(userDir + "/" + baseName + ".properties");
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
|
file = new File(userDir + "/conf/" + baseName + ".properties");
|
||||||
}
|
}
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
|
file = new File(userHome + "/." + baseName + ".properties");
|
||||||
}
|
}
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
file = new File("/etc/hsadmin/hsadmin.properties");
|
file = new File("/etc/hsadmin/" + baseName + ".properties");
|
||||||
}
|
}
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
file = new File("/etc/hsadmin.properties");
|
file = new File("/etc/" + baseName + ".properties");
|
||||||
}
|
}
|
||||||
if (file.canRead()) {
|
if (file.canRead()) {
|
||||||
try {
|
try {
|
||||||
LOG.info("Constructor - Properties-File: " + file.getAbsolutePath());
|
LOG.info("Constructor - Properties-File: " + file.getAbsolutePath());
|
||||||
props.load(new FileReader(file));
|
props.load(new FileReader(file));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// should not happen
|
LOG.severe("reading properties failed: " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
final String errormsg = "reading properties failed: No properties file found";
|
||||||
|
LOG.severe(errormsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user