Skip most actions if pac is not a web packet.
This commit is contained in:
parent
ce5c545bef
commit
fd53e7dc33
@ -86,28 +86,34 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
||||
pacComponents.add(pacComponent);
|
||||
}
|
||||
pac.setPacComponents(pacComponents);
|
||||
Set<UnixUser> users = new HashSet<UnixUser>();
|
||||
pac.setUnixUser(users);
|
||||
UnixUser admin = new UnixUser();
|
||||
Contact contact = customer.getContractualContact();
|
||||
admin.setComment(TextUtil.replaceUmlautCharacters(contact.getFirstName() + " " + contact.getLastName()));
|
||||
admin.setHomedir("/home/pacs/" + pac.getName());
|
||||
admin.setName(pac.getName());
|
||||
admin.setShell("/bin/bash");
|
||||
admin.setQuotaSoftlimit(0);
|
||||
admin.setQuotaHardlimit(0);
|
||||
admin.setPac(pac);
|
||||
long nUID = 20000;
|
||||
Long maxUid = (Long) em.createQuery("SELECT MAX(u.userId) FROM UnixUsers u").getSingleResult();
|
||||
if (maxUid >= nUID) nUID = maxUid + 1;
|
||||
admin.setUserId(nUID);
|
||||
users.add(admin);
|
||||
AbstractEntity newPacEntity = super.add(newEntity);
|
||||
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
|
||||
Domain pacDomain = new Domain();
|
||||
pacDomain.setName(pac.getName() + ".hostsharing.net");
|
||||
pacDomain.setUser(admin);
|
||||
helperModule.add(pacDomain);
|
||||
AbstractEntity newPacEntity = null;
|
||||
String pacType = pac.getBasepac().getName();
|
||||
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
|
||||
Set<UnixUser> users = new HashSet<UnixUser>();
|
||||
pac.setUnixUser(users);
|
||||
UnixUser admin = new UnixUser();
|
||||
Contact contact = customer.getContractualContact();
|
||||
admin.setComment(TextUtil.replaceUmlautCharacters(contact.getFirstName() + " " + contact.getLastName()));
|
||||
admin.setHomedir("/home/pacs/" + pac.getName());
|
||||
admin.setName(pac.getName());
|
||||
admin.setShell("/bin/bash");
|
||||
admin.setQuotaSoftlimit(0);
|
||||
admin.setQuotaHardlimit(0);
|
||||
admin.setPac(pac);
|
||||
long nUID = 20000;
|
||||
Long maxUid = (Long) em.createQuery("SELECT MAX(u.userId) FROM UnixUsers u").getSingleResult();
|
||||
if (maxUid >= nUID) nUID = maxUid + 1;
|
||||
admin.setUserId(nUID);
|
||||
users.add(admin);
|
||||
newPacEntity = super.add(newEntity);
|
||||
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
|
||||
Domain pacDomain = new Domain();
|
||||
pacDomain.setName(pac.getName() + ".hostsharing.net");
|
||||
pacDomain.setUser(admin);
|
||||
helperModule.add(pacDomain);
|
||||
} else {
|
||||
newPacEntity = super.add(newEntity);
|
||||
}
|
||||
return newPacEntity;
|
||||
}
|
||||
|
||||
@ -150,31 +156,34 @@ public class PacModuleImpl extends AbstractModuleImpl {
|
||||
if (dateCancelled == null || dateCancelled.getTime() > System.currentTimeMillis()) {
|
||||
throw new AuthorisationException(getTransaction().getLoginUser(), "delete", existingEntity);
|
||||
}
|
||||
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
|
||||
String pacType = pac.getBasepac().getName();
|
||||
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
|
||||
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
|
||||
|
||||
String[] dependQueries = new String[] {
|
||||
"SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac",
|
||||
"SELECT db FROM MySqlDatabases db WHERE db.pac.name = :pac",
|
||||
"SELECT db FROM PgSqlDatabases db WHERE db.pac.name = :pac",
|
||||
"SELECT dbusr FROM MySqlUsers dbusr WHERE dbusr.pac.name = :pac",
|
||||
"SELECT dbusr FROM PgSqlUsers dbusr WHERE dbusr.pac.name = :pac",
|
||||
"SELECT alias FROM EMailAliases alias WHERE alias.pac.name = :pac"
|
||||
};
|
||||
String[] dependQueries = new String[] {
|
||||
"SELECT dom FROM Domains dom WHERE dom.user.pac.name = :pac",
|
||||
"SELECT db FROM MySqlDatabases db WHERE db.pac.name = :pac",
|
||||
"SELECT db FROM PgSqlDatabases db WHERE db.pac.name = :pac",
|
||||
"SELECT dbusr FROM MySqlUsers dbusr WHERE dbusr.pac.name = :pac",
|
||||
"SELECT dbusr FROM PgSqlUsers dbusr WHERE dbusr.pac.name = :pac",
|
||||
"SELECT alias FROM EMailAliases alias WHERE alias.pac.name = :pac"
|
||||
};
|
||||
|
||||
for (String queryString : dependQueries) {
|
||||
Query qDoms = em.createQuery(queryString);
|
||||
qDoms.setParameter("pac", pacName);
|
||||
List<?> domsList = qDoms.getResultList();
|
||||
for (Object o : domsList) {
|
||||
if (o instanceof AbstractEntity) {
|
||||
helperModule.delete((AbstractEntity) o);
|
||||
for (String queryString : dependQueries) {
|
||||
Query qDoms = em.createQuery(queryString);
|
||||
qDoms.setParameter("pac", pacName);
|
||||
List<?> domsList = qDoms.getResultList();
|
||||
for (Object o : domsList) {
|
||||
if (o instanceof AbstractEntity) {
|
||||
helperModule.delete((AbstractEntity) o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (UnixUser user : pac.getUnixUser()) {
|
||||
if (!pacName.equals(user.getName())) {
|
||||
helperModule.delete(user);
|
||||
for (UnixUser user : pac.getUnixUser()) {
|
||||
if (!pacName.equals(user.getName())) {
|
||||
helperModule.delete(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.delete(existingEntity);
|
||||
|
Loading…
Reference in New Issue
Block a user