[mapguide-commits] r4889 - in sandbox/maestro-2.5: MaestroAPITests OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Exceptions OSGeo.MapGuide.MaestroAPI.Http

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon May 17 01:57:43 EDT 2010


Author: jng
Date: 2010-05-17 01:57:43 -0400 (Mon, 17 May 2010)
New Revision: 4889

Added:
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedResourceTypeException.cs
Modified:
   sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs
   sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
Log:
Update the Capability APIs to throw Maestro specific exceptions

Modified: sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs
===================================================================
--- sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs	2010-05-17 05:45:17 UTC (rev 4888)
+++ sandbox/maestro-2.5/MaestroAPITests/CapabilityTests.cs	2010-05-17 05:57:43 UTC (rev 4889)
@@ -25,6 +25,7 @@
 using OSGeo.MapGuide.MaestroAPI;
 using OSGeo.MapGuide.MaestroAPI.Http;
 using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
 
 namespace MaestroAPITests
 {
@@ -53,7 +54,10 @@
                                 caps.GetMaxSupportedResourceVersion(type.ToString());
                                 Assert.Fail("MGOS 1.0.0 doesn't support fusion!");
                             }
-                            catch (NotSupportedException) { }
+                            catch (UnsupportedResourceTypeException ex) 
+                            {
+                                Assert.AreEqual(ex.ResourceType, ResourceTypes.ApplicationDefinition);
+                            }
                         }
                         break;
                     case ResourceTypes.FeatureSource:
@@ -93,7 +97,10 @@
                                 caps.GetMaxSupportedResourceVersion(type.ToString());
                                 Assert.Fail("MGOS 1.0.0 doesn't support advanced symbology!");
                             }
-                            catch (NotSupportedException) { }
+                            catch (UnsupportedResourceTypeException ex) 
+                            {
+                                Assert.AreEqual(ex.ResourceType, ResourceTypes.SymbolDefinition);
+                            }
                         }
                         break;
                     case ResourceTypes.WebLayout:
@@ -164,7 +171,10 @@
                                 caps.GetMaxSupportedResourceVersion(type.ToString());
                                 Assert.Fail("MGOS 1.1.0 doesn't support fusion!");
                             }
-                            catch (NotSupportedException) { }
+                            catch (UnsupportedResourceTypeException ex) 
+                            {
+                                Assert.AreEqual(ex.ResourceType, ResourceTypes.ApplicationDefinition);
+                            }
                         }
                         break;
                     case ResourceTypes.FeatureSource:
@@ -204,7 +214,10 @@
                                 caps.GetMaxSupportedResourceVersion(type.ToString());
                                 Assert.Fail("MGOS 1.1.0 doesn't support advanced symbology!");
                             }
-                            catch (NotSupportedException) { }
+                            catch (UnsupportedResourceTypeException ex) 
+                            {
+                                Assert.AreEqual(ex.ResourceType, ResourceTypes.SymbolDefinition);
+                            }
                         }
                         break;
                     case ResourceTypes.WebLayout:
@@ -275,7 +288,10 @@
                                 caps.GetMaxSupportedResourceVersion(type.ToString());
                                 Assert.Fail("MGOS 1.2.0 doesn't support fusion!");
                             }
-                            catch (NotSupportedException) { }
+                            catch (UnsupportedResourceTypeException ex) 
+                            {
+                                Assert.AreEqual(ex.ResourceType, ResourceTypes.ApplicationDefinition);
+                            }
                         }
                         break;
                     case ResourceTypes.FeatureSource:

Added: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedResourceTypeException.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedResourceTypeException.cs	                        (rev 0)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Exceptions/UnsupportedResourceTypeException.cs	2010-05-17 05:57:43 UTC (rev 4889)
@@ -0,0 +1,49 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library 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
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OSGeo.MapGuide.MaestroAPI.Exceptions
+{
+    /// <summary>
+    /// Used to indicate a resource type is not supported for a connection
+    /// </summary>
+    [global::System.Serializable]
+    public class UnsupportedResourceTypeException : MaestroException
+    {
+        //
+        // For guidelines regarding the creation of new exception types, see
+        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+        // and
+        //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+        //
+
+        public UnsupportedResourceTypeException(ResourceTypes rt) { this.ResourceType = rt; }
+        public UnsupportedResourceTypeException(ResourceTypes rt, string message) : base(message) { this.ResourceType = rt; }
+        public UnsupportedResourceTypeException(ResourceTypes rt, string message, Exception inner) : base(message, inner) { this.ResourceType = rt; }
+        protected UnsupportedResourceTypeException(
+          System.Runtime.Serialization.SerializationInfo info,
+          System.Runtime.Serialization.StreamingContext context)
+            : base(info, context) { }
+
+        public ResourceTypes ResourceType { get; private set; }
+    }
+}

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-05-17 05:45:17 UTC (rev 4888)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-05-17 05:57:43 UTC (rev 4889)
@@ -170,6 +170,7 @@
     <Compile Include="Exceptions\CustomPropertyNotFoundException.cs" />
     <Compile Include="Exceptions\MaestroException.cs" />
     <Compile Include="Exceptions\ResourceConversionException.cs" />
+    <Compile Include="Exceptions\UnsupportedResourceTypeException.cs" />
     <Compile Include="IConnectionCapabilities.cs" />
     <Compile Include="MaestroApiProviderAttribute.cs" />
     <Compile Include="ConnectionProviderRegistry.cs" />

Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs	2010-05-17 05:45:17 UTC (rev 4888)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI.Http/HttpCapabilities.cs	2010-05-17 05:57:43 UTC (rev 4889)
@@ -21,6 +21,7 @@
 using System.Collections.Generic;
 using System.Text;
 using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.Exceptions;
 
 namespace OSGeo.MapGuide.MaestroAPI.Http
 {
@@ -40,7 +41,7 @@
             {
                 case "ApplicationDefinition":
                     if (!SupportsFusion())
-                        throw new NotSupportedException();
+                        throw new UnsupportedResourceTypeException(ResourceTypes.ApplicationDefinition);
                     break;
                 case "LayerDefinition":
                     ver = GetMaxLayerDefinitionVersion();
@@ -53,7 +54,7 @@
                     break;
                 case "SymbolDefinition":
                     if (!SupportsAdvancedSymbols())
-                        throw new NotSupportedException();
+                        throw new UnsupportedResourceTypeException(ResourceTypes.SymbolDefinition);
                     else
                         ver = GetMaxSymbolDefinitionVersion();
                     break;



More information about the mapguide-commits mailing list