[mapguide-commits] r5191 - in trunk/MgDev: Server/src/Services/Feature Server/src/Wfs Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Sep 26 04:08:58 EDT 2010


Author: liuar
Date: 2010-09-26 08:08:58 +0000 (Sun, 26 Sep 2010)
New Revision: 5191

Modified:
   trunk/MgDev/Server/src/Services/Feature/FilterUtil.cpp
   trunk/MgDev/Server/src/Wfs/1.0.0.xml.awd
   trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp
   trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp
   trunk/MgDev/Web/src/HttpHandler/WfsFeatures.cpp
Log:
ticket #1421 OGC WFS 1.1.0 Support

11. Test wfs:wfs-1.1.0-Basic-GetFeature-tc23.1 (s0001/d1e35137_1/d1e740_1/d1e25217_1/d1e6182_1)

Assertion: The following query parameters are required for all KVP-encoded service requests except !GetCapabilities: service, request, version.

For !GetFeature requests, if service or version parameter is not specified, MapGuide should response a WFS exception.

12. Test wfs:wfs-1.1.0-Basic-GetFeature-tc44.2 (s0001/d1e35137_1/d1e740_1/d1e25217_1/d1e6238_1)

Assertion: Version number specified in a given request must correspond to a version supported by the service.

For !GetFeature requests, if the version number specified in the request is not supported, MapGuide should generate a WFS exception.
  
13. Test wfs:wfs-1.1.0-Basic-GetFeature-tc32.1 (s0001/d1e35137_1/d1e740_1/d1e25217_1/d1e6226_1)

Assertion: An ogc:Literal element may include simple or complex content. If a child element appears it may belong to any target namespace, but a top-level declaration for the item must be available.

For property names in filter, there will be a prefix like "gml:" or user specified prefix. Those prefixes should be removed to make sure properties can be found by FDO API.

Modified: trunk/MgDev/Server/src/Services/Feature/FilterUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FilterUtil.cpp	2010-09-24 05:22:10 UTC (rev 5190)
+++ trunk/MgDev/Server/src/Services/Feature/FilterUtil.cpp	2010-09-26 08:08:58 UTC (rev 5191)
@@ -153,6 +153,12 @@
     else if (xmlcmp(wnm, L"PropertyName") == 0)
     {
         m_propName = process_identifier(root);
+        
+        // This is a workaround for GML3. For Name and Description properties, there will be a "gml:" prefix
+        // Remove the prefix to make sure Name and Description properties can be found by FDO API.
+        size_t pos = m_propName.find_first_of(L":");
+        m_propName = m_propName.substr(pos+1);
+
         return m_propName;
     }
     else if (xmlcmp(wnm, L"Literal") == 0)

Modified: trunk/MgDev/Server/src/Wfs/1.0.0.xml.awd
===================================================================
--- trunk/MgDev/Server/src/Wfs/1.0.0.xml.awd	2010-09-24 05:22:10 UTC (rev 5190)
+++ trunk/MgDev/Server/src/Wfs/1.0.0.xml.awd	2010-09-26 08:08:58 UTC (rev 5191)
@@ -265,11 +265,18 @@
 
 -->
 <Response request="Exception" content-type="text/xml">
-<ServiceExceptionReport version="&TemplateVersion;" xmlns="http://www.opengis.net/ogc">
- <ServiceException code="&Exception.Type;">
-  Request=&Request.request; resulted in an exception: &Exception.message;
- </ServiceException>
-</ServiceExceptionReport>
+<ows:ExceptionReport 
+   version="&TemplateVersion;"
+   xmlns:ows="http://www.opengis.net/ows"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd">
+  <ows:Exception exceptionCode="&Exception.Type;" locator="&Exception.Locator;">
+  <ows:ExceptionText>
+   &Exception.message;
+  </ows:ExceptionText>
+ </ows:Exception>
+</ows:ExceptionReport>
+
 </Response>
 
 </Template>

Modified: trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp	2010-09-24 05:22:10 UTC (rev 5190)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp	2010-09-26 08:08:58 UTC (rev 5191)
@@ -71,17 +71,6 @@
     // Instance a server-lette
     MgOgcWfsServer Wfs(Parms,Out);
 
-    // In order to validate request we have to invoke the ProcessRequest
-    if(!Wfs.ProcessRequest(this))
-    {
-        // Obtain the response byte reader
-        Ptr<MgByteReader> errorResponse = Out.Stream().GetReader();
-
-        // Set the result
-        hResult->SetResultObject(errorResponse, errorResponse->GetMimeType());
-        return;
-    }
-
     // Determine required feature types
     CPSZ pszFeatureTypes = Wfs.RequestParameter(MgHttpResourceStrings::reqWfsTypeName.c_str());
     STRING sFeatureTypes = pszFeatureTypes? pszFeatureTypes : _("");
@@ -106,6 +95,17 @@
     MgWfsFeatureDefinitions oFeatureTypes(pResourceService,pFeatureService,featureTypeList);
     Wfs.SetFeatureDefinitions(&oFeatureTypes);
 
+    // In order to validate request we have to invoke the ProcessRequest
+    if(!Wfs.ProcessRequest(this))
+    {
+        // Obtain the response byte reader
+        Ptr<MgByteReader> errorResponse = Out.Stream().GetReader();
+
+        // Set the result
+        hResult->SetResultObject(errorResponse, errorResponse->GetMimeType());
+        return;
+    }
+
     // This is a comma-sep a list.  If empty, == all.
     // If it's just one feature (no comma sep found) let's do
     // a single response, else let's recursively enumerate the features.
@@ -152,7 +152,7 @@
             MyLog.Write(_("WFS::DescribeFeatureType\r\n"));
 #endif
             // Execute the request
-            Wfs.ProcessRequest(this);
+            //Wfs.ProcessRequest(this);
 
             // Slurp the results.
             Ptr<MgByteReader> capabilities = Out.Stream().GetReader();

Modified: trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp	2010-09-24 05:22:10 UTC (rev 5190)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp	2010-09-26 08:08:58 UTC (rev 5191)
@@ -63,6 +63,7 @@
 CPSZ kpszExceptionMessageUnknownTypeName   = _("Expected valid typeName argument, as enumerated by GetCapabilities. (Instead, found typeName='&Request.TypeName;'.)"); // Localize
 CPSZ kpszExceptionMessageWfsGetFeatureMissingFeatureType = _("A WFS GetFeature request requires at least one feature type to be specified."); // Localize
 CPSZ kpszExceptionMessageWfsVersionNegotiationFailed = _("Requested version is unsupported in AcceptVersions"); //Localize
+CPSZ kpszExceptionMessageWfsInvalidVersion = _("Version number specified must correspond to a version supported by the service."); // Localize
 CPSZ kpszExceptionMessageWfsInvalidService = _("Invalid parameter value for SERVICE"); //Localize
 
 CPSZ kpszInternalErrorMissingGetFeatureRequestParams   = _("Internal Error: Missing WFS GetFeature request parameters."); // Localize
@@ -259,7 +260,8 @@
                 {
                     if(sAcceptVersions.find(sVersion) != STRING::npos)
                     {
-                        return true;
+                        bSupported = true;
+                        break;
                     }
                 }    
             }
@@ -286,20 +288,60 @@
         return false;
     }
 
+    // If all the validation passed, we add the FeatureTypeList into definition to 
+    // make ProcedureEnumFeatureTypes happy. 
+    AddDefinition(kpszDefinitionSectionFeatureTypeList,kpszOmittedValue);
+
     return true;
 }
 
 bool MgOgcWfsServer::ValidateGetFeatureRequest()
 {
     CPSZ pVersion = RequestParameter(kpszQueryStringVersion);
-    if(pVersion == NULL)
+    if(pVersion == NULL || STRING(pVersion).empty())
     {
         ServiceExceptionReportResponse(MgOgcWfsException(MgOgcWfsException::kpszMissingRequestParameter,
                                                          kpszExceptionMessageWfsMissingVersion,
                                                          kpszQueryStringVersion));
         return false;
     }
+    else
+    {
+        // OGC CITE: Test wfs:wfs-1.1.0-Basic-GetFeature-tc44.2 (s0001/d1e35137_1/d1e740_1/d1e25217_1/d1e6238_1)
+        // Assertion: Version number specified in a given request must correspond to a version supported by the service.
+        CPSZ pszSupportedVersions = Definition(kpszDictionarySupportedVersions);
+        // Pass out a NULL, which caller must use to tickle an exception.
+        if(pszSupportedVersions == NULL)
+            return false;
 
+        MgXmlParser SupportedVersions(pszSupportedVersions);
+
+        STRING sVersion;
+        bool bSupported = false;
+        while(SupportedVersions.Next())
+        {
+            if(SupportedVersions.Current().Type() == keBeginElement)
+            {
+                MgXmlBeginElement& Begin = (MgXmlBeginElement&)SupportedVersions.Current();
+                if(Begin.Name() == kpszElementVersion && Begin.GetAttribute(kpszAttributeNumber,sVersion))
+                {
+                    if(SZ_EQI(pVersion,sVersion.c_str()))
+                    {
+                        bSupported = true;
+                        break;
+                    }
+                }    
+            }
+        }
+        if(!bSupported)
+        {
+            ServiceExceptionReportResponse(MgOgcWfsException(MgOgcWfsException::kpszInvalidParameterValue,
+                                                             kpszExceptionMessageWfsInvalidVersion,
+                                                             kpszQueryStringVersion));
+            return false;
+        }
+    }
+
     if(m_pGetFeatureParams == NULL)
     {
         // The request params are missing
@@ -450,18 +492,22 @@
     ProcessExpandableTextIntoString(sSubset,sSubset);
 
     int iNum = 0;
+    
+    if(NULL != m_pFeatures)
+    {
+        while(m_pFeatures->Next())
+        {
+            // We ensure that each feature gets its own stack frame
+            // so definitions don't get carried over to the next feature.
+            CDictionaryStackFrame ForEachFeature(this);
+            m_pFeatures->GenerateDefinitions(*m_pTopOfDefinitions);
 
-    while(m_pFeatures->Next()) {
-        // We ensure that each feature gets its own stack frame
-        // so definitions don't get carried over to the next feature.
-        CDictionaryStackFrame ForEachFeature(this);
-        m_pFeatures->GenerateDefinitions(*m_pTopOfDefinitions);
-
-        CPSZ pszIsPublished = this->Definition(_("Feature.IsPublished"));
-        if(pszIsPublished != NULL && SZ_EQ(pszIsPublished,_("1")))
-            if(IsIterationInSubset(++iNum,sSubset,kpszPiDefinitionFeatureIteration)) {
-                ProcessExpandableText(sFormat);
-        }
+            CPSZ pszIsPublished = this->Definition(_("Feature.IsPublished"));
+            if(pszIsPublished != NULL && SZ_EQ(pszIsPublished,_("1")))
+                if(IsIterationInSubset(++iNum,sSubset,kpszPiDefinitionFeatureIteration)) {
+                    ProcessExpandableText(sFormat);
+            }
+         }
     }
 }
 
@@ -480,15 +526,18 @@
     int iNum = 0;
 
     if(m_pFeatureSet != NULL) {
-        while(m_pFeatureSet->Next()) {
+        while(m_pFeatureSet->Next())
+        {
             // We ensure that each feature gets its own stack frame
             // so definitions don't get carried over to the next feature.
             CDictionaryStackFrame ForEachFeature(this);
 
             m_pFeatureSet->GenerateDefinitions(*m_pTopOfDefinitions);
-
-            if(IsIterationInSubset(++iNum,sSubset,kpszPiDefinitionFeatureIteration))
+            
+            if(IsIterationInSubset(++iNum,sSubset,kpszPiDefinitionFeatureIteration) && (*m_pTopOfDefinitions)[L"Feature.OuterXml"] )
+            {
                 ProcessExpandableText(sFormat);
+            }
         }
     }
 }

Modified: trunk/MgDev/Web/src/HttpHandler/WfsFeatures.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/WfsFeatures.cpp	2010-09-24 05:22:10 UTC (rev 5190)
+++ trunk/MgDev/Web/src/HttpHandler/WfsFeatures.cpp	2010-09-26 08:08:58 UTC (rev 5191)
@@ -119,7 +119,7 @@
 
 void MgWfsFeatures::GenerateDefinitions(MgUtilDictionary& Dictionary)
 {
-    if(m_bOk) {
+    if(m_bOk && !m_sCurrentFeature.empty()) {
         Dictionary.AddDefinition(L"Feature.OuterXml",    m_sCurrentFeature);
         Dictionary.AddDefinition(L"Feature.InnerXml",    m_sCurrentFeature.substr(m_iCurrentInnerContent,m_iCurrentInnerLength));
         Dictionary.AddDefinition(L"Feature.EndElement",  m_sCurrentFeature.substr(m_iCurrentInnerContent+m_iCurrentInnerLength));



More information about the mapguide-commits mailing list