[mapguide-commits] r4863 - in trunk/Tools/Maestro:
Maestro/ResourceValidators MaestroAPI
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed May 12 20:46:11 EDT 2010
Author: jng
Date: 2010-05-12 20:46:10 -0400 (Wed, 12 May 2010)
New Revision: 4863
Modified:
trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs
trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs
Log:
Fix #1355: Sync up TestConnection() return value on both ServerConnectionI implementations to ensure a consistent result.
Modified: trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs 2010-05-13 00:32:27 UTC (rev 4862)
+++ trunk/Tools/Maestro/Maestro/ResourceValidators/FeatureSourceValidator.cs 2010-05-13 00:46:10 UTC (rev 4863)
@@ -38,7 +38,7 @@
OSGeo.MapGuide.MaestroAPI.FeatureSource feature = resource as OSGeo.MapGuide.MaestroAPI.FeatureSource;
//Note: Must be saved!
string s = feature.CurrentConnection.TestConnection(feature.ResourceId);
- if (s != null && s.Length != 0)
+ if (s.Trim().ToUpper() != true.ToString().ToUpper())
return new ValidationIssue[] { new ValidationIssue(feature, ValidationStatus.Error, s) };
try
Modified: trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs 2010-05-13 00:32:27 UTC (rev 4862)
+++ trunk/Tools/Maestro/MaestroAPI/HttpServerConnection.cs 2010-05-13 00:46:10 UTC (rev 4863)
@@ -22,6 +22,7 @@
using System.Xml;
using System.Collections.Specialized;
using System.Collections;
+using System.Text;
namespace OSGeo.MapGuide.MaestroAPI
{
@@ -212,34 +213,36 @@
public override string TestConnection(string featuresource)
{
string req = m_reqBuilder.TestConnection(featuresource);
-
+ string result = string.Empty;
try
{
byte[] x = this.DownloadData(req);
+ result = Encoding.UTF8.GetString(x);
}
catch (WebException wex)
{
- if (wex.Response != null)
- try
- {
- string result = "";
- using(System.IO.MemoryStream ms = new System.IO.MemoryStream())
- {
- Utility.CopyStream(wex.Response.GetResponseStream(), ms);
- result = System.Text.Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
- }
+ if (wex.Response != null)
+ {
+ try
+ {
+ using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
+ {
+ Utility.CopyStream(wex.Response.GetResponseStream(), ms);
+ result = System.Text.Encoding.UTF8.GetString(ms.ToArray(), 0, (int)ms.Length);
+ }
- if (result.ToLower().IndexOf("<body>") > 0)
- result = result.Substring(result.ToLower().IndexOf("<body>") + 6);
+ if (result.ToLower().IndexOf("<body>") > 0)
+ result = result.Substring(result.ToLower().IndexOf("<body>") + 6);
- if (result.ToLower().IndexOf("</body>") > 0)
- result = result.Substring(0, result.ToLower().IndexOf("</body>"));
+ if (result.ToLower().IndexOf("</body>") > 0)
+ result = result.Substring(0, result.ToLower().IndexOf("</body>"));
- return result;
- }
- catch
- {
- }
+ return result;
+ }
+ catch
+ {
+ }
+ }
if (wex.InnerException == null)
return wex.Message;
@@ -248,10 +251,10 @@
}
catch (Exception ex)
{
- return ex.Message;
+ result = ex.Message;
}
- return string.Empty;
+ return result;
}
public string TestConnection(string providername, NameValueCollection parameters)
Modified: trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs 2010-05-13 00:32:27 UTC (rev 4862)
+++ trunk/Tools/Maestro/MaestroAPI/LocalNativeConnection.cs 2010-05-13 00:46:10 UTC (rev 4863)
@@ -172,13 +172,13 @@
if (sb.Length > 0)
sb.Length--;
}
- return fes.TestConnection(providername, sb.ToString()) ? "No errors" : "Unspecified errors";
+ return fes.TestConnection(providername, sb.ToString()) ? "True" : "Unspecified errors";
}
public override string TestConnection(string featuresource)
{
MgFeatureService fes = this.Con.CreateService(MgServiceType.FeatureService) as MgFeatureService;
- return fes.TestConnection(new MgResourceIdentifier(featuresource)) ? "No errors" : "Unspecified errors";
+ return fes.TestConnection(new MgResourceIdentifier(featuresource)) ? "True" : "Unspecified errors";
}
public void DescribeSchema()
More information about the mapguide-commits
mailing list