Hi,

Patch for a UI in WebAdmin to set External Identity Sync Interval.

Please review.

Thanks,
Johnny
Index: src/admin/ChangeLog
===================================================================
--- src/admin/ChangeLog	(revision 6749)
+++ src/admin/ChangeLog	(working copy)
@@ -1,3 +1,15 @@
+2006-11-17 Johnny Jacob <[EMAIL PROTECTED]>
+	
+	* iFolderAdmin.resx : Added data for IDENTITYSYNCTAG and IFOLDER
+	
+	* SystemInfo.aspx : Added IDSyncInterval,IDSyncMinutesTag,
+	SyncNowButton widgets
+	
+	* SystemInfo.aspx.cs : (ShowIdentitySync) : Added. Decides whether
+	to show/hide ID Sync UI.
+	(OnSyncNowButton_Click) : Added. Initiate the ID Sync immediately
+	when 'Sync Now' clicked.
+	(OnSaveButton_Click) : Validate SyncInterval and set it.
 2006-12-8  Johnny Jacob  <[EMAIL PROTECTED]
 
 	* ServerDetails.aspx.cs (GetLogList): Removed adminlogfile and
Index: src/admin/iFolderAdmin.resx
===================================================================
--- src/admin/iFolderAdmin.resx	(revision 6749)
+++ src/admin/iFolderAdmin.resx	(working copy)
@@ -375,6 +375,9 @@
 	<data name="HUNGARIAN">
 		<value>Hungarian</value>
 	</data>
+	<data name="IDENTITYSYNCTAG">
+		<value>Identity Sync</value>
+	</data>
 	<data name="IFOLDER">
 		<value>iFolder</value>
 	</data>
@@ -738,6 +741,9 @@
 	<data name="STATUSTAG">
 		<value>Status:</value>
 	</data>
+	<data name="SYNCNOW">
+		<value>Sync Now</value>
+	</data>
 	<data name="SYNCHRONIZATION">
 		<value>Synchronization</value>
 	</data>
Index: src/admin/SystemInfo.aspx
===================================================================
--- src/admin/SystemInfo.aspx	(revision 6749)
+++ src/admin/SystemInfo.aspx	(working copy)
@@ -82,6 +82,29 @@
 					
 					<tr>
 						<th>
+							<asp:Literal ID="IDSyncTag" Runat="server" />
+						</th>
+						
+						<td>
+							<asp:TextBox 
+								ID="IDSyncInterval" 
+								Runat="server" 
+								CssClass="syncnowtextbox"
+								onkeypress="EnableSystemButtons()" />
+
+							<asp:Literal ID="IDSyncMinutesTag" Runat="server" />
+
+							<asp:Button 
+								ID="SyncNowButton" 
+								Runat="server" 
+								CssClass="syncnowbutton"
+								Enabled="True"
+								OnClick="OnSyncNowButton_Click" />
+						</td>
+					</tr>
+
+					<tr>
+						<th>
 							<%= GetString( "TOTALUSERSTAG" ) %>
 						</th>
 						
Index: src/admin/SystemInfo.aspx.cs
===================================================================
--- src/admin/SystemInfo.aspx.cs	(revision 6749)
+++ src/admin/SystemInfo.aspx.cs	(working copy)
@@ -1,25 +1,25 @@
-/***********************************************************************
- *  $RCSfile: System.aspx.cs,v $
- * 
- *  Copyright (C) 2006 Novell, Inc.
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this program; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Mike Lasky ([EMAIL PROTECTED])
- * 
- ***********************************************************************/
+/***********************************************************************
+ *  $RCSfile: System.aspx.cs,v $
+ * 
+ *  Copyright (C) 2006 Novell, Inc.
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this program; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Author: Mike Lasky ([EMAIL PROTECTED])
+ * 
+ ***********************************************************************/
 
 using System;
 using System.Collections;
@@ -65,11 +65,31 @@
 		protected TextBox Name;
 
 		/// <summary>
+		/// External Identity Sync Interval Tag
+		/// </summary>
+		protected Literal IDSyncTag;
+
+		/// <summary>
+		/// External Identity Sync Interval Tag
+		/// </summary>
+		protected Literal IDSyncMinutesTag;
+
+		/// <summary>
+		/// External Identity Sync Interval
+		/// </summary>
+		protected TextBox IDSyncInterval;
+
+		/// <summary>
 		/// iFolder system description control.
 		/// </summary>
 		protected HtmlTextArea Description;
 
 		/// <summary>
+		/// External Identity Sync Now Button
+		/// </summary>
+		protected Button SyncNowButton;
+
+		/// <summary>
 		/// iFolder system cancel button control.
 		/// </summary>
 		protected Button CancelButton;
@@ -120,6 +140,18 @@
 		/// </summary>
 		protected Button AddButton;
 
+		/// <summary>
+		/// External ID Store status
+		/// </summary>
+
+		protected bool ExternalIdentities;
+
+		/// <summary>
+		/// Current server master/slave role
+		/// </summary>
+
+		protected bool IsMaster;
+
 		#endregion
 
 		#region Properties
@@ -230,6 +262,31 @@
 		}
 
 		/// <summary>
+		/// Show/Hide Identity Sync Widgets based on policy
+		/// </summary>
+		private void ShowIdentitySync()
+		{
+                        if (ExternalIdentities && IsMaster) 
+			{
+			    ExternalIdentities = true;
+			    IDSyncInterval.Visible = true;
+
+			    IDSyncMinutesTag.Text = GetString ("MINUTES");
+			    IDSyncMinutesTag.Visible = true;
+
+			    IDSyncTag.Text = GetString ("IDENTITYSYNCTAG");
+			    IDSyncTag.Visible = true;
+
+			    SyncNowButton.Text = GetString("SYNCNOW");
+			    SyncNowButton.Visible = true;
+		        } else {
+			    IDSyncInterval.Visible = false;
+			    IDSyncTag.Visible = false;
+			    IDSyncMinutesTag.Visible = false;
+			    SyncNowButton.Visible = false;
+			}
+		}
+		/// <summary>
 		/// Gets the displayable ifolder system information.
 		/// </summary>
 		private void GetSystemInformation()
@@ -243,6 +300,9 @@
 
 			iFolderSet ifolders = web.GetiFolders( iFolderType.All, 0, 1 );
 			NumberOfiFolders.Text = ifolders.Total.ToString();
+
+			if (ExternalIdentities && IsMaster)  
+			       IDSyncInterval.Text = (web.IdentitySyncGetServiceInfo().SynchronizationInterval / 60).ToString();
 		}
 
 		/// <summary>
@@ -278,6 +338,9 @@
 			// localization
 			rm = Application[ "RM" ] as ResourceManager;
 
+			ExternalIdentities = web.GetIdentityPolicy().ExternalIdentities;
+			IsMaster = web.GetHomeServer().IsMaster;
+
 			if ( !IsPostBack )
 			{
 				// Initialize the localized fields.
@@ -285,13 +348,15 @@
 				AddButton.Text = GetString( "ADD" );
 				SaveButton.Text = GetString( "SAVE" );
 				CancelButton.Text = GetString( "CANCEL" );
-
+
 				// Initialize state variables.
 				CurrentAdminOffset = 0;
 				TotalAdmins = 0;
 				AllAdminsCheckBox.Checked = false;
 				CheckedMembers = new Hashtable();
-
+
+				ShowIdentitySync();
+
 				// Get the owner of the system.
 				iFolder domain = web.GetiFolder( web.GetSystem().ID );
 				SuperAdminID = domain.OwnerID;
@@ -313,7 +378,6 @@
 
 			// Get the policy information.
 			Policy.GetSystemPolicies();
-
 			// Build the bread crumb list.
 			BuildBreadCrumbList();
 		}
@@ -331,6 +395,7 @@
 				GetString( "ADMINISTRATOR" ) );
 		}
 
+
 		#endregion
 
 		#region Protected Methods
@@ -441,6 +506,16 @@
 		}
 
 		/// <summary>
+		/// Event that gets called when the SyncNow button is clicked.
+		/// </summary>
+		/// <param name="source"></param>
+		/// <param name="e"></param>
+		protected void OnSyncNowButton_Click( object source, EventArgs e )
+		{
+		        web.IdentitySyncNow ();
+		}
+
+		/// <summary>
 		/// Event that gets called when the cancel button is clicked.
 		/// </summary>
 		/// <param name="source"></param>
@@ -494,6 +569,18 @@
 			system.Name = Name.Text;
 			system.Description = Description.Value;
 			web.SetSystem( system );
+
+			if (ExternalIdentities && IsMaster)
+			{
+			        int syncInterval = Int32.Parse (IDSyncInterval.Text);
+				syncInterval = syncInterval * 60;
+				if (syncInterval > 0 ) {
+				        web.IdentitySyncSetInterval (syncInterval);
+				} else {
+				        IDSyncInterval.Text = (web.IdentitySyncGetServiceInfo().SynchronizationInterval / 60).ToString();
+				        TopNav.ShowError( GetString ("ERRORINVALIDSYNCINTERVAL"));
+				}
+			}
 		}
 
 		/// <summary>
Index: src/server/Simias.Server/IdentitySyncService.cs
===================================================================
--- src/server/Simias.Server/IdentitySyncService.cs	(revision 6749)
+++ src/server/Simias.Server/IdentitySyncService.cs	(working copy)
@@ -656,8 +656,19 @@
 		/// </summary>
 		static public int SyncInterval
 		{
-			get { return syncInterval; }
-			set { syncInterval = value; }
+			get { 
+			    return syncInterval; 
+			}
+			set {
+			    //Save this value in Domain.
+			    Store store = Store.GetStore ();
+			    Domain domain = store.GetDomain ( store.DefaultDomain );
+			    Property syncIntervalProp = new Property( "IDSyncInterval" , value );
+			    domain.Properties.ModifyProperty( syncIntervalProp );
+			    domain.Commit( domain );
+
+			    syncInterval = value; 
+			}
 		}
 
 		/// <summary>
@@ -1008,6 +1019,7 @@
 			}
 			
 			log.Debug( "Start - called" );
+
 			quit = false;
 			syncEvent = new AutoResetEvent( false );
 			syncThread = new Thread( new ThreadStart( SyncThread ) );
@@ -1054,6 +1066,15 @@
 			Simias.IdentitySync.Service.cycles = 0;
 			
 			syncEvent.WaitOne( 1000 * 10, false );
+
+ 		        Store store = Store.GetStore ();
+ 			Domain domain = store.GetDomain ( store.DefaultDomain );
+
+ 			if( domain.Properties.GetSingleProperty( "IDSyncInterval" ) == null)
+			       SyncInterval = 900; //15 Mins Default Value. Save it in Domain.
+ 			else
+ 			       syncInterval = (int) domain.Properties.GetSingleProperty( "IDSyncInterval" ).Value;
+
 			while ( quit == false )
 			{
 				running = true;
_______________________________________________
ifolder-dev mailing list
[email protected]
http://forge.novell.com/mailman/listinfo/ifolder-dev

Reply via email to