Release 2.0.1

This commit is contained in:
Peter Hormanns 2011-08-29 14:09:20 +00:00
parent f86c4952e1
commit 38d9e8ceb8
13 changed files with 67 additions and 36 deletions

View File

@ -58,7 +58,7 @@ public abstract class AbstractEntity {
* @return jpaQLQuery the matching JPA-QL query
*/
public static String createQueryFromStringKey(String humanKey) throws HSAdminException {
return "id=" + humanKey;
return "obj.id=" + humanKey;
}
/**

View File

@ -100,7 +100,7 @@ public class Contact extends AbstractEntity implements Serializable {
}
public static String createQueryFromStringKey(String humanKey) {
return "name='" + humanKey + "'";
return "obj.name='" + humanKey + "'";
}
@Override

View File

@ -103,7 +103,7 @@ public abstract class Database extends AbstractEntity implements Serializable {
}
public static String createQueryFromStringKey(String humanKey) {
return "name='" + humanKey + "'";
return "obj.name='" + humanKey + "'";
}
@Override

View File

@ -39,6 +39,10 @@ public class MySqlDatabase extends Database implements Serializable {
return MySqlUser.class;
}
public static String createQueryFromStringKey(String humanKey) {
return "obj.name='" + humanKey + "'";
}
public static String restriction() {
return "obj.instance='mysql' AND ( " + Database.restriction() + " )";
}

View File

@ -39,9 +39,10 @@ public class PgSqlDatabase extends Database implements Serializable {
return getEncoding();
}
/**
* query restriction for access control
*/
public static String createQueryFromStringKey(String humanKey) {
return "obj.name='" + humanKey + "'";
}
public static String restriction() {
return "obj.instance='pgsql' AND ( " + Database.restriction() + " )";
}

View File

@ -84,7 +84,7 @@ public class DomainModuleImpl extends AbstractModuleImpl {
dom.setFiled(now);
dom.setStatus(Status.SELF);
dom.setStatusChanged(now);
dom.setDnsMaster("dns1.hostsharing.net");
dom.setDnsMaster("dns.hostsharing.net");
if (dom.getName() == null || dom.getName().length() == 0) {
throw new HSAdminException("domain name required");
}

View File

@ -53,7 +53,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
for (String queueName : new String[] { "mail1", "mail2", "mail3" }) {
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net");
}
mainProcessor.appendProcessor("backupmx", createBackupMXSetupProcessor(domName), "backupmx.hostsharing.net");
// mainProcessor.appendProcessor("backupmx", createBackupMXSetupProcessor(domName), "backupmx.hostsharing.net");
templateVars = new HashMap<String, String>();
templateVars.put("PAC", pacName);
templateVars.put("HIVE", pac.getHiveName());
@ -88,7 +88,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
mainProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net");
}
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
mainProcessor.appendProcessor("backupmx", createBackupMXDeleteProcessor(domName), "backupmx.hostsharing.net");
// mainProcessor.appendProcessor("backupmx", createBackupMXDeleteProcessor(domName), "backupmx.hostsharing.net");
return mainProcessor;
}
@ -167,7 +167,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
}
private Processor createMailinDeleteProcessor(String domName) {
Processor mailQueueProcessor = new ShellProcessor("postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " +
Processor mailQueueProcessor = new ShellProcessor(
"postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '" + domName + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/transport");

View File

@ -1,5 +1,5 @@
<!-- BEGIN: main -->$TTL 6H
{DOM_HOSTNAME}. IN SOA dns1.hostsharing.net. hostmaster.hostsharing.net. (
{DOM_HOSTNAME}. IN SOA dns.hostsharing.net. hostmaster.hostsharing.net. (
{SIO} ; serial secs since Jan 1 1970
6H ; refresh (>=10000)
1H ; retry (>=1800)

View File

@ -10,15 +10,10 @@ import de.hsadmin.core.qserv.CompoundProcessor;
import de.hsadmin.core.qserv.EntityProcessorFactory;
import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.ShellProcessor;
import de.hsadmin.core.qserv.WaitingTasksProcessor;
/**
* System level implementation for EMailAdress module.
*/
public class EMailAddressProcessorFactory implements EntityProcessorFactory {
/**
* @return a Processor which creates an email address
*/
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) {
// TODO: combine both keys in a single call (optimization)
EMailAddress email = (EMailAddress) entity;
@ -27,29 +22,47 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
email.getFullDomain() + " -" ) );
cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix/virtual",
email.getEMailAddress() + " " + email.getTarget() ) );
return cp;
if (emailAddressCount(em, email) < 2) {
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
String pacName = email.getDomain().getUser().getPac().getName();
String domName = email.getDomain().getName();
for (String queueName : new String[] { "mail1", "mail2", "mail3" }) {
waitingTasksProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pacName), queueName + ".hostsharing.net");
}
return waitingTasksProcessor;
} else {
return cp;
}
}
/**
* @return a Processor which updates an email address
*/
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) {
// TODO: if update is specified by primary-key or DB query instead of OID,
// a postmap -d might be neccessary
return createCreateProcessor(em, entity);
}
/**
* @return a Processor which deletes an email address
*/
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
// TODO: combine both keys in a single call (optimization)
// remove the entry itself
CompoundProcessor cp = new CompoundProcessor();
EMailAddress email = (EMailAddress) entity;
cp.appendProcessor(
new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix/virtual" ) );
// any other email addresses for this domain?
int emailAddressCount = emailAddressCount(em, email);
if (emailAddressCount == 0) {
// remove the domain from virtual.db
cp.appendProcessor(
new ShellProcessor( "postmap -d '" + email.getFullDomain() + "' /etc/postfix/virtual" ) );
WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp);
String domName = email.getDomain().getName();
for (String queueName : new String[] { "mail1", "mail2", "mail3" }) {
waitingTasksProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net");
}
return waitingTasksProcessor;
} else {
return cp;
}
}
private int emailAddressCount(EntityManager em, EMailAddress email) {
Query query;
if ( email.getSubdomain() != null ) {
query = em.createQuery("SELECT e FROM EMailAddresses e WHERE e.subdomain=:subdomain AND e.domain=:domain");
@ -60,11 +73,23 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory {
}
query.setParameter("domain", email.getDomain());
List<?> result = query.getResultList();
if ( result == null || result.size() == 0 ) {
// remove the domain from virtual.db
cp.appendProcessor(
new ShellProcessor( "postmap -d '" + email.getFullDomain() + "' /etc/postfix/virtual" ) );
if (result == null) {
return 0;
}
return cp;
return result.size();
}
private Processor createMailinSetupProcessor(String domName, String pacName) {
return
new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport",
domName + " smtp:[" + pacName + ".hostsharing.net]\n" +
"." + domName + " smtp:[" + pacName + ".hostsharing.net]\n");
}
private Processor createMailinDeleteProcessor(String domName) {
return new ShellProcessor(
"postmap -d '" + domName + "' /etc/postfix-mailin/transport && " +
"postmap -d '." + domName + "' /etc/postfix-mailin/transport");
}
}

View File

@ -91,7 +91,7 @@ public class EMailAlias extends AbstractEntity implements Serializable {
}
public static String createQueryFromStringKey(String humanKey) {
return "name='" + humanKey + "'";
return "obj.name='" + humanKey + "'";
}
@Override

View File

@ -49,7 +49,7 @@ public class BaseComponent extends de.hsadmin.core.model.AbstractEntity implemen
}
public static String createQueryFromStringKey(String humanKey) {
return "feature='" + humanKey + "'";
return "obj.feature='" + humanKey + "'";
}
@Override

View File

@ -63,7 +63,7 @@ public class Hive extends AbstractEntity implements Serializable {
}
public static String createQueryFromStringKey(String humanKey) {
return "hiveName='" + humanKey + "'";
return "obj.hiveName='" + humanKey + "'";
}
@Override

View File

@ -46,7 +46,7 @@ public class INetAddress extends AbstractEntity implements Serializable {
}
public static String createQueryFromStringKey(String humanKey) {
return "inetAddr='" + humanKey + "'";
return "obj.inetAddr='" + humanKey + "'";
}
@Override