[mapguide-commits] r4891 - in sandbox/maestro-2.5: MaestroAPITests MaestroBaseTests OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 17 03:10:17 EDT 2010


Author: jng
Date: 2010-05-17 03:10:17 -0400 (Mon, 17 May 2010)
New Revision: 4891

Modified:
   sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs
   sandbox/maestro-2.5/MaestroAPITests/ResourceTests.cs
   sandbox/maestro-2.5/MaestroBaseTests/
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Enums.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs
Log:
Add resource id validation to generated classes and update capability unit tests for missing resource types

Modified: sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs
===================================================================
--- sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -60,6 +60,12 @@
                             }
                         }
                         break;
+                    case ResourceTypes.DrawingSource:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.FeatureSource:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -90,6 +96,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.SymbolLibrary:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.SymbolDefinition:
                         {
                             try
@@ -177,6 +189,12 @@
                             }
                         }
                         break;
+                    case ResourceTypes.DrawingSource:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.FeatureSource:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -207,6 +225,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.SymbolLibrary:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.SymbolDefinition:
                         {
                             try
@@ -294,6 +318,12 @@
                             }
                         }
                         break;
+                    case ResourceTypes.DrawingSource:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.FeatureSource:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -324,6 +354,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.SymbolLibrary:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.SymbolDefinition:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -397,6 +433,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.DrawingSource:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.FeatureSource:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -427,6 +469,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.SymbolLibrary:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.SymbolDefinition:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -500,6 +548,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.DrawingSource:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.FeatureSource:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -530,6 +584,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.SymbolLibrary:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.SymbolDefinition:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -603,6 +663,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.DrawingSource:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.FeatureSource:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());
@@ -633,6 +699,12 @@
                             Assert.AreEqual(version, new Version(1, 0, 0));
                         }
                         break;
+                    case ResourceTypes.SymbolLibrary:
+                        {
+                            var version = caps.GetMaxSupportedResourceVersion(type.ToString());
+                            Assert.AreEqual(version, new Version(1, 0, 0));
+                        }
+                        break;
                     case ResourceTypes.SymbolDefinition:
                         {
                             var version = caps.GetMaxSupportedResourceVersion(type.ToString());

Modified: sandbox/maestro-2.5/MaestroAPITests/ResourceTests.cs
===================================================================
--- sandbox/maestro-2.5/MaestroAPITests/ResourceTests.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/MaestroAPITests/ResourceTests.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -33,6 +33,7 @@
 using OSGeo.MapGuide.MaestroAPI.Resource.Conversion;
 using NMock2;
 using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.ObjectModels.Common;
 
 namespace MaestroAPITests
 {
@@ -84,6 +85,342 @@
         }
 
         [Test]
+        public void TestValidResourceIdentifiers()
+        {
+            //Verify that only valid resource identifiers can be assigned to certain resource types.
+
+            IResource res = new FeatureSourceType();
+            #region Feature Source
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException) { }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException) { }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException) { }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.FeatureSource";
+            }
+            catch (InvalidOperationException)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new DrawingSource();
+            #region Drawing Source
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.FeatureSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new MapDefinition();
+            #region Map Definition
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.MapDefinition";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new WebLayoutType();
+            #region Web Layout
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.WebLayout";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new ApplicationDefinitionType();
+            #region Application Definition
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.ApplicationDefinition";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new SymbolLibraryType();
+            #region Symbol Library
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.SymbolLibrary";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new SimpleSymbolDefinition();
+            #region Simple Symbol Definition
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.SymbolDefinition";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new CompoundSymbolDefinition();
+            #region Compound Symbol Definition
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.SymbolDefinition";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new SymbolLibraryType();
+            #region Symbol Library
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.SymbolLibrary";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+
+            res = new PrintLayout();
+            #region Print Layout
+            try
+            {
+                res.ResourceID = "dklgjlahekjedjfd";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.DrawingSource";
+                Assert.Fail("Should've thrown exception on invalid resource id");
+            }
+            catch (InvalidOperationException){ }
+
+            try
+            {
+                res.ResourceID = "Library://UnitTests/Test.PrintLayout";
+            }
+            catch (Exception)
+            {
+                Assert.Fail("Resource ID should've checked out");
+            }
+            #endregion
+        }
+
+        [Test]
         public void TestNoConversionOnIdenticalVersion()
         {
             //Verify origial reference is returned if we're converting a resource to the same version


Property changes on: sandbox/maestro-2.5/MaestroBaseTests
___________________________________________________________________
Added: svn:ignore
   + bin
obj


Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Enums.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Enums.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Enums.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -33,6 +33,8 @@
         PrintLayout,
         SymbolDefinition,
         LoadProcedure,
+        DrawingSource,
+        SymbolLibrary
 	}
 
 	public enum Operations

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ApplicationDefinition.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.ApplicationDefinition
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.ApplicationDefinition.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSource.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.Common
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.DrawingSource.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/FeatureSource.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.FeatureSource
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.FeatureSource.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.LayerDefinition
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.LayerDefinition.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/LoadProcedure.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.LoadProcedure
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.LoadProcedure.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.MapDefinition
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.MapDefinition.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/PrintLayout.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.PrintLayout
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.PrintLayout.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.SymbolDefinition
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.SymbolDefinition.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolLibrary.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.SymbolLibrary
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.SymbolLibrary.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs	2010-05-17 06:46:19 UTC (rev 4890)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/WebLayout.cs	2010-05-17 07:10:17 UTC (rev 4891)
@@ -22,6 +22,7 @@
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Resource;
 using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
 
 namespace OSGeo.MapGuide.ObjectModels.WebLayout
 {
@@ -47,6 +48,13 @@
             }
             set
             {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.WebLayout.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
                 _resId = value;
                 this.OnPropertyChanged("ResourceID");
             }



More information about the mapguide-commits mailing list