[mapguide-commits] r8447 - in trunk/Tools/Maestro: MaestroAPITests MaestroAPITests/UserTestData OSGeo.MapGuide.MaestroAPI.Http OSGeo.MapGuide.MaestroAPI.Http/Commands

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Nov 13 23:16:17 PST 2014


Author: jng
Date: 2014-11-13 23:16:17 -0800 (Thu, 13 Nov 2014)
New Revision: 8447

Removed:
   trunk/Tools/Maestro/MaestroAPITests/GeoRestTests.cs
   trunk/Tools/Maestro/MaestroAPITests/UserTestData/GeoRestConfig.xml
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/Commands/GeoRestCommands.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/GeoRestConnection.cs
Log:
#2502: Remove GeoREST related files

Deleted: trunk/Tools/Maestro/MaestroAPITests/GeoRestTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/GeoRestTests.cs	2014-11-14 07:09:50 UTC (rev 8446)
+++ trunk/Tools/Maestro/MaestroAPITests/GeoRestTests.cs	2014-11-14 07:16:17 UTC (rev 8447)
@@ -1,140 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2012, 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;
-using NUnit.Framework;
-using OSGeo.MapGuide.MaestroAPI.Commands;
-using OSGeo.MapGuide.MaestroAPI.Feature;
-using System.Collections.Specialized;
-using OSGeo.MapGuide.MaestroAPI.Internal;
-
-namespace MaestroAPITests
-{
-    [TestFixture]
-    public class GeoRestTests
-    {
-        [TestFixtureSetUp]
-        public void Setup()
-        {
-            if (TestControl.IgnoreGeoRestTests)
-                Assert.Ignore("Skipping GeoRestTests because TestControl.IgnoreGeoRestTests = true");
-        }
-
-        [Test]
-        public void TestInsert()
-        {
-            var conn = ConnectionUtil.CreateTestHttpConnectionWithGeoRest();
-            var insert = (IInsertFeatures)conn.CreateCommand((int)CommandType.InsertFeature);
-            insert.ClassName = "SHP_Schema:Parcels";
-            
-
-            var rec = new MutableRecord();
-            insert.RecordToInsert = rec;
-            insert.FeatureSourceId = "Library://Samples/Sheboygan/Data/Parcels.FeatureSource";
-            var dr = conn.FeatureService.AggregateQueryFeatureSource(
-                insert.FeatureSourceId,
-                "SHP_Schema:Parcels",
-                null,
-                new NameValueCollection()
-                {
-                    { "TOTAL", "COUNT(Autogenerated_SDF_ID)" }
-                });
-
-            long lBefore = 0L;
-            if (dr.ReadNext())
-            {
-                lBefore = dr.GetInt64("TOTAL");
-            }
-            dr.Close();
-
-            var wktReader = new FixedWKTReader();
-
-            rec.PutValue("RNAME", new StringValue("Hello World"));
-            rec.PutValue("Geometry", new GeometryValue(wktReader.Read("POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))")));
-
-            var res = insert.Execute();
-            Assert.Null(res.Error);
-
-            long lAfter = lBefore;
-            dr = conn.FeatureService.AggregateQueryFeatureSource(
-                insert.FeatureSourceId,
-                "SHP_Schema:Parcels",
-                null,
-                new NameValueCollection()
-                {
-                    { "TOTAL", "COUNT(Autogenerated_SDF_ID)" }
-                });
-            if (dr.ReadNext())
-                lAfter = dr.GetInt64("TOTAL");
-            dr.Close();
-
-            Assert.AreEqual(lBefore + 1L, lAfter);
-        }
-
-        [Test]
-        public void TestInsertNotAllowed()
-        {
-            var conn = ConnectionUtil.CreateTestHttpConnectionWithGeoRest();
-            var insert = (IInsertFeatures)conn.CreateCommand((int)CommandType.InsertFeature);
-
-            insert.ClassName = "SHP_Schema:Parcels";
-            var rec = new MutableRecord();
-            insert.FeatureSourceId = "Library://Samples/Sheboygan/Data/ParcelsNotAllowed.FeatureSource";
-            insert.RecordToInsert = rec;
-
-            //This is not allowed
-            var res = insert.Execute();
-            Assert.IsAssignableFrom<InvalidOperationException>(res.Error);
-        }
-
-        [Test]
-        public void TestInsertNonConfigured()
-        {
-            var conn = ConnectionUtil.CreateTestHttpConnectionWithGeoRest();
-            var insert = (IInsertFeatures)conn.CreateCommand((int)CommandType.InsertFeature);
-
-            var rec = new MutableRecord();
-            insert.ClassName = "SHP_Schema:Rail";
-            insert.FeatureSourceId = "Library://Samples/Sheboygan/Data/Rail.FeatureSource";
-            insert.RecordToInsert = rec;
-
-            //This is not configured
-            var res = insert.Execute();
-            Assert.IsAssignableFrom<InvalidOperationException>(res.Error);
-        }
-
-        [Test]
-        public void TestInsertNonConfigured2()
-        {
-            var conn = ConnectionUtil.CreateTestHttpConnectionWithGeoRest();
-            var insert = (IInsertFeatures)conn.CreateCommand((int)CommandType.InsertFeature);
-
-            var rec = new MutableRecord();
-            insert.ClassName = "SHP_Schema:Foobar";
-            insert.FeatureSourceId = "Library://Samples/Sheboygan/Data/Parcels.FeatureSource";
-            insert.RecordToInsert = rec;
-
-            //This is not configured
-            var res = insert.Execute();
-            Assert.IsAssignableFrom<InvalidOperationException>(res.Error);
-        }
-    }
-}

Deleted: trunk/Tools/Maestro/MaestroAPITests/UserTestData/GeoRestConfig.xml
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/UserTestData/GeoRestConfig.xml	2014-11-14 07:09:50 UTC (rev 8446)
+++ trunk/Tools/Maestro/MaestroAPITests/UserTestData/GeoRestConfig.xml	2014-11-14 07:16:17 UTC (rev 8447)
@@ -1,19 +0,0 @@
-<?xml version="1.0" ?>
-<GeoRestConfiguration>
-    <GeoRestFeatureSource>
-        <FeatureSource>Library://Samples/Sheboygan/Data/Parcels.FeatureSource</FeatureSource>
-        <FeatureClass>SHP_Schema:Parcels</FeatureClass>
-        <UriPart>mgproperty</UriPart>
-        <AllowInsert>true</AllowInsert>
-        <AllowUpdate>false</AllowUpdate>
-        <AllowDelete>false</AllowDelete>
-    </GeoRestFeatureSource>
-    <GeoRestFeatureSource>
-        <FeatureSource>Library://Samples/Sheboygan/Data/ParcelsNotAllowed.FeatureSource</FeatureSource>
-        <FeatureClass>SHP_Schema:Parcels</FeatureClass>
-        <UriPart>notallowed</UriPart>
-        <AllowInsert>false</AllowInsert>
-        <AllowUpdate>false</AllowUpdate>
-        <AllowDelete>false</AllowDelete>
-    </GeoRestFeatureSource>
-</GeoRestConfiguration>
\ No newline at end of file

Deleted: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/Commands/GeoRestCommands.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/Commands/GeoRestCommands.cs	2014-11-14 07:09:50 UTC (rev 8446)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/Commands/GeoRestCommands.cs	2014-11-14 07:16:17 UTC (rev 8447)
@@ -1,181 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2012, 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;
-using OSGeo.MapGuide.MaestroAPI.Commands;
-using System.Xml;
-using OSGeo.MapGuide.MaestroAPI.Feature;
-using System.Net;
-using System.IO;
-using System.Diagnostics;
-
-namespace OSGeo.MapGuide.MaestroAPI.Http.Commands
-{
-    public class GeoRestInsertFeatures : DefaultInsertCommand<HttpServerConnection>
-    {
-        internal GeoRestInsertFeatures(HttpServerConnection conn) : base(conn) { }
-
-        protected override void ExecuteInternal()
-        {
-            var gconn = base.ConnImpl.GeoRestConnection;
-            if (gconn == null)
-                throw new InvalidOperationException("Connection does not have a valid GeoREST url or configuration"); //LOCALIZEME
-
-            if (!gconn.Configuration.IsGeoRestEnabled(this.FeatureSourceId, this.ClassName))
-                throw new InvalidOperationException(this.FeatureSourceId + " (" + this.ClassName + ") is not GeoREST configured"); //LOCALIEME
-
-            var fsConf = gconn.Configuration.GetFeatureSource(this.FeatureSourceId, this.ClassName);
-            if (!fsConf.AllowInsert)
-                throw new InvalidOperationException(this.FeatureSourceId + " (" + this.ClassName + ") is not configured for insert operations"); //LOCALIEME
-
-            //Assemble XML to POST
-            XmlDocument doc = new XmlDocument();
-            var fs = doc.AppendChild(doc.CreateElement("FeatureSet"));
-            var features = fs.AppendChild(doc.CreateElement("Features"));
-            var feat = ConvertToFeatureElement(doc);
-            features.AppendChild(feat);
-            
-            //Build GeoREST insert url
-            string insertUrl = gconn.Url;
-            if (!insertUrl.EndsWith("/"))
-                insertUrl += "/";
-            insertUrl += "rest/data/" + fsConf.UriPart + "/.xml";
-
-            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(insertUrl);
-            req.Method = "POST";
-            req.ContentType = "application/xml; charset=\"UTF-8\"";
-            req.Timeout = 10 * 1000;
-
-            using (Stream reqStream = req.GetRequestStream())
-            {
-                using (StreamWriter sw = new StreamWriter(reqStream))
-                {
-                    doc.Save(sw);
-                }
-            }
-
-            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
-#if DEBUG
-            using (var sr = new StreamReader(resp.GetResponseStream()))
-            {
-                Trace.TraceInformation("GeoRest Insert:\n" + sr.ReadToEnd());
-            }
-#endif
-        }
-
-        private XmlNode ConvertToFeatureElement(XmlDocument doc)
-        {
-            XmlNode feat = doc.CreateElement("Feature");
-            foreach (var propName in this.RecordToInsert.PropertyNames)
-            {
-                var prop = doc.CreateElement("Property");
-                var name = doc.CreateElement("Name");
-                name.InnerText = propName;
-                prop.AppendChild(name);
-
-                var value = doc.CreateElement("Value");
-                prop.AppendChild(value);
-
-                if (!this.RecordToInsert.IsNull(propName))
-                {
-                    var pv = this.RecordToInsert.GetValue(propName);
-                    value.InnerText = pv.ValueAsString();
-                }
-                feat.AppendChild(prop);
-            }
-            return feat;
-        }
-    }
-
-    /*
-    public class GeoRestUpdateFeatures : DefaultUpdateCommand<HttpServerConnection>
-    {
-        public override int ExecuteInternal()
-        {
-            var gconn = base.ConnImpl.GeoRestConnection;
-            if (gconn == null)
-                throw new InvalidOperationException("Connection does not have a valid GeoREST url or configuration"); //LOCALIZEME
-
-            if (!gconn.Configuration.IsGeoRestEnabled(this.FeatureSourceId))
-                throw new InvalidOperationException(this.FeatureSourceId + " is not GeoREST configured"); //LOCALIEME
-
-            var fsConf = gconn.Configuration.GetFeatureSource(this.FeatureSourceId);
-            if (!fsConf.AllowInsert)
-                throw new InvalidOperationException(this.FeatureSourceId + " is not configured for insert operations"); //LOCALIEME
-
-            XmlDocument doc = new XmlDocument();
-            var fs = doc.AppendChild(doc.CreateElement("FeatureSet"));
-            var features = fs.AppendChild(doc.CreateElement("Features"));
-            var feat = ConvertToFeatureElement(doc);
-            features.AppendChild(feat);
-
-            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(gconn.Url);
-            req.Method = "POST";
-            req.ContentType = "text/xml";
-
-            Stream reqStream = req.GetRequestStream();
-            doc.Save(reqStream);
-
-            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
-#if DEBUG
-            using (var sr = new StreamReader(resp.GetResponseStream()))
-            {
-                Trace.TraceInformation("GeoRest Insert:\n" + sr.ReadToEnd());
-            }
-#endif
-            return 1;
-        }
-
-        private XmlNode ConvertToFeatureElement(XmlDocument doc)
-        {
-            XmlNode feat = doc.CreateElement("Feature");
-            foreach (var propName in this.ValuesToUpdate.PropertyNames)
-            {
-                var prop = doc.CreateElement("Property");
-                var name = doc.CreateElement("Name");
-                name.InnerText = propName;
-                prop.AppendChild(name);
-
-                var value = doc.CreateElement("Value");
-                prop.AppendChild(value);
-
-                if (!this.ValuesToUpdate.IsNull(propName))
-                {
-                    var pv = this.ValuesToUpdate.GetValue(propName);
-                    value.InnerText = pv.ValueAsString();
-                }
-                feat.AppendChild(prop);
-            }
-            return feat;
-        }
-    }
-     
-    public class GeoRestDeleteFeatures : DefaultDeleteCommand<HttpServerConnection>
-    {
-        protected override int ExecuteInternal()
-        {
-            var gconn = base.ConnImpl;
-            if (gconn == null)
-                throw new InvalidOperationException("Connection does not have a valid GeoREST url or configuration");
-        }
-    }
-     */
-}

Deleted: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/GeoRestConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/GeoRestConnection.cs	2014-11-14 07:09:50 UTC (rev 8446)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/GeoRestConnection.cs	2014-11-14 07:16:17 UTC (rev 8447)
@@ -1,114 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2012, 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;
-using System.IO;
-using System.Xml;
-
-namespace OSGeo.MapGuide.MaestroAPI.Http
-{
-    internal class GeoRestConnection
-    {
-        private string _geoRestUrl;
-
-        private string _configFile;
-
-        private GeoRestFeatureSourceConfiguration _conf;
-
-        public GeoRestFeatureSourceConfiguration Configuration { get { return _conf; } }
-
-        internal GeoRestConnection(string url, string configFile)
-        {
-            _geoRestUrl = url;
-            _configFile = configFile;
-            _conf = GeoRestFeatureSourceConfiguration.LoadFrom(configFile);
-        }
-
-        public string Url { get { return _geoRestUrl; } }
-
-        public string ConfigPath { get { return _configFile; } }
-    }
-
-    internal class GeoRestFeatureSourceConfiguration
-    {
-        private Dictionary<string, GeoRestFeatureSource> _configuredFeatureSources;
-
-        private GeoRestFeatureSourceConfiguration()
-        {
-            _configuredFeatureSources = new Dictionary<string, GeoRestFeatureSource>();
-        }
-
-        private void PutConfig(string featureSource, string featureClass, GeoRestFeatureSource fs)
-        {
-            _configuredFeatureSources[featureSource + "|" + featureClass] = fs;
-        }
-
-        public bool IsGeoRestEnabled(string featureSource, string featureClass) { return _configuredFeatureSources.ContainsKey(featureSource + "|" + featureClass); }
-
-        public ICollection<string> FeatureSources { get { return _configuredFeatureSources.Keys; } }
-
-        public GeoRestFeatureSource GetFeatureSource(string featureSource, string featureClass) { return _configuredFeatureSources[featureSource + "|" + featureClass]; }
-
-        internal static GeoRestFeatureSourceConfiguration LoadFrom(string configFile)
-        {
-            var conf = new GeoRestFeatureSourceConfiguration();
-
-            if (!string.IsNullOrEmpty(configFile) && File.Exists(configFile))
-            {
-                XmlDocument doc = new XmlDocument();
-                doc.Load(configFile);
-
-                XmlNodeList fsNodes = doc.GetElementsByTagName("GeoRestFeatureSource");
-                foreach (XmlNode fsNode in fsNodes)
-                {
-                    var gfs = new GeoRestFeatureSource()
-                    {
-                        FeatureSourceId = fsNode["FeatureSource"].InnerText,
-                        FeatureClass = fsNode["FeatureClass"].InnerText,
-                        UriPart = fsNode["UriPart"].InnerText,
-                        AllowInsert = bool.Parse(fsNode["AllowInsert"].InnerText),
-                        AllowUpdate = bool.Parse(fsNode["AllowUpdate"].InnerText),
-                        AllowDelete = bool.Parse(fsNode["AllowDelete"].InnerText)
-                    };
-
-                    conf.PutConfig(gfs.FeatureSourceId, gfs.FeatureClass, gfs);
-                }
-            }
-
-            return conf;
-        }
-    }
-
-    public class GeoRestFeatureSource
-    {
-        public string FeatureSourceId { get; set; }
-
-        public string UriPart { get; set; }
-
-        public string FeatureClass { get; set; }
-
-        public bool AllowInsert { get; set; }
-
-        public bool AllowUpdate { get; set; }
-
-        public bool AllowDelete { get; set; }
-    }
-}



More information about the mapguide-commits mailing list