16513
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/core/Feature.java b/update/org.eclipse.update.core/src/org/eclipse/update/core/Feature.java
index 644a308..cb58f9e 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/core/Feature.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/core/Feature.java
@@ -208,10 +208,9 @@
 		IProgressMonitor progress)

 		throws CoreException {

 

-		ErrorRecoveryLog recoveryLog = ErrorRecoveryLog.getLog();

-

 		//DEBUG

 		debug("Installing...:" + getURL().toExternalForm());

+		ErrorRecoveryLog recoveryLog=ErrorRecoveryLog.getLog();

 

 		// make sure we have an InstallMonitor		

 		InstallMonitor monitor;

@@ -275,7 +274,7 @@
 			SubProgressMonitor subMonitor=null;				

 

 			// start log

-			recoveryLog.append(recoveryLog.START_INSTALL_LOG);

+			recoveryLog.open(recoveryLog.START_INSTALL_LOG);

 

 			// Start the installation tasks			

 			handler.installInitiated();

@@ -386,9 +385,6 @@
 			handler.completeInstall(consumer);

 			monitorWork(monitor,1);

 					

-			// log files have been downloaded

-			recoveryLog.append(recoveryLog.END_INSTALL);					

-						

 			// indicate install success

 			success = true;

 

@@ -404,7 +400,8 @@
 					if (success) {

 						result = consumer.close();

 						// close the log

-						recoveryLog.append(recoveryLog.END_INSTALL_LOG);

+						recoveryLog.close(recoveryLog.END_INSTALL_LOG);

+						recoveryLog.delete();

 					} else {

 						consumer.abort();

 					}

@@ -412,9 +409,6 @@
 				handler.installCompleted(success);

 			} catch (Exception e) {

 				newException = e;

-			} finally{

-				recoveryLog.close();

-				recoveryLog.delete();								

 			}

 			if (originalException != null) // original exception wins

 				throw Utilities.newCoreException(

diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ErrorRecoveryLog.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ErrorRecoveryLog.java
index 297d5b3..0b71bcc 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ErrorRecoveryLog.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/ErrorRecoveryLog.java
@@ -32,15 +32,15 @@
 	private static final String END_OF_FILE = "eof=eof";
 
 	//
-	public static final String START_INSTALL_LOG = 	"INSTALL_LOG";
+	public static final String START_INSTALL_LOG = 	"START_INSTALL_LOG";
 	public static final String PLUGIN_ENTRY = 		"PLUGIN";
 	public static final String FRAGMENT_ENTRY = 		"FRAGMENT";	
 	public static final String FEATURE_ENTRY = 		"FEATURE";
-	public static final String END_INSTALL = 		"END_INSTALL";
+	public static final String ALL_INSTALLED = 		"ALL_FEATURES_INSTALLED";
 	public static final String RENAME_ENTRY = 		"RENAME";
 	public static final String END_INSTALL_LOG = 	"END_INSTALL_LOG";
 	public static final String START_REMOVE_LOG = 	"REMOVE_LOG";
-	public static final String END_REMOVE = 			"END_REMOVE";
+	public static final String END_ABOUT_REMOVE =	"END_ABOUT_TO_REMOVE";
 	public static final String DELETE_ENTRY = 		"DELETE";
 	public static final String END_REMOVE_LOG = 		"END_REMOVE_LOG";
 
@@ -50,6 +50,10 @@
 	private FileWriter out;
 	private int index;
 	private List paths;
+	
+	private boolean open = false;
+	private int nbOfOpen = 0;
+	
 
 	/**
 	 * Constructor for ErrorRecoveryLog.
@@ -62,8 +66,9 @@
 	 * Singleton
 	 */
 	public static ErrorRecoveryLog getLog() {
-		if (inst == null)
+		if (inst == null){
 			inst = new ErrorRecoveryLog();
+		}
 		return inst;
 	}
 
@@ -103,17 +108,51 @@
 		return new File(platformConfiguration, ERROR_RECOVERY_LOG);
 	}
 
+
+	/**
+	 * Open the log
+	 */
+	public void open(String logEntry) throws CoreException {
+		if (open) {
+			nbOfOpen++;			
+			UpdateManagerPlugin.warn("Open nested Error/Recovery log #"+nbOfOpen+":"+logEntry);				
+			return;
+		}
+		
+		File logFile = null;		
+		try {
+			logFile = getRecoveryLogFile();
+			out = new FileWriter(logFile);
+			index = 0;
+			paths=null;
+			open=true;
+			nbOfOpen=0;
+			UpdateManagerPlugin.warn("Start new Error/Recovery log #"+nbOfOpen+":"+logEntry);							
+		} catch (IOException e) {
+			throw Utilities.newCoreException(
+				Policy.bind("UpdateManagerUtils.UnableToLog", new Object[] { logFile }),
+				e);
+		}
+		
+		append(logEntry);
+	}
+
+	/**
+	 * Open the log
+	 */
+	private void internalOpen(String logEntry) throws CoreException {
+
+	}
+
 	/**
 	 * Append the string to the log and flush
 	 */
 	public void append(String logEntry) throws CoreException {
 		File logFile = null;
 		try {
-			if (out == null) {
-				logFile = getRecoveryLogFile();
-				out = new FileWriter(logFile);
-				index = 0;
-				paths=null;
+			if (!open) {
+				UpdateManagerPlugin.warn("Internal Error: The Error/Recovery log is not open:"+logEntry,new Exception());				
+				return;
 			}
 
 			StringBuffer buffer = new StringBuffer(LOG_ENTRY_KEY);
@@ -149,7 +188,16 @@
 	/**
 	 * Close any open recovery log
 	 */
-	public void close() {
+	public void close(String logEntry) throws CoreException {
+		
+		if (nbOfOpen>0){
+			UpdateManagerPlugin.warn("Close nested Error/Recovery log #"+nbOfOpen+":"+logEntry);			
+			nbOfOpen--;			
+			return;
+		}			
+		
+		UpdateManagerPlugin.warn("Close Error/Recovery log #"+nbOfOpen+":"+logEntry);
+		append(logEntry);
 		if (out != null) {
 			try {
 				out.write(END_OF_FILE);
@@ -158,6 +206,7 @@
 			} catch (Exception e) { //eat the exception
 			} finally {
 				out = null;
+				open=false;
 			}
 		}
 	}
@@ -279,13 +328,13 @@
 			return multi;
 	 	}
 	 	
-	 	if (values.contains(END_INSTALL) && !forceRemove){
+	 	if (values.contains(ALL_INSTALLED) && !forceRemove){
 	 		// finish install by renaming
 	 		int index = 0;
 	 		boolean found = false;
 	 		String val = prop.getProperty(LOG_ENTRY_KEY+index);
 	 		while(val!=null && !found){
-	 			if(val.equalsIgnoreCase(END_INSTALL)) found = true;
+	 			if(val.equalsIgnoreCase(ALL_INSTALLED)) found = true;
 	 			IStatus renameStatus = processRename(val);
 	 			UpdateManagerPlugin.log(renameStatus);
 	 			if(renameStatus.getSeverity()!=IStatus.OK){
@@ -463,7 +512,7 @@
 			return multi;
 	 	}
 	 	
-	 	if (!values.contains(END_REMOVE)){
+	 	if (!values.contains(END_ABOUT_REMOVE)){
 	 		// finish install by renaming
  			multi.add(createStatus(IStatus.ERROR,"The remove process didn't start. Please remove the disable feature from the program.",null));
 				return multi;
@@ -473,7 +522,7 @@
 	 		boolean found = false;
 	 		String val = prop.getProperty(LOG_ENTRY_KEY+index);
 	 		while(val!=null && !found){
-	 			if(val.equalsIgnoreCase(END_REMOVE)) found = true;
+	 			if(val.equalsIgnoreCase(END_ABOUT_REMOVE)) found = true;
 	 			IStatus renameStatus = processRemove(val);
 	 			UpdateManagerPlugin.log(renameStatus);
 	 			if(renameStatus.getSeverity()!=IStatus.OK){
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutableContentConsumer.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutableContentConsumer.java
index 5b6fb74..48e9b4b 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutableContentConsumer.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeatureExecutableContentConsumer.java
@@ -75,6 +75,12 @@
 			return null;

 		}

 		

+		// parent consumer, log we are about to rename

+		// log files have been downloaded

+		if (getParent()==null){

+			ErrorRecoveryLog.getLog().append(ErrorRecoveryLog.ALL_INSTALLED);

+		}

+		

 		// close nested feature

 		IFeatureContentConsumer[] children = getChildren();

 		for (int i = 0; i < children.length; i++) {

diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFile.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFile.java
index 890bd80..ceaa665 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFile.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteFile.java
@@ -143,12 +143,12 @@
 		try {

 

 			// start log

-			recoveryLog.append(recoveryLog.START_REMOVE_LOG);

+			recoveryLog.open(recoveryLog.START_REMOVE_LOG);

 

-			aboutToRemove(feature);

+			aboutToRemove(feature); 

 

 			// log files have been downloaded

-			recoveryLog.append(recoveryLog.END_REMOVE);

+			recoveryLog.append(recoveryLog.END_ABOUT_REMOVE);

 

 			handler.uninstallInitiated();

 

@@ -239,11 +239,10 @@
 			try {

 				if (success) {

 					// close the log

-					recoveryLog.append(recoveryLog.END_REMOVE_LOG);

-					recoveryLog.close();

+					recoveryLog.close(recoveryLog.END_REMOVE_LOG);

 					recoveryLog.delete();

 				} else {

-					recoveryLog.close();

+					recoveryLog.close(recoveryLog.END_REMOVE_LOG);

 				}

 				handler.uninstallCompleted(success);

 			} catch (Throwable t) {

@@ -417,8 +416,8 @@
 	 * 

 	 */

 	private void aboutToRemove(IFeature feature) throws CoreException {

-		ErrorRecoveryLog recoveryLog = ErrorRecoveryLog.getLog();

 

+		ErrorRecoveryLog recoveryLog = ErrorRecoveryLog.getLog();

 		// if teh recovery is not turned on

 		if (!ErrorRecoveryLog.RECOVERY_ON) return;

 

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/AllConfigurationsTests.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/AllConfigurationsTests.java
index ac09b77..e24d856 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/AllConfigurationsTests.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/configurations/AllConfigurationsTests.java
Binary files differ
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/nestedfeatures/TestInstall.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/nestedfeatures/TestInstall.java
index ad552e6..2735293 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/nestedfeatures/TestInstall.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/nestedfeatures/TestInstall.java
@@ -285,7 +285,5 @@
 				((InstallConfiguration) localSite.getCurrentConfiguration())
 					.getURL()
 					.getFile()));
-
 	}
-
 }
\ No newline at end of file
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/reconciliation/TestSiteReconciliation.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/reconciliation/TestSiteReconciliation.java
index 875368e..5df6409 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/reconciliation/TestSiteReconciliation.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/reconciliation/TestSiteReconciliation.java
@@ -40,15 +40,16 @@
 		PlatformConfiguration cfig = (PlatformConfiguration)BootLoader.getCurrentPlatformConfiguration();
 		ISitePolicy p1 = cfig.createSitePolicy(policy, listOfPlugins);	
 		ISiteEntry s1 = cfig.createSiteEntry(url,p1);
-		cfig.configureSite(s1);
-		
+		cfig.configureSite(s1);	
 	}
 	
 	private void removeConfigSite(URL url) throws Exception {
 		// get new config object
 		PlatformConfiguration cfig = (PlatformConfiguration)BootLoader.getCurrentPlatformConfiguration();
 		ISiteEntry s1 = cfig.findConfiguredSite(url);
+		assertNotNull("Unable to find site entry:"+url,s1);
 		cfig.unconfigureSite(s1);
+		cfig.save();
 	}	
 	/**
 	 * Site 1 contains a feature which needs a plugin taht is not on the path when we start
diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestInstallURLSIteXML.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestInstallURLSIteXML.java
index 4e5f128..ef91105 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestInstallURLSIteXML.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestInstallURLSIteXML.java
@@ -158,16 +158,19 @@
 		UpdateManagerUtils.removeFromFileSystem(new File(localSite.getURL().getFile()));

 	}

 

-/*	public void testInstall() throws Exception {

+	public void testInstall() throws Exception {

 

 		// cleanup local files...

-		File localFile =

-			new File(

-				new URL(

-					((SiteLocal) SiteManager.getLocalSite()).getLocationURL(),

-					SiteLocal.SITE_LOCAL_FILE)

-					.getFile());

+		SiteLocal siteLocal = ((SiteLocal) SiteManager.getLocalSite());

+		File localFile = new File(siteLocal.getLocationURL().getFile());

+		//if (!localFile.exists()) fail("LocalSite file doesn't exist ->"+localFile.getAbsolutePath()+"<-");

+		UpdateManagerUtils.removeFromFileSystem(localFile.getParentFile());		

+		/*

+		localFile = new File(localFile,SiteLocal.SITE_LOCAL_FILE);

+		if (!localFile.exists()) fail("LocalSite.xml doesn't exist:"+localFile);

 		UpdateManagerUtils.removeFromFileSystem(localFile);

+		*/

+		

 		InternalSiteManager.localSite = null;

 

 		URL INSTALL_SITE = null;

@@ -195,8 +198,7 @@
 

 		assertNotNull("Cannot find help.jar on site", remoteFeature);

 		ILocalSite localSite = SiteManager.getLocalSite();

-		IConfiguredSite site =

-			localSite.getCurrentConfiguration().getConfiguredSites()[0];

+		IConfiguredSite site = localSite.getCurrentConfiguration().getConfiguredSites()[0];

 		Listener listener = new Listener();

 		site.addConfiguredSiteChangedListener(listener);

 

@@ -237,7 +239,7 @@
 		site.removeConfiguredSiteChangedListener(listener);

 		assertTrue("Listener hasn't received notification", listener.isNotified());

 	}

-*/

+

 	public void testFileSiteWithoutSiteXML() throws Exception {

 

 		ISite remoteSite =

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestLocalSite.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestLocalSite.java
index d0e9070..b2ff3af 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestLocalSite.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/regularInstall/TestLocalSite.java
@@ -159,7 +159,7 @@
 		UpdateManagerUtils.removeFromFileSystem(localFile);

 	}

 	

-/*	public void testRetriveConfig() throws Exception {

+	public void testRetriveConfig() throws Exception {

 

 		//clean up

 		SiteLocal siteLocal = (SiteLocal)SiteManager.getLocalSite();

@@ -302,7 +302,7 @@
 		}

 

 		//String configuredFeature = feature2.getLabel();

-		assertTrue("cannot find feature org.test1.ident1_1.0.0 in configured SIte",found);

+		assertTrue("cannot find feature org.test1.ident1_1.0.0 in configured Site",found);

 		assertTrue("Wrong id  version of feature",feature2.getVersionedIdentifier().toString().equalsIgnoreCase("org.test1.ident1_1.0.0"));

 		

 		// test only 2 install config in local site

@@ -330,6 +330,6 @@
 		localFile = new File(feature2.getURL().getFile());

 		UpdateManagerUtils.removeFromFileSystem(localFile);

 	}

-*/

+

 }

 

diff --git a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/sitevalidation/TestSiteValidation.java b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/sitevalidation/TestSiteValidation.java
index cae985a..8f9ec02 100644
--- a/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/sitevalidation/TestSiteValidation.java
+++ b/update/org.eclipse.update.tests.core/src/org/eclipse/update/tests/sitevalidation/TestSiteValidation.java
@@ -4,15 +4,15 @@
  * All Rights Reserved.
  */
 import java.io.File;
-import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Properties;
 
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.boot.BootLoader;
+import org.eclipse.core.boot.IPlatformConfiguration.ISiteEntry;
+import org.eclipse.core.internal.boot.PlatformConfiguration;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.update.core.*;
 import org.eclipse.update.configuration.*;
-import org.eclipse.update.internal.core.*;
+import org.eclipse.update.core.SiteManager;
+import org.eclipse.update.internal.core.UpdateManagerUtils;
 import org.eclipse.update.tests.UpdateManagerTestCase;
 
 public class TestSiteValidation extends UpdateManagerTestCase {
@@ -25,6 +25,14 @@
 		super(arg0);
 	}
 
+	private void removeConfigSite(URL url) throws Exception {
+		// get new config object
+		PlatformConfiguration cfig = (PlatformConfiguration)BootLoader.getCurrentPlatformConfiguration();
+		ISiteEntry s1 = cfig.findConfiguredSite(url);
+		assertNotNull("Unable to find site entry:"+url,s1);
+		cfig.unconfigureSite(s1);
+	}
+
 	public void testSite1() throws Exception {
 
 		URL remoteUrl = new URL(TARGET_FILE_SITE + "validation/site1");
@@ -38,6 +46,8 @@
 		if (!status.isOK()){
 			fail(msg+status.getMessage());
 		}
+		currentConfig.removeConfiguredSite(configuredSite);
+		removeConfigSite(configuredSite.getSite().getURL());
 	}
 	
 	public void testSite2() throws Exception {
@@ -98,7 +108,7 @@
 		}
 	}	
 
-/*	public void testSite5() throws Exception {
+	public void testSite5() throws Exception {
 
 		URL remoteUrl = new URL(SOURCE_FILE_SITE + "validation/site5/");
 		File file = new File(remoteUrl.getFile());
@@ -111,8 +121,16 @@
 		if (!status.isOK()){
 			fail(msg+status.getMessage());
 		}
+		
+			// get new config object
+		URL url = configuredSite.getSite().getURL();
+		PlatformConfiguration cfig = (PlatformConfiguration)BootLoader.getCurrentPlatformConfiguration();
+		ISiteEntry s1 = cfig.findConfiguredSite(url);
+		assertNotNull("Site entry not found:"+url,s1);
+		cfig.unconfigureSite(s1);
+		cfig.save();
 	}
-*/	
+	
 	public void testSite6() throws Exception {
 
 		URL remoteUrl = new URL(SOURCE_FILE_SITE + "validation/site6/children/children");