File bnc-449888-handle-no-workspace.patch of Package evolution

diff --git a/plugins/sharepoint-account-setup/SharepointAccount.cs b/plugins/sharepoint-account-setup/SharepointAccount.cs
index 61959ac..a9fad5f 100644
--- a/plugins/sharepoint-account-setup/SharepointAccount.cs
+++ b/plugins/sharepoint-account-setup/SharepointAccount.cs
@@ -85,6 +85,44 @@ namespace Sharepoint
 			} 
 		}
 
+		private static FileInfo [] GetWorkSpaces ()
+		{
+			int tries = 0;
+			
+			TryAgain:
+			try 
+			{
+				tries = tries + 1;
+				FileInfo [] workspaces = deskIceDaemon.EnumerateWorkspaces ();
+
+				return workspaces;
+			}		
+			catch (Exception ex)
+			{
+				if (tries > 5) 
+				{
+					Console.WriteLine ("Three tries exceeded");
+					Console.WriteLine ("Could not create the account");
+					Console.WriteLine (ex.Message);
+					return null;
+				}
+
+				NoWorkspacesException nwex = new NoWorkspacesException ();
+				if (ex.Message.Contains (nwex.Message))	{
+					Console.WriteLine ("No workspaces found");
+					Console.WriteLine ("Sleeping for 4 seconds");
+					System.Threading.Thread.Sleep (1000 * 4);
+
+					goto TryAgain;
+				} else {
+					Console.WriteLine ("Error while getting workspace. Please try again after a minute");
+					Console.WriteLine (ex.Message);
+				}
+			}	
+
+			return null;
+		}
+
 		private static void SetupFolders ()
 		{
 			Console.WriteLine ("Getting folders ");
@@ -97,7 +135,11 @@ namespace Sharepoint
 				return;
 			}
 
-			FileInfo [] workspaces = deskIceDaemon.EnumerateWorkspaces ();
+			FileInfo [] workspaces = GetWorkSpaces ();
+
+			if (workspaces == null)
+				return;
+
 			foreach (FileInfo workspace in workspaces) 
 			{
 				Folder[] folders = null;
openSUSE Build Service is sponsored by