From 75b244caea4bd433bdab52bc121f46874a0928b2 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Tue, 30 Aug 2011 15:41:19 +0200
Subject: [PATCH] Release 2.0.1

---
 hsarback/test/de/hsadmin/remote/RoleTest.java             |    2 +-
 hsarback/src/de/hsadmin/remote/PacRemote.java             |   14 +++++++++++---
 hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java |   39 ++++++++++++++++++++++++++-------------
 3 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
index 29f8a09..6703b21 100644
--- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -42,7 +42,8 @@
 				createIPTablesProc(),
 				createSudouersProc(hiveValues, pacValuesList), 
 				createProftpdConfProc(hiveValues, pacValuesList), 
-				createMakePacDirectoryStructure(unixUser));
+				createMakePacDirectoryStructure(unixUser),
+				createIfUp(pacName));
 		WaitingTasksProcessor secProcessor = new WaitingTasksProcessor(priProcessor);
 		secProcessor.appendProcessor(pac.getHiveName(), createSendEMailProc(pacName, customerEMail, emailVars), "send email to customer");
 		return secProcessor;
@@ -51,7 +52,8 @@
 	@Override
 	public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) 
 			throws ProcessorException {
-		throw new ProcessorException("pac.update not implemented");
+		Pac pac = (Pac) entity;
+		return createSetQuotaProc(pac);
 	}
 
 	@Override
@@ -61,6 +63,7 @@
 		Map<String, String> hiveValues = fillHiveValues(hive);
 		List<Map<String, String>> pacValuesList = fillPacValuesList(hive, pac);
 		WaitingTasksProcessor waitingProcessor = new WaitingTasksProcessor(new CompoundProcessor(
+				createIfDown(pac.getName()),
 				createEtcHostsProc(hiveValues, pacValuesList), 
 				createNetworkInterfacesProc(hiveValues, pacValuesList), 
 				createSudouersProc(hiveValues, pacValuesList), 
@@ -130,18 +133,20 @@
 	}
 
 	private Processor createMakePacDirectoryStructure(UnixUser unixUser) {
-		return new ShellProcessor("chmod 711 " + unixUser.getHomedir() + " && " +
-				"su -l " + unixUser.getName() + " -s \"/bin/bash\" -c \"mkdir -p " +
-				unixUser.getHomedir() + "/doms " + 
-				unixUser.getHomedir() + "/etc " +
-				unixUser.getHomedir() + "/users " + 
-				unixUser.getHomedir() + "/var " + 
+		String homedir = unixUser.getHomedir();
+		String username = unixUser.getName();
+		return new ShellProcessor("chmod 711 " + homedir + " && " +
+				"su -l " + username + " -s \"/bin/bash\" -c \"mkdir -p " +
+				homedir + "/doms " + 
+				homedir + "/etc " +
+				homedir + "/users " + 
+				homedir + "/var " + 
 				"\" && " +
-				"chown httpd " + unixUser.getHomedir() + "/doms && " +
-				"chmod 1550 " + unixUser.getHomedir() + "/doms && " +
-				"chmod 2700 " + unixUser.getHomedir() + "/etc && " +
-				"chmod 2750 " + unixUser.getHomedir() + "/var && " +
-				"chmod 2755 " + unixUser.getHomedir() + "/users"
+				"chown httpd " + homedir + "/doms && " +
+				"chmod 1550 " + homedir + "/doms && " +
+				"chmod 2700 " + homedir + "/etc && " +
+				"chmod 2750 " + homedir + "/var && " +
+				"chmod 2755 " + homedir + "/users"
 				);
 	}
 
@@ -155,6 +160,14 @@
 			);
 	}
 
+	private Processor createIfUp(String pacName) {
+		return new ShellProcessor("ifup eth0:" + pacName);
+	}
+
+	private Processor createIfDown(String pacName) {
+		return new ShellProcessor("ifdown eth0:" + pacName);
+	}
+
 	private UnixUser getPacAdminUser(Pac pac) throws ProcessorException {
 		UnixUser unixUser = null;
 		Set<UnixUser> unixUserSet = pac.getUnixUser();
diff --git a/hsarback/src/de/hsadmin/remote/PacRemote.java b/hsarback/src/de/hsadmin/remote/PacRemote.java
index 676ec18..8b7d8f7 100644
--- a/hsarback/src/de/hsadmin/remote/PacRemote.java
+++ b/hsarback/src/de/hsadmin/remote/PacRemote.java
@@ -2,9 +2,11 @@
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.Map;
-import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import de.hsadmin.core.model.AbstractEntity;
 import de.hsadmin.mods.cust.Customer;
@@ -28,10 +30,16 @@
 		resultMap.put("curinetaddr", pac.getCurINetAddr().getInetAddr());
 		resultMap.put("created", df.format(pac.getCreated()));
 		resultMap.put("basepac", pac.getBasepac().getName());
-		Set<PacComponent> pacComponents = pac.getPacComponents();
+		SortedSet<PacComponent> sortedComponents = new TreeSet<PacComponent>(new Comparator<PacComponent>() {
+			@Override
+			public int compare(PacComponent o1, PacComponent o2) {
+				return o2.getBaseComponent().getSorting() - o1.getBaseComponent().getSorting();
+			}
+		});
+		sortedComponents.addAll(pac.getPacComponents());
 		StringBuffer bf = new StringBuffer();
 		boolean empty = true;
-		for (PacComponent comp : pacComponents) {
+		for (PacComponent comp : sortedComponents) {
 			if (comp.getQuantity() > 0) {
 				if (!empty) {
 					bf.append("; ");
diff --git a/hsarback/test/de/hsadmin/remote/RoleTest.java b/hsarback/test/de/hsadmin/remote/RoleTest.java
index ff888f9..7f114f7 100644
--- a/hsarback/test/de/hsadmin/remote/RoleTest.java
+++ b/hsarback/test/de/hsadmin/remote/RoleTest.java
@@ -91,7 +91,7 @@
 
 	@Test
 	public void testHostmaster() {
-		String user = "pe";
+		String user = "ad";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 

--
Gitblit v1.9.1