Compare commits
43 Commits
9661178687
...
e8c256da9c
Author | SHA1 | Date | |
---|---|---|---|
|
e8c256da9c | ||
|
79c653e910 | ||
|
69d9d87c9b | ||
|
96c3396934 | ||
|
e1db7a784f | ||
|
7a16ff9165 | ||
|
694b13bb55 | ||
|
22a99e98a3 | ||
|
b16ba63833 | ||
|
d95ebd4957 | ||
|
85271e0776 | ||
|
15ca8d9dd4 | ||
|
6e2db93a0f | ||
|
bf2a2a885e | ||
|
92be4acd7f | ||
|
767f47fe7f | ||
73f47dfb47 | |||
|
898aa24be6 | ||
|
c87ef04330 | ||
2268dcc595 | |||
|
023509d2dd | ||
39789415a9 | |||
|
83b7eba59e | ||
591abcc0fa | |||
|
471e666215 | ||
|
caffaaa2a4 | ||
|
006eef9ab5 | ||
|
0ca3cac465 | ||
|
e2d6e75375 | ||
|
02e55ee7a3 | ||
|
c4bbde5984 | ||
|
13316d265e | ||
|
9a6a6d094a | ||
|
643b23ad34 | ||
|
fea2612a48 | ||
|
0941515461 | ||
|
9032f0d81c | ||
|
e57a3d7c84 | ||
|
864c21be13 | ||
|
237c6d49fb | ||
|
513431584e | ||
|
2c4af11660 | ||
|
5004cab814 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
/qserv-test/
|
40
Makefile
Normal file
40
Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
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,6 +209,14 @@ INSERT INTO domain_option (domain_option_name)
|
||||
VALUES ('autoconfig');
|
||||
INSERT INTO domain_option (domain_option_name)
|
||||
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
|
||||
|
@ -1,85 +1,19 @@
|
||||
DROP VIEW ipconfig;
|
||||
|
||||
ALTER TABLE packet
|
||||
ALTER COLUMN packet_name TYPE VARCHAR(6);
|
||||
ALTER TABLE packet
|
||||
ALTER COLUMN hive_id DROP NOT NULL;
|
||||
ALTER TABLE domain
|
||||
ADD COLUMN passenger_python character varying(256) DEFAULT '/usr/bin/python3',
|
||||
ADD COLUMN passenger_nodejs character varying(256) DEFAULT '/usr/bin/node',
|
||||
ADD COLUMN passenger_ruby character varying(256) DEFAULT '/usr/bin/ruby',
|
||||
ADD COLUMN fcgi_php_bin character varying(256) DEFAULT '/usr/lib/cgi-bin/php';
|
||||
|
||||
UPDATE packet SET packet_name='vm10' || substr(packet_name,4,2) WHERE packet_name LIKE 'srv%';
|
||||
INSERT INTO domain_option (domain_option_name) VALUES
|
||||
('passenger'),
|
||||
('passengerfriendlyerrorpages'),
|
||||
('cgi'),
|
||||
('fastcgi');
|
||||
|
||||
CREATE VIEW ipconfig AS
|
||||
SELECT DISTINCT ON (theunion.ipv4) theunion.ipv4,
|
||||
theunion.name,
|
||||
theunion.alias,
|
||||
theunion.hivename
|
||||
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);
|
||||
INSERT INTO domain__domain_option ( domain_option_id, domain_id )
|
||||
SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='cgi' ), domain_id FROM domain;
|
||||
INSERT INTO domain__domain_option ( domain_option_id, domain_id )
|
||||
SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='fastcgi' ), domain_id FROM domain;
|
||||
INSERT INTO domain__domain_option ( domain_option_id, domain_id )
|
||||
SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='passenger' ), domain_id FROM domain;
|
||||
|
@ -319,7 +319,11 @@ CREATE TABLE domain (
|
||||
domain_dns_master character varying(64),
|
||||
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) 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,26 +5,43 @@
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsar</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
<name>HSAdmin Stable Backend Webapp</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</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>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-util</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-qserv</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
@ -53,18 +70,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-client</artifactId>
|
||||
<version>5.17.5</version>
|
||||
<version>2.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@ -78,6 +90,18 @@
|
||||
<version>4.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</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>
|
||||
<build>
|
||||
<finalName>hsar</finalName>
|
||||
@ -92,8 +116,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -51,6 +51,14 @@ public class DomainRemote extends AbstractRemote {
|
||||
}
|
||||
final String validsubdomains = dom.getValidsubdomainnames();
|
||||
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
|
||||
@ -92,6 +100,22 @@ public class DomainRemote extends AbstractRemote {
|
||||
if (validsubdomains != null && validsubdomains instanceof String) {
|
||||
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
|
||||
|
@ -23,9 +23,8 @@ public class RoleRemote implements IRemote {
|
||||
Transaction transaction = new Transaction(user);
|
||||
if (transaction.login(user, ticket)) {
|
||||
String role = "USER";
|
||||
Config config = Config.getInstance();
|
||||
String accoutPrefixCustomer = config.getProperty("accountprefix.customer");
|
||||
String accoutPrefixHostmaster = config.getProperty("accountprefix.hostmaster");
|
||||
String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer");
|
||||
String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster");
|
||||
Pac pac = transaction.getLoginUser().getPac();
|
||||
String pacName = pac.getName();
|
||||
if (accoutPrefixCustomer.equals(pacName)) {
|
||||
|
@ -121,6 +121,10 @@ public class JsonPillarServlet extends HttpServlet {
|
||||
domainadmins.add(domUserName);
|
||||
final Pac domPac = domUser.getPac();
|
||||
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();
|
||||
writer.println(" \"domain\": \"" + domName + "\"");
|
||||
writer.println(" , \"pac\": \"" + domPac.getName() + "\"");
|
||||
@ -148,6 +152,18 @@ public class JsonPillarServlet extends HttpServlet {
|
||||
}
|
||||
writer.println(" }");
|
||||
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(" ]");
|
||||
|
@ -0,0 +1,25 @@
|
||||
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,8 +2,6 @@ package de.hsadmin.servlets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.jms.ExceptionListener;
|
||||
import javax.jms.JMSException;
|
||||
@ -12,9 +10,13 @@ import javax.jms.MessageListener;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueConnectionFactory;
|
||||
import javax.jms.QueueReceiver;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
@ -22,14 +24,11 @@ import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
|
||||
import de.hsadmin.core.model.TechnicalException;
|
||||
import de.hsadmin.core.model.TicketValidator;
|
||||
import de.hsadmin.core.model.Transaction;
|
||||
import de.hsadmin.core.qserv.Processor;
|
||||
import de.hsadmin.core.qserv.QueueTask;
|
||||
import de.hsadmin.core.qserv.TaskTransfer;
|
||||
import de.hsadmin.core.util.Config;
|
||||
|
||||
public class QueueStatusReceiverServlet extends HttpServlet
|
||||
@ -37,10 +36,9 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
||||
|
||||
private static final long serialVersionUID = -5701350884034782083L;
|
||||
|
||||
private String jmsUrl;
|
||||
private String jmsUser;
|
||||
private String jmsPass;
|
||||
private String jmsStatusQueue;
|
||||
private QueueConnectionFactory queueConnectionFactory;
|
||||
private QueueConnection queueConnection;
|
||||
private QueueSession queueSession;
|
||||
private boolean isConnected;
|
||||
@ -56,24 +54,27 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
||||
isConnected = false;
|
||||
messageCount = 0;
|
||||
errorCount = 0;
|
||||
try {
|
||||
connect();
|
||||
} catch (NamingException e) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
private void connect() throws NamingException {
|
||||
Config config = Config.getInstance();
|
||||
jmsUrl = config.getProperty("hsadmin.jms.url", "tcp://localhost:61616");
|
||||
jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
|
||||
jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
|
||||
jmsStatusQueue = config.getProperty("hsadmin.jms.status-queue", "queue.Status");
|
||||
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl);
|
||||
mqConnectionFactory.setTrustAllPackages(true);
|
||||
InitialContext ctx = new InitialContext();
|
||||
Context env = (Context) ctx.lookup("java:comp/env");
|
||||
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
|
||||
int timeoutCounter = 10;
|
||||
while (!isConnected && (timeoutCounter > 0)) {
|
||||
try {
|
||||
queueConnection = mqConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
||||
queueConnection = queueConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
||||
queueConnection.setExceptionListener(this);
|
||||
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
Queue queue = queueSession.createQueue(jmsStatusQueue);
|
||||
Queue queue = (Queue) env.lookup("jms/hsadminStatus");
|
||||
queueConnection.start();
|
||||
QueueReceiver receiver = queueSession.createReceiver(queue);
|
||||
receiver.setMessageListener(this);
|
||||
@ -112,24 +113,16 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
||||
|
||||
@Override
|
||||
public void onMessage(Message jmsMessage) {
|
||||
assert jmsMessage != null;
|
||||
Transaction transaction = null;
|
||||
messageCount++;
|
||||
try {
|
||||
ObjectMessage objMessage = (ObjectMessage) jmsMessage;
|
||||
final Serializable object = objMessage.getObject();
|
||||
if (object != null) {
|
||||
TaskTransfer detachedQT = (TaskTransfer) object;
|
||||
QueueTask detachedQT = (QueueTask) objMessage.getObject();
|
||||
transaction = new Transaction("statusreceiver");
|
||||
transaction.beginTransaction();
|
||||
EntityManager em = transaction.getEntityManager();
|
||||
em.clear();
|
||||
final long queueTaskId = detachedQT.getId();
|
||||
QueueTask persistentQT = em.find(QueueTask.class, queueTaskId);
|
||||
if (persistentQT == null) {
|
||||
errorCount++;
|
||||
throw new TechnicalException("QueueTask not found, id: " + queueTaskId);
|
||||
}
|
||||
QueueTask persistentQT = em.find(QueueTask.class, detachedQT.getId());
|
||||
persistentQT.assign(detachedQT);
|
||||
Processor processor = persistentQT.getProcessor();
|
||||
if (processor != null) {
|
||||
@ -138,12 +131,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
||||
em.persist(persistentQT);
|
||||
em.flush();
|
||||
transaction.commitTransaction();
|
||||
} else {
|
||||
errorCount++;
|
||||
final String err = "Deserialization failed " + new Date();
|
||||
System.out.println(err);
|
||||
throw new TechnicalException(err);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorCount++;
|
||||
if (transaction != null) transaction.rollbackTransaction();
|
||||
@ -157,7 +144,7 @@ public class QueueStatusReceiverServlet extends HttpServlet
|
||||
public void onException(JMSException exception) {
|
||||
close();
|
||||
try { Thread.sleep(10000); } catch (InterruptedException e) { }
|
||||
connect();
|
||||
try { connect(); } catch (NamingException e) { }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,12 @@
|
||||
|
||||
DocumentRoot /home/doms/${dom.name}/htdocs
|
||||
|
||||
#if( ${cgi} )
|
||||
Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
|
||||
#end
|
||||
#if( ${fastcgi} )
|
||||
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
|
||||
#end
|
||||
|
||||
<Directory />
|
||||
PassengerEnabled Off
|
||||
@ -26,21 +30,42 @@
|
||||
</Directory>
|
||||
|
||||
<Directory /home/doms/${dom.name}/>
|
||||
#if( ${passenger} )
|
||||
PassengerEnabled On
|
||||
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
|
||||
# PassengerPreloadBundler On
|
||||
#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>
|
||||
|
||||
#if( ${cgi} )
|
||||
<Location /cgi-bin/>
|
||||
PassengerEnabled Off
|
||||
SetHandler cgi-script
|
||||
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
</Location>
|
||||
#end
|
||||
|
||||
#if( ${fastcgi} )
|
||||
<Location /fastcgi-bin/>
|
||||
PassengerEnabled Off
|
||||
SetHandler fcgid-script
|
||||
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
</Location>
|
||||
#end
|
||||
|
||||
#if( ${autoconfig} )
|
||||
<Location /autodiscover/autodiscover.xml>
|
||||
@ -57,8 +82,12 @@
|
||||
RewriteEngine On
|
||||
RewriteOptions Inherit
|
||||
|
||||
#if( ${cgi} )
|
||||
RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
||||
#end
|
||||
#if( ${fastcgi} )
|
||||
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
||||
#end
|
||||
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
|
||||
RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d
|
||||
RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last]
|
||||
@ -71,8 +100,13 @@
|
||||
RewriteRule ^(.*) - [redirect=404,last]
|
||||
|
||||
#end
|
||||
AddType application/x-httpd-php .php .php5 .php4 .php3
|
||||
Action application/x-httpd-php /fastcgi-bin/phpstub
|
||||
#if( ${fastcgi} )
|
||||
#if( ${fcgiphpbin} )
|
||||
FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin}
|
||||
#end
|
||||
AddType application/x-httpd-php .php
|
||||
Action application/x-httpd-php /fastcgi-bin/hs-phpstub
|
||||
#end
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost ${pac.curINetAddr.inet4Addr}:443 ${pac.oldINetAddr.inet4Addr}:443 [${pac.curINetAddr.inet6Addr}]:443 [${pac.oldINetAddr.inet6Addr}]:443>
|
||||
@ -94,8 +128,12 @@
|
||||
|
||||
DocumentRoot /home/doms/${dom.name}/htdocs-ssl
|
||||
|
||||
#if( ${cgi} )
|
||||
Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
|
||||
#end
|
||||
#if( ${fastcgi} )
|
||||
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
|
||||
#end
|
||||
|
||||
<Directory />
|
||||
SSLRequireSSL On
|
||||
@ -104,21 +142,42 @@
|
||||
</Directory>
|
||||
|
||||
<Directory /home/doms/${dom.name}/>
|
||||
#if( ${passenger} )
|
||||
PassengerEnabled On
|
||||
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
|
||||
# PassengerPreloadBundler On
|
||||
#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>
|
||||
|
||||
#if( ${cgi} )
|
||||
<Location /cgi-bin/>
|
||||
PassengerEnabled Off
|
||||
SetHandler cgi-script
|
||||
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
</Location>
|
||||
#end
|
||||
|
||||
#if( ${fastcgi} )
|
||||
<Location /fastcgi-bin/>
|
||||
PassengerEnabled Off
|
||||
SetHandler fcgid-script
|
||||
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||
</Location>
|
||||
#end
|
||||
|
||||
#if( ${autoconfig} )
|
||||
<Location /autodiscover/autodiscover.xml>
|
||||
@ -135,8 +194,12 @@
|
||||
RewriteEngine On
|
||||
RewriteOptions Inherit
|
||||
|
||||
#if( ${cgi} )
|
||||
RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
||||
#end
|
||||
#if( ${fastcgi} )
|
||||
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
||||
#end
|
||||
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
|
||||
RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d
|
||||
RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last]
|
||||
@ -149,7 +212,11 @@
|
||||
RewriteRule ^(.*) - [redirect=404,last]
|
||||
|
||||
#end
|
||||
AddType application/x-httpd-php .php .php5 .php4 .php3
|
||||
Action application/x-httpd-php /fastcgi-bin/phpstub
|
||||
|
||||
#if( ${fastcgi} )
|
||||
#if( ${fcgiphpbin} )
|
||||
FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin}
|
||||
#end
|
||||
AddType application/x-httpd-php .php
|
||||
Action application/x-httpd-php /fastcgi-bin/hs-phpstub
|
||||
#end
|
||||
</VirtualHost>
|
||||
|
@ -5,4 +5,29 @@
|
||||
global="jdbc/HSAdminDB"
|
||||
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>
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?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,6 +4,10 @@
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<listener>
|
||||
<listener-class>de.hsadmin.servlets.PersistenceManagerContextListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Queue Status Servlet</servlet-name>
|
||||
<servlet-class>de.hsadmin.servlets.QueueStatusReceiverServlet</servlet-class>
|
||||
@ -53,5 +57,36 @@
|
||||
<res-auth>Container</res-auth>
|
||||
</resource-ref>
|
||||
|
||||
</web-app>
|
||||
<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>
|
@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||
@ -61,7 +62,7 @@ public class DomainTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
public void testUpdateWithoutPermissionFail() {
|
||||
String user = "aaa00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
@ -99,6 +100,129 @@ public class DomainTest {
|
||||
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
|
||||
public void testCreateForeignSubdomain() throws UnknownHostException, IOException {
|
||||
int count = getDomsCount();
|
||||
|
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.hsadmin</groupId>
|
||||
<artifactId>hsadmin-qserv</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HSAdmin-QServ</name>
|
||||
@ -17,15 +17,10 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-util</artifactId>
|
||||
<version>4.0.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-qserv</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
@ -84,15 +79,6 @@
|
||||
<prefix>/usr/local/lib/hostsharing/hsadmin</prefix>
|
||||
</mapper>
|
||||
</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>
|
||||
<src>src/deb/systemd/hsadmin-qserv.service</src>
|
||||
<type>file</type>
|
||||
|
@ -1,50 +0,0 @@
|
||||
#!/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,11 +4,9 @@ After=network.target nss-lookup.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/usr/local/lib/hostsharing/hsadmin/qserv
|
||||
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=*"
|
||||
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
|
||||
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar /etc/hsadmin/qserv/qserv.properties
|
||||
StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
|
2
qserv/.gitignore
vendored
2
qserv/.gitignore
vendored
@ -4,4 +4,4 @@
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
hsadmin.properties
|
||||
|
||||
|
14
qserv/hsadmin.properties
Normal file
14
qserv/hsadmin.properties
Normal file
@ -0,0 +1,14 @@
|
||||
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>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-qserv</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>11</java.version>
|
||||
<java.version>8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-util</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
@ -27,13 +27,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<version>2.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@ -43,8 +43,15 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-client</artifactId>
|
||||
<version>5.17.5</version>
|
||||
<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>
|
||||
<build>
|
||||
@ -54,14 +61,14 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.openjpa</groupId>
|
||||
<artifactId>openjpa-maven-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<version>2.4.3</version>
|
||||
<configuration>
|
||||
<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
|
||||
@ -82,5 +89,40 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</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>
|
||||
</project>
|
||||
|
@ -14,7 +14,6 @@ import de.hsadmin.core.qserv.EntityProcessorFactory;
|
||||
import de.hsadmin.core.qserv.NullProcessor;
|
||||
import de.hsadmin.core.qserv.Processor;
|
||||
import de.hsadmin.core.qserv.QueueTask;
|
||||
import de.hsadmin.core.qserv.TaskTransfer;
|
||||
import de.hsadmin.core.util.HSAdminException;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
@ -200,10 +199,8 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
StringBuilder details = new StringBuilder();
|
||||
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;
|
||||
QueueTask task = new QueueTask(user, title, details.toString(), proc);
|
||||
final EntityManager entityManager = transaction.getEntityManager();
|
||||
entityManager.persist(task);
|
||||
entityManager.refresh(task);
|
||||
transaction.enqueue(entity.getHiveName(), TaskTransfer.getTransferObject(task));
|
||||
transaction.getEntityManager().persist(task);
|
||||
transaction.enqueue(entity.getHiveName(), task);
|
||||
}
|
||||
|
||||
public String toString(StackTraceElement[] stackTrace) {
|
||||
|
@ -2,8 +2,6 @@ package de.hsadmin.core.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
@ -15,8 +13,6 @@ public class PersistenceManager {
|
||||
|
||||
private Map<String, EntityManagerFactory> persistenceUnits;
|
||||
|
||||
private Logger logger = Logger.getLogger(PersistenceManager.class.getName());
|
||||
|
||||
public static EntityManager getEntityManager(String persistUnitName) {
|
||||
EntityManagerFactory emf = PersistenceManager.getInstance().getEMF(persistUnitName);
|
||||
return emf.createEntityManager();
|
||||
@ -35,7 +31,6 @@ public class PersistenceManager {
|
||||
if (emf == null) {
|
||||
emf = Persistence.createEntityManagerFactory(persistUnitName);
|
||||
persistenceUnits.put(persistUnitName, emf);
|
||||
logger.log(Level.INFO, "Create Persistence Unit: " + persistUnitName);
|
||||
}
|
||||
return emf;
|
||||
}
|
||||
@ -48,11 +43,11 @@ public class PersistenceManager {
|
||||
}
|
||||
|
||||
private void closeFactories() {
|
||||
for (String persistUnitName : persistenceUnits.keySet()) {
|
||||
logger.log(Level.INFO, "Close Persistence Unit: " + persistUnitName);
|
||||
EntityManagerFactory emf = persistenceUnits.get(persistUnitName);
|
||||
for (String puName : persistenceUnits.keySet()) {
|
||||
System.out.println("Persistence Unit: " + puName);
|
||||
EntityManagerFactory emf = persistenceUnits.get(puName);
|
||||
emf.close();
|
||||
persistenceUnits.remove(persistUnitName);
|
||||
persistenceUnits.remove(puName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,20 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueConnectionFactory;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityTransaction;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
//import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
|
||||
import de.hsadmin.core.qserv.QueueClient;
|
||||
import de.hsadmin.core.qserv.TaskTransfer;
|
||||
import de.hsadmin.core.qserv.QueueTask;
|
||||
import de.hsadmin.core.util.Config;
|
||||
import de.hsadmin.mods.cust.Customer;
|
||||
import de.hsadmin.mods.pac.Pac;
|
||||
@ -32,23 +32,24 @@ public class Transaction {
|
||||
private String loginName;
|
||||
private Map<String, QueueTaskStore> taskStores;
|
||||
private boolean transactionActive;
|
||||
private Config config;
|
||||
private String jmsServerUrl;
|
||||
private String jmsUsername;
|
||||
private String jmsPassword;
|
||||
private InitialContext ctx;
|
||||
|
||||
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.entityManager = PersistenceManager.getEntityManager("hsadmin");
|
||||
this.loginName = loginName;
|
||||
this.taskStores = new HashMap<String, QueueTaskStore>();
|
||||
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsServerUrl);
|
||||
mqConnectionFactory.setTrustAllPackages(true);
|
||||
this.queueConnectionFactory = mqConnectionFactory;
|
||||
try {
|
||||
ctx = new InitialContext();
|
||||
Context env = (Context) ctx.lookup("java:comp/env");
|
||||
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() {
|
||||
@ -60,15 +61,16 @@ public class Transaction {
|
||||
}
|
||||
|
||||
public Queue lookupJMSQueue(String queueName) {
|
||||
if (ctx != null) {
|
||||
try {
|
||||
final QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
|
||||
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
||||
final Queue queue = session.createQueue(queueName);
|
||||
return queue;
|
||||
} catch (JMSException e) {
|
||||
Context env = (Context) ctx.lookup("java:comp/env");
|
||||
return (Queue) env.lookup("jms/" + queueName);
|
||||
} catch (NamingException e) {
|
||||
throw new TechnicalException("no jms queue: jms/" + queueName, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLoginName() {
|
||||
if (loginName != null) {
|
||||
@ -77,7 +79,7 @@ public class Transaction {
|
||||
throw new TechnicalException("no login");
|
||||
}
|
||||
|
||||
public void enqueue(String hiveName, TaskTransfer task) {
|
||||
public void enqueue(String hiveName, QueueTask task) {
|
||||
QueueTaskStore taskStore = taskStores.get(hiveName);
|
||||
if (taskStore == null) {
|
||||
taskStore = new QueueTaskStore();
|
||||
@ -89,13 +91,13 @@ public class Transaction {
|
||||
private void sendAll() {
|
||||
for (String hive : taskStores.keySet()) {
|
||||
QueueTaskStore store = taskStores.get(hive);
|
||||
String queueName = "queue.hsadminSystem-" + hive;
|
||||
String queueName = "hsadminSystem-" + hive;
|
||||
Queue jmsSystemQueue = lookupJMSQueue(queueName);
|
||||
QueueClient qClient = null;
|
||||
try {
|
||||
qClient = new QueueClient(queueConnectionFactory, jmsSystemQueue);
|
||||
for (TaskTransfer taskTransfer : store.getTasks()) {
|
||||
qClient.send(taskTransfer);
|
||||
for (QueueTask task : store.getTasks()) {
|
||||
qClient.send(task);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new TechnicalException(e);
|
||||
@ -145,13 +147,11 @@ public class Transaction {
|
||||
if (transactionActive) {
|
||||
rollbackTransaction();
|
||||
}
|
||||
if (entityManager != null) {
|
||||
entityManager.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach entities from JPA session.
|
||||
* Detach entities from hibernate session.
|
||||
* Used to detach entities before update. Makes it possible to compare
|
||||
* old and new attribute values.
|
||||
*/
|
||||
@ -163,17 +163,17 @@ public class Transaction {
|
||||
}
|
||||
|
||||
class QueueTaskStore {
|
||||
private List<TaskTransfer> taskList;
|
||||
private List<QueueTask> taskList;
|
||||
QueueTaskStore() {
|
||||
taskList = new ArrayList<TaskTransfer>();
|
||||
taskList = new ArrayList<QueueTask>();
|
||||
}
|
||||
public void clear() {
|
||||
taskList = new ArrayList<TaskTransfer>();
|
||||
taskList = new ArrayList<QueueTask>();
|
||||
}
|
||||
void add(TaskTransfer t) {
|
||||
void add(QueueTask t) {
|
||||
taskList.add(t);
|
||||
}
|
||||
Iterable<TaskTransfer> getTasks() {
|
||||
Iterable<QueueTask> getTasks() {
|
||||
return taskList;
|
||||
}
|
||||
}
|
||||
@ -181,10 +181,10 @@ public class Transaction {
|
||||
public UnixUser getLoginUser() {
|
||||
String loginName = getLoginName();
|
||||
if (loginName != null && loginName.length() == 2) {
|
||||
loginName = config.getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
|
||||
loginName = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
|
||||
}
|
||||
if (loginName != null && loginName.length() == 3) {
|
||||
loginName = config.getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
|
||||
loginName = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
|
||||
}
|
||||
Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
|
||||
userQuery.setParameter("username", loginName);
|
||||
@ -200,7 +200,7 @@ public class Transaction {
|
||||
if (ticketUser != null && ticketUser.length() == 2) {
|
||||
return true; // 2-letter hostmaster
|
||||
}
|
||||
String hostmasterAccountPrefix = config.getProperty("accountprefix.hostmaster", "hsh01") + "-";
|
||||
String hostmasterAccountPrefix = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-";
|
||||
if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) {
|
||||
return true; // hsh01 hostmaster
|
||||
}
|
||||
@ -211,7 +211,7 @@ public class Transaction {
|
||||
String pacName = unixUser.getPac().getName();
|
||||
return ticketUser.equals(pacName); // pac-admin
|
||||
}
|
||||
String memberAccountPrefix = config.getProperty("accountprefix.customer", "hsh00") + "-";
|
||||
String memberAccountPrefix = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-";
|
||||
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");
|
||||
memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser);
|
||||
|
@ -14,9 +14,4 @@ abstract public class AbstractProcessor implements Processor {
|
||||
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 + "'");
|
||||
Statement s = c.createStatement();
|
||||
for (String sqlStatement : sql) {
|
||||
LOG.fine("SQL: " + sqlStatement);
|
||||
System.out.println("SQL: " + sqlStatement);
|
||||
s.execute(sqlStatement);
|
||||
}
|
||||
return 0;
|
||||
@ -67,7 +67,7 @@ public class JDBCProcessor extends AbstractProcessor {
|
||||
exc = aSqlExc;
|
||||
}
|
||||
errorMsg = exc.getMessage();
|
||||
LOG.severe("ERR: " + errorMsg);
|
||||
System.out.println("ERR: " + errorMsg);
|
||||
throw new ProcessorException(aSqlExc.getMessage() + ", reason: " + errorMsg);
|
||||
} catch (Exception aExc) {
|
||||
throw new ProcessorException(aExc.getMessage());
|
||||
|
@ -3,7 +3,7 @@ package de.hsadmin.core.qserv;
|
||||
|
||||
public class NullProcessor extends AbstractProcessor {
|
||||
|
||||
private static final long serialVersionUID = -3667951484545665538L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Object process() throws ProcessorException {
|
||||
|
@ -18,7 +18,7 @@ import de.hsadmin.core.util.Config;
|
||||
*
|
||||
* @author mi
|
||||
*/
|
||||
public class QueueClient {
|
||||
public class QueueClient extends QueueCommons {
|
||||
|
||||
private QueueConnectionFactory jmsConnectionFactory;
|
||||
private Queue jmsSystemQueue;
|
||||
@ -36,11 +36,11 @@ public class QueueClient {
|
||||
String jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
|
||||
String jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
|
||||
jmsConnection = jmsConnectionFactory.createQueueConnection(jmsUser, jmsPass);
|
||||
jmsSession = jmsConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
jmsSession = jmsConnection.createQueueSession(DEFAULT, Session.AUTO_ACKNOWLEDGE);
|
||||
jmsSender = jmsSession.createSender(jmsSystemQueue);
|
||||
}
|
||||
|
||||
public void send(TaskTransfer task) throws ProcessorException {
|
||||
public void send(QueueTask task) throws ProcessorException {
|
||||
try {
|
||||
ObjectMessage jmsMessage = jmsSession.createObjectMessage(task);
|
||||
jmsSender.send(jmsMessage);
|
||||
@ -55,7 +55,7 @@ public class QueueClient {
|
||||
}
|
||||
}
|
||||
|
||||
private String queueName(Queue jmsSystemQueue) {
|
||||
private String queueName(Queue jmsSystemQueue2) {
|
||||
try {
|
||||
return jmsSystemQueue.getQueueName();
|
||||
} catch (Exception exc) {
|
||||
|
14
qserv/src/main/java/de/hsadmin/core/qserv/QueueCommons.java
Normal file
14
qserv/src/main/java/de/hsadmin/core/qserv/QueueCommons.java
Normal file
@ -0,0 +1,14 @@
|
||||
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,8 +1,14 @@
|
||||
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.Logger;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.ExceptionListener;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
@ -11,82 +17,90 @@ import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueConnectionFactory;
|
||||
import javax.jms.QueueReceiver;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener {
|
||||
|
||||
import de.hsadmin.core.util.Config;
|
||||
|
||||
public class QueueServer implements MessageListener, ExceptionListener {
|
||||
|
||||
private static final String VERSION_NO = "4.0.16";
|
||||
private static final String VERSION_NO = "4.0.11";
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private String jmsUrl;
|
||||
private String jmsUsername;
|
||||
private String jmsPassword;
|
||||
private String jmsSystemQueue;
|
||||
private QueueConnection conn;
|
||||
private QueueSession queueSession;
|
||||
private String jmsStatusQueue;
|
||||
private String jmsPassWord;
|
||||
private String jmsUserName;
|
||||
private String jmsSystemQueue;
|
||||
private String jmsFactory;
|
||||
private String serviceEMail;
|
||||
private String fromEMail;
|
||||
|
||||
private QueueConnection queueConnection;
|
||||
private boolean isConnected;
|
||||
|
||||
|
||||
/**
|
||||
* Runs the QueueServer.
|
||||
* Runs the QueueServer, using the arguments as ConnectionFactory
|
||||
* and Topic names.
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
final Config config = Config.getInstance();
|
||||
System.setProperty("java.util.logging.config.file", config.getProperty("hsadmin.log.config", System.getProperty("user.home") + "/.hsadmin.log.properties"));
|
||||
File propFile = new File(System.getProperty("user.dir"), "conf/qserv.properties");
|
||||
if (args.length == 1) {
|
||||
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();
|
||||
qServ.setJmsURL(config.getProperty("hsadmin.jms.url"));
|
||||
qServ.setJmsSystemQueue(config.getProperty("hsadmin.jms.system-queue"));
|
||||
qServ.setJmsStatusQueue(config.getProperty("hsadmin.jms.status-queue"));
|
||||
qServ.setJmsUserName(config.getProperty("hsadmin.jms.username"));
|
||||
qServ.setJmsPassWord(config.getProperty("hsadmin.jms.password"));
|
||||
qServ.setServiceEMail(config.getProperty("hsadmin.log.email"));
|
||||
qServ.setFromEMail(config.getProperty("hsadmin.log.from"));
|
||||
qServ.setJmsFactory(props.getProperty("hsadmin.jms.factory"));
|
||||
qServ.setJmsSystemQueue(props.getProperty("hsadmin.jms.system-queue"));
|
||||
qServ.setJmsStatusQueue(props.getProperty("hsadmin.jms.status-queue"));
|
||||
qServ.setJmsUserName(props.getProperty("hsadmin.jms.username"));
|
||||
qServ.setJmsPassWord(props.getProperty("hsadmin.jms.password"));
|
||||
qServ.setServiceEMail(props.getProperty("hsadmin.log.email"));
|
||||
qServ.setFromEMail(props.getProperty("hsadmin.log.from"));
|
||||
Logger logger = Logger.getLogger("de.hsadmin.core.qserv");
|
||||
logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:"
|
||||
+ "\nsystem queue: " + config.getProperty("hsadmin.jms.system-queue")
|
||||
+ "\nstatus queue: " + config.getProperty("hsadmin.jms.status-queue")
|
||||
+ "\nqueue user: " + config.getProperty("hsadmin.jms.username"));
|
||||
+ "\nqueue server: " + props.getProperty("hsadmin.jms.factory")
|
||||
+ "\nsystem queue: " + props.getProperty("hsadmin.jms.system-queue")
|
||||
+ "\nstatus queue: " + props.getProperty("hsadmin.jms.status-queue")
|
||||
+ "\nqueue user: " + props.getProperty("hsadmin.jms.username"));
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
qServ.close();
|
||||
}
|
||||
});
|
||||
while (true) {
|
||||
if (!qServ.isConnected()) {
|
||||
qServ.connect();
|
||||
while (!qServ.connect()) {
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
Thread.sleep(30000);
|
||||
while (true) {
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
protected void close() {
|
||||
if (queueConnection != null) {
|
||||
try {
|
||||
queueConnection.close();
|
||||
} catch (JMSException e) {
|
||||
logger.log(Level.SEVERE, e.getMessage());
|
||||
}
|
||||
}
|
||||
private static String userHelp(File propFile) {
|
||||
return "Wrong number of arguments.\n"
|
||||
+ "With no arguments '"
|
||||
+ propFile
|
||||
+ "' will be used as config file.\n"
|
||||
+ "Or give a properties file as single argument.\n\n"
|
||||
+ "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() {
|
||||
logger = Logger.getLogger("de.hsadmin.core.qserv");
|
||||
queueConnection = null;
|
||||
isConnected = false;
|
||||
}
|
||||
|
||||
private boolean isConnected() {
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
private void setServiceEMail(String emailAddress) {
|
||||
@ -105,31 +119,32 @@ public class QueueServer implements MessageListener, ExceptionListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
private boolean connect() {
|
||||
// create JMS connection and session
|
||||
try {
|
||||
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl);
|
||||
mqConnectionFactory.setTrustAllPackages(true);
|
||||
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
|
||||
queueConnection.setExceptionListener(this);
|
||||
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
||||
Queue queue = session.createQueue(jmsSystemQueue);
|
||||
queueConnection.start();
|
||||
final QueueReceiver receiver = session.createReceiver(queue);
|
||||
Context ctx = new InitialContext();
|
||||
QueueConnectionFactory connectionFactory =
|
||||
(QueueConnectionFactory) ctx.lookup(jmsFactory);
|
||||
conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord);
|
||||
conn.setExceptionListener(this);
|
||||
queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
Queue queue = (Queue) ctx.lookup(jmsSystemQueue);
|
||||
conn.start();
|
||||
QueueReceiver receiver = queueSession.createReceiver(queue);
|
||||
receiver.setMessageListener(this);
|
||||
isConnected = true;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
isConnected = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onMessage(final Message jmsMessage) {
|
||||
assert jmsMessage != null;
|
||||
public synchronized void onMessage(Message jmsMessage) {
|
||||
logger.log(Level.INFO, jmsMessage.toString());
|
||||
TaskTransfer task = null;
|
||||
QueueTask task = null;
|
||||
try {
|
||||
ObjectMessage jmsObjectMessage = (ObjectMessage) jmsMessage;
|
||||
task = (TaskTransfer) jmsObjectMessage.getObject();
|
||||
task = (QueueTask) jmsObjectMessage.getObject();
|
||||
Processor processor = task.getProcessor();
|
||||
logger.log(Level.INFO, "processing (" + task.getTitle() + " | started("
|
||||
+ task.getStarted() + ") |" + task.getDetails() + "|"
|
||||
@ -139,12 +154,12 @@ public class QueueServer implements MessageListener, ExceptionListener {
|
||||
logger.log(Level.INFO, "done");
|
||||
} catch (ProcessorException e) {
|
||||
logException(e);
|
||||
task.setException(e.getMessage());
|
||||
task.setException(e);
|
||||
SmtpHelper.send(fromEMail, serviceEMail, jmsSystemQueue, processor.logInfo());
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
logException(throwable);
|
||||
task.setException(throwable.getMessage());
|
||||
task.setException(throwable);
|
||||
} finally {
|
||||
sendStatus(task);
|
||||
notifyAll();
|
||||
@ -163,53 +178,70 @@ public class QueueServer implements MessageListener, ExceptionListener {
|
||||
public void onException(JMSException e) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
close();
|
||||
isConnected = false;
|
||||
while (!connect()) {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e1) { }
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendStatus(TaskTransfer queueMessage) {
|
||||
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl);
|
||||
mqConnectionFactory.setTrustAllPackages(true);
|
||||
QueueConnection queueConnection = null;
|
||||
MessageProducer producer = null;
|
||||
QueueSession session = null;
|
||||
public void close() {
|
||||
if (queueSession != null) {
|
||||
try {
|
||||
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
|
||||
queueConnection.setExceptionListener(this);
|
||||
session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
||||
final Queue queue = session.createQueue(jmsStatusQueue);
|
||||
queueConnection.start();
|
||||
producer = session.createProducer(queue);
|
||||
final ObjectMessage statusMessage = session.createObjectMessage(queueMessage);
|
||||
producer.send(statusMessage);
|
||||
queueSession.close();
|
||||
} catch (JMSException e1) { }
|
||||
}
|
||||
if (conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (JMSException e1) { }
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendStatus(QueueTask queueMessage) {
|
||||
MessageProducer producer = null;
|
||||
Session statusSession = null;
|
||||
Connection statusConnection = null;
|
||||
try {
|
||||
logger.log(Level.INFO, "sendStatus(" + queueMessage + ")");
|
||||
Context ctx = new InitialContext();
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(jmsFactory);
|
||||
Destination queue = (Destination) ctx.lookup(jmsStatusQueue);
|
||||
statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord);
|
||||
statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
producer = statusSession.createProducer(queue);
|
||||
ObjectMessage statusMessage = statusSession.createObjectMessage(queueMessage);
|
||||
logger.log(Level.INFO, "send(" + statusMessage + ")");
|
||||
producer.send(statusMessage);
|
||||
} catch (Exception statusException) {
|
||||
logger.log(Level.SEVERE, statusException.getMessage(), statusException);
|
||||
} finally {
|
||||
if (producer != null) try { producer.close(); } catch (Exception e) { }
|
||||
if (session != null) try { session.close(); } catch (Exception e) { }
|
||||
if (queueConnection != null) try { queueConnection.close(); } catch (Exception e) { }
|
||||
// close JMS
|
||||
try { producer.close(); } catch (Exception exc) { }
|
||||
try { statusSession.close(); } catch (Exception exc) { }
|
||||
try { statusConnection.close(); } catch (Exception exc) { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setJmsURL(String property) {
|
||||
jmsUrl = property;
|
||||
}
|
||||
|
||||
public void setJmsPassWord(String property) {
|
||||
jmsPassword = property;
|
||||
}
|
||||
|
||||
public void setJmsUserName(String property) {
|
||||
jmsUsername = property;
|
||||
}
|
||||
|
||||
public void setJmsSystemQueue(String property) {
|
||||
jmsSystemQueue = property;
|
||||
}
|
||||
|
||||
public void setJmsStatusQueue(String property) {
|
||||
jmsStatusQueue = property;
|
||||
}
|
||||
|
||||
public void setJmsPassWord(String property) {
|
||||
jmsPassWord = property;
|
||||
}
|
||||
|
||||
public void setJmsUserName(String property) {
|
||||
jmsUserName = property;
|
||||
}
|
||||
|
||||
public void setJmsSystemQueue(String property) {
|
||||
jmsSystemQueue = property;
|
||||
}
|
||||
|
||||
public void setJmsFactory(String property) {
|
||||
jmsFactory = property;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -223,13 +223,14 @@ public class QueueTask extends AbstractEntity implements Serializable {
|
||||
* assigns all data field of qt to this instance, with
|
||||
* the exception of the id
|
||||
*/
|
||||
public void assign(TaskTransfer qt) {
|
||||
this.title = qt.getTitle();
|
||||
this.details = qt.getDetails();
|
||||
this.started = qt.getStarted();
|
||||
this.finished = qt.getFinished();
|
||||
this.proc = qt.getProcessor();
|
||||
this.exception = qt.getException();
|
||||
public void assign(QueueTask qt) {
|
||||
this.user = qt.user;
|
||||
this.title = qt.title;
|
||||
this.details = qt.details;
|
||||
this.started = qt.started;
|
||||
this.finished = qt.finished;
|
||||
this.proc = qt.proc;
|
||||
this.exception = qt.exception;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,7 @@ package de.hsadmin.core.qserv;
|
||||
*/
|
||||
public class ShellProcessor extends AbstractProcessor {
|
||||
|
||||
private static final long serialVersionUID = -8340381162948081669L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String aSystemCall;
|
||||
private String aInput;
|
||||
|
@ -6,7 +6,6 @@ import java.io.Writer;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.net.smtp.SMTPClient;
|
||||
import org.apache.commons.net.smtp.SMTPReply;
|
||||
@ -17,8 +16,6 @@ import de.hsadmin.core.util.HSAdminException;
|
||||
|
||||
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)
|
||||
throws HSAdminException {
|
||||
send(fromAddress, toAddress, null, subject, text);
|
||||
@ -27,10 +24,9 @@ public class SmtpHelper {
|
||||
public static void send(String fromAddress, String toAddress, String ccAddress, String subject, String text)
|
||||
throws HSAdminException {
|
||||
try {
|
||||
final SMTPClient client = new SMTPClient();
|
||||
SMTPClient client = new SMTPClient();
|
||||
String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName();
|
||||
final Config config = Config.getInstance();
|
||||
String smtpHost = config.getProperty("smtp.host");
|
||||
String smtpHost = Config.getInstance().getProperty("smtp.host");
|
||||
if (smtpHost == null || smtpHost.trim().isEmpty()) {
|
||||
smtpHost = "localhost";
|
||||
}
|
||||
@ -38,10 +34,11 @@ public class SmtpHelper {
|
||||
if (subject.toLowerCase().contains("error")) {
|
||||
throw new HSAdminException("Konnte Mail nicht senden");
|
||||
}
|
||||
LOG.finer("From: " + fromAddress);
|
||||
LOG.finer("To: " + toAddress);
|
||||
LOG.finer("Subject: " + subject);
|
||||
LOG.finer(text);
|
||||
System.out.println("------------------------");
|
||||
System.out.println("From: " + fromAddress);
|
||||
System.out.println("To: " + toAddress);
|
||||
System.out.println("Subject: " + subject);
|
||||
System.out.println("\n" + text);
|
||||
return;
|
||||
}
|
||||
client.connect(smtpHost, 25);
|
||||
|
@ -1,130 +0,0 @@
|
||||
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,8 +4,6 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import de.hsadmin.core.model.Transaction;
|
||||
|
||||
public class WaitingTasksProcessor extends AbstractProcessor {
|
||||
@ -31,10 +29,8 @@ public class WaitingTasksProcessor extends AbstractProcessor {
|
||||
for (WaitingProcessor p : waitingTasks) {
|
||||
QueueTask wTask =
|
||||
new QueueTask(task.getUser(), task.getTitle() + " / " + p.getTitle(), task.getTitle() + " / " + p.getTitle(), p.getProc());
|
||||
final EntityManager entityManager = transaction.getEntityManager();
|
||||
entityManager.persist(wTask);
|
||||
entityManager.refresh(wTask);
|
||||
transaction.enqueue(p.getHost(), TaskTransfer.getTransferObject(wTask));
|
||||
transaction.getEntityManager().persist(wTask);
|
||||
transaction.enqueue(p.getHost(), wTask);
|
||||
}
|
||||
}
|
||||
super.finalize(transaction, task);
|
||||
|
@ -55,6 +55,10 @@ public class Domain extends AbstractEntity {
|
||||
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
|
||||
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)
|
||||
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
|
||||
@JoinTable(name="domain__domain_option",
|
||||
@ -62,9 +66,21 @@ public class Domain extends AbstractEntity {
|
||||
inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")})
|
||||
private Set<DomainOption> domainoptions;
|
||||
|
||||
@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)
|
||||
@Column(name = "passenger_python", columnDefinition = "character varying(256)")
|
||||
private String passengerpython;
|
||||
|
||||
@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() {
|
||||
}
|
||||
@ -175,6 +191,14 @@ public class Domain extends AbstractEntity {
|
||||
"obj.user=:loginUser";
|
||||
}
|
||||
|
||||
public String getValidsubdomainnames() {
|
||||
return validsubdomainnames;
|
||||
}
|
||||
|
||||
public void setValidsubdomainnames(String validSubdomainNames) {
|
||||
this.validsubdomainnames = validSubdomainNames;
|
||||
}
|
||||
|
||||
public Set<DomainOption> getDomainoptions() {
|
||||
return domainoptions;
|
||||
}
|
||||
@ -183,12 +207,48 @@ public class Domain extends AbstractEntity {
|
||||
this.domainoptions = domainOptions;
|
||||
}
|
||||
|
||||
public String getValidsubdomainnames() {
|
||||
return validsubdomainnames;
|
||||
public String getPassengerpython() {
|
||||
if (passengerpython == null) {
|
||||
return "/usr/bin/python3";
|
||||
}
|
||||
return passengerpython;
|
||||
}
|
||||
|
||||
public void setValidsubdomainnames(String validSubdomainNames) {
|
||||
this.validsubdomainnames = validSubdomainNames;
|
||||
public void setPassengerpython(String value) {
|
||||
this.passengerpython = value;
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -30,6 +30,10 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
public static final String DOMOPT_LETSENCRYPT = "letsencrypt";
|
||||
public static final String DOMOPT_AUTOCONFIG = "autoconfig";
|
||||
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 =
|
||||
new String[] {
|
||||
@ -41,18 +45,21 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
DOMOPT_BACKUPFOREXTERNALMX,
|
||||
DOMOPT_LETSENCRYPT,
|
||||
DOMOPT_AUTOCONFIG,
|
||||
DOMOPT_DKIM
|
||||
DOMOPT_DKIM,
|
||||
DOMOPT_PASSENGER,
|
||||
DOMOPT_PASSENGERFRIENDLYERRORPAGES,
|
||||
DOMOPT_CGI,
|
||||
DOMOPT_FASTCGI
|
||||
};
|
||||
public static final String[] DEFAULT_DOMOPTS =
|
||||
new String[] {
|
||||
DOMOPT_GREYLISTING,
|
||||
DOMOPT_MULTIVIEWS,
|
||||
DOMOPT_INDEXES,
|
||||
DOMOPT_HTDOCSFALLBACK,
|
||||
DOMOPT_INCLUDES,
|
||||
DOMOPT_LETSENCRYPT,
|
||||
DOMOPT_AUTOCONFIG,
|
||||
DOMOPT_DKIM
|
||||
DOMOPT_DKIM,
|
||||
DOMOPT_FASTCGI
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,10 @@ public class DomainOptionValues extends DefaultSelectableValues {
|
||||
list.add(new BooleanListValue("letsencrypt"));
|
||||
list.add(new BooleanListValue("autoconfig"));
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
|
||||
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 ) " +
|
||||
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
|
||||
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )")
|
||||
);
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm",
|
||||
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 ) " +
|
||||
"|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )")
|
||||
"|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && systemctl restart postgrey.service )")
|
||||
);
|
||||
}
|
||||
|
||||
@ -237,10 +237,14 @@ 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)
|
||||
);
|
||||
domDirsProcessor.appendProcessor(
|
||||
new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755")
|
||||
new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi/hs-phpstub", userName, pacName, "755")
|
||||
);
|
||||
domDirsProcessor.appendProcessor(
|
||||
new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755")
|
||||
new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi-ssl/hs-phpstub", userName, pacName, "755")
|
||||
);
|
||||
domDirsProcessor.appendProcessor(
|
||||
new ShellProcessor("chattr +i " + domainDir + "/fastcgi/hs-phpstub && " +
|
||||
"chattr +i " + domainDir + "/fastcgi-ssl/hs-phpstub")
|
||||
);
|
||||
domDirsProcessor.appendProcessor(
|
||||
new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " +
|
||||
@ -263,6 +267,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE);
|
||||
ifOption(templateVars, query, "letsencrypt", 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 Processor domSetupProcessor = new CompoundProcessor(
|
||||
isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"),
|
||||
@ -287,11 +299,19 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
" || (mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName +
|
||||
" && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||
" && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
|
||||
" && invoke-rc.d apache2 reload >/dev/null 2>&1)")
|
||||
" && systemctl reload apache2.service >/dev/null 2>&1)")
|
||||
);
|
||||
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) {
|
||||
query.setParameter("option", option);
|
||||
if (query.getResultList().isEmpty()) {
|
||||
@ -320,8 +340,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
" && mkdir " + homedir + "/doms.bak" +
|
||||
" && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" +
|
||||
" && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" +
|
||||
// " && salt-call state.sls pacs " +
|
||||
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||
" && systemctl reload apache2.service >/dev/null 2>&1");
|
||||
}
|
||||
return
|
||||
new ShellProcessor("rm -f /home/doms/" + domname +
|
||||
@ -333,8 +352,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||
" && rm -f /etc/apache2/pems-generated/" + domname + ".crt" +
|
||||
" && rm -f /etc/apache2/pems-generated/" + domname + ".key" +
|
||||
" && 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 +
|
||||
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||
" && systemctl reload apache2.service >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
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" +
|
||||
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
||||
" && rm -f /etc/bind/pri." + domName +
|
||||
" && invoke-rc.d bind9 reload");
|
||||
" && systemctl reload named.service");
|
||||
}
|
||||
|
||||
private Processor createAccountingRulesProc() {
|
||||
@ -142,13 +142,13 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
|
||||
private Processor createLinkSiteProc(final String pacDomain) {
|
||||
return new ShellProcessor("ln -sf /etc/apache2/sites-available/" + pacDomain + " /etc/apache2/sites-enabled/97-" + pacDomain
|
||||
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||
+ " && systemctl reload apache2.service >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
private Processor createUnlinkSiteProc(final String pacDomain) {
|
||||
return new ShellProcessor("rm -f /etc/apache2/sites-enabled/97-" + pacDomain
|
||||
+ " && rm -f /etc/apache2/sites-available/" + pacDomain + ""
|
||||
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||
+ " && systemctl reload apache2.service >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
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",
|
||||
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 ) " +
|
||||
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
|
||||
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-util</artifactId>
|
||||
<version>4.0.18</version>
|
||||
<version>4.0.15</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>11</java.version>
|
||||
<java.version>8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -24,8 +24,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -11,42 +11,31 @@ public class Config {
|
||||
|
||||
private static Logger LOG = Logger.getLogger(Config.class.getName());
|
||||
|
||||
private static final String userDir = System.getProperty("user.dir");
|
||||
private static final String userHome = System.getProperty("user.home");
|
||||
|
||||
private final Properties props;
|
||||
private Properties props;
|
||||
|
||||
private Config() {
|
||||
props = new Properties();
|
||||
initPropertiesFromFile();
|
||||
}
|
||||
|
||||
private void initPropertiesFromFile() {
|
||||
final String baseName = "hsadmin";
|
||||
File file = new File(userDir + "/" + baseName + ".properties");
|
||||
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
|
||||
if (!file.canRead()) {
|
||||
file = new File(userDir + "/conf/" + baseName + ".properties");
|
||||
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File(userHome + "/." + baseName + ".properties");
|
||||
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin/" + baseName + ".properties");
|
||||
file = new File("/etc/hsadmin/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/" + baseName + ".properties");
|
||||
file = new File("/etc/hsadmin.properties");
|
||||
}
|
||||
if (file.canRead()) {
|
||||
try {
|
||||
LOG.info("Constructor - Properties-File: " + file.getAbsolutePath());
|
||||
props.load(new FileReader(file));
|
||||
} catch (Exception e) {
|
||||
LOG.severe("reading properties failed: " + e.getMessage());
|
||||
// should not happen
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
final String errormsg = "reading properties failed: No properties file found";
|
||||
LOG.severe(errormsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user