Merge branch 'master' of ssh://hsh04-source@hsh04.hostsharing.net/home/doms/source.hostsharing.net/source/hsadmin.git/
This commit is contained in:
commit
3f23cec1c2
@ -213,9 +213,12 @@ public class CLIClientConnectorServlet extends HttpServlet {
|
|||||||
while (wkeys.hasNext()) {
|
while (wkeys.hasNext()) {
|
||||||
String k = (String) wkeys.next();
|
String k = (String) wkeys.next();
|
||||||
String kname = hasGetter(eType, k);
|
String kname = hasGetter(eType, k);
|
||||||
|
String kvalue = ( (k.equals("id"))
|
||||||
|
? ( AbstractEntity.escapeString(where.get(k)) )
|
||||||
|
: ( "'" + AbstractEntity.escapeString(where.get(k)) + "'" ) );
|
||||||
if (kname != null) {
|
if (kname != null) {
|
||||||
rval += (first ? "" : " and ")
|
rval += (first ? "" : " and ")
|
||||||
+ "(obj." + AbstractEntity.escapeString(kname) + " = '" + AbstractEntity.escapeString(where.get(k)) + "')";
|
+ "(obj." + AbstractEntity.escapeString(kname) + " = " + kvalue + ")";
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
throw new ServletException("illegal input (unknown field: " + k + ")");
|
throw new ServletException("illegal input (unknown field: " + k + ")");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.hsadmin.mods.dom;
|
package de.hsadmin.mods.dom;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -89,7 +90,24 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
|||||||
if (admin == null || admin.getName() == null || admin.getName().length() == 0) {
|
if (admin == null || admin.getName() == null || admin.getName().length() == 0) {
|
||||||
throw new HSAdminException("domain admin required");
|
throw new HSAdminException("domain admin required");
|
||||||
}
|
}
|
||||||
|
// Standard domainoptions setzen. TODO: Alle defaults über eigene Klasse aus der Datenbank holen.
|
||||||
|
HashSet<DomainOption> domainOptions = new HashSet<DomainOption>();
|
||||||
|
DomainOption domainOption = new DomainOption();
|
||||||
|
domainOption.setName("greylisting");
|
||||||
|
domainOptions.add(domainOption);
|
||||||
EntityManager em = getTransaction().getEntityManager();
|
EntityManager em = getTransaction().getEntityManager();
|
||||||
|
Query q = em.createQuery("SELECT opt FROM " +
|
||||||
|
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
||||||
|
" opt WHERE opt.name=:optName");
|
||||||
|
for (DomainOption opt : domainOptions) {
|
||||||
|
q.setParameter("optName", opt.getName());
|
||||||
|
List<?> list = q.getResultList();
|
||||||
|
if (list.size() != 1) {
|
||||||
|
throw new HSAdminException("invalid domain option: " + opt.getName());
|
||||||
|
} else {
|
||||||
|
opt.setId(((DomainOption) list.get(0)).getId());
|
||||||
|
}
|
||||||
|
dom.setDomainoptions(domainOptions);
|
||||||
|
|
||||||
UnixUser loginUser = getTransaction().getLoginUser();
|
UnixUser loginUser = getTransaction().getLoginUser();
|
||||||
if (!loginUser.hasHostmasterRole()) {
|
if (!loginUser.hasHostmasterRole()) {
|
||||||
|
@ -375,16 +375,31 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
String domDir = pacDir + "/doms/" + pac.getName() + ".hostsharing.net";
|
String domDir = pacDir + "/doms/" + pac.getName() + ".hostsharing.net";
|
||||||
String[] sourceDirs = new String[] { "web", "web-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ;
|
String[] sourceDirs = new String[] { "web", "web-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ;
|
||||||
String[] targetDirs = new String[] { "htdocs", "htdocs-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ;
|
String[] targetDirs = new String[] { "htdocs", "htdocs-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ;
|
||||||
CompoundProcessor processor = new CompoundProcessor(
|
CompoundProcessor processor = new CompoundProcessor();
|
||||||
new ShellProcessor("rm -rf " + domDir + "/subs " + domDir + "/htdocs/.htaccess "
|
for (int idx = 0; idx < targetDirs.length; idx++) {
|
||||||
+ domDir + "/subs-ssl " + domDir + "/htdocs-ssl/.htaccess "));
|
processor.appendProcessor(
|
||||||
|
new ShellProcessor("rm -rf " + domDir + targetDirs[idx]));
|
||||||
|
}
|
||||||
for (int idx = 0; idx < sourceDirs.length; idx++) {
|
for (int idx = 0; idx < sourceDirs.length; idx++) {
|
||||||
processor.appendProcessor(
|
processor.appendProcessor(
|
||||||
new ShellProcessor("shopt -s dotglob && ls " + pacDir + "/" + sourceDirs[idx] + " >/dev/null 2>&1" +
|
new ShellProcessor("shopt -s dotglob && ls " + pacDir + "/" + sourceDirs[idx] + " >/dev/null 2>&1" +
|
||||||
" && mv " + pacDir + "/" + sourceDirs[idx] + "/* " + domDir + "/" + targetDirs[idx] + "/ " +
|
" && mv " + pacDir + "/" + sourceDirs[idx] + domDir + "/" + targetDirs[idx] +
|
||||||
" && ( rmdir " + pacDir + "/" + sourceDirs[idx] + " || rm " + pacDir + "/" + sourceDirs[idx] + " ) " +
|
|
||||||
" || echo 'directory " + pacDir + "/" + sourceDirs[idx] + " not found'"));
|
" || echo 'directory " + pacDir + "/" + sourceDirs[idx] + " not found'"));
|
||||||
}
|
}
|
||||||
|
processor.appendProcessor(
|
||||||
|
new ShellProcessor("test -L " + domDir + "/htdocs" +
|
||||||
|
" && `stat -c '%N' " + domDir + "/htdocs |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " +
|
||||||
|
" && cd " + domDir +
|
||||||
|
" && rm " + domDir + "/htdocs" +
|
||||||
|
" && ln -sf htdocs-ssl htdocs" +
|
||||||
|
" && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs"));
|
||||||
|
processor.appendProcessor(
|
||||||
|
new ShellProcessor("test -L " + domDir + "/htdocs-ssl" +
|
||||||
|
" && `stat -c '%N' " + domDir + "/htdocs-ssl |sed -e's/^.*`//' -e\"s/'$//\"` = web " +
|
||||||
|
" && cd " + domDir +
|
||||||
|
" && rm " + domDir + "/htdocs-ssl" +
|
||||||
|
" && ln -sf htdocs htdocs-ssl" +
|
||||||
|
" && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs-ssl"));
|
||||||
return processor;
|
return processor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class DomainTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() {
|
public void testCreate() throws UnknownHostException, IOException {
|
||||||
int count = getDomsCount();
|
int count = getDomsCount();
|
||||||
String user = "aaa00";
|
String user = "aaa00";
|
||||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||||
@ -105,6 +105,9 @@ public class DomainTest {
|
|||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
assertEquals(count + 1, getDomsCount());
|
assertEquals(count + 1, getDomsCount());
|
||||||
|
// TODO die beiden folgenden Tests sind etwas spezifisch für Version 2.2
|
||||||
|
assertEquals("eine neue Domain sollte nur die Domainoption 'greylisting' haben.",1,getDomOptionsCount());
|
||||||
|
testGreylistingOnOff(true, "sollte bei neuer Domain eingeschaltet sein");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user