[mapguide-commits] r9141 - in sandbox/adsk/3.2o.AIMS: Common/MapGuideCommon/Services Common/PlatformBase/Services Server/src/Services/Feature Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Apr 4 23:05:32 PDT 2017


Author: hubu
Date: 2017-04-04 23:05:32 -0700 (Tue, 04 Apr 2017)
New Revision: 9141

Modified:
   sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.cpp
   sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.h
   sandbox/adsk/3.2o.AIMS/Common/PlatformBase/Services/FeatureService.h
   sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/OpGetCapabilities.cpp
   sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.cpp
   sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.h
   sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.cpp
   sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.h
   sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.cpp
   sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.h
Log:
WFS/WMS connection provides runtime capabilities. That is, we need to connect to WFS/WMS server first, then get capabilities from the server. There is already an API FeatureService::GetCapabilities(CREFSTRING providerName, CREFSTRING connectionString). It allows the caller to provide a connection string to connect to WFS/WMS server. But it doesn't work when call the API from client side (e.g. PHP client) and the WFS/WMS server has login/proxy password defined. We can only get login/proxy user name on client side. We cannot get the password. Then the connection string will be incomplete.

To fix this issue, we define a new API FeatureService::GetCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource). The ServerFeatureService will get all necessary information from the feature source and connect to the WFS/WMS Server.

The command GetCapabilities already has 2 overrides. One is has one parameter providerName, the other has 2 parameters providerName and connectionString. In order to distinguish the new command from old commands, I have to add a pseudo parameter to make the parameter count be 3. So the parameters of the new command are: providerName, connectionString and resource.

This change is submitted to adsk branch. A RFC is needed to submit it to main branch. Will prepare necessary staffs later.

Modified: sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.cpp
===================================================================
--- sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.cpp	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.cpp	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -303,7 +303,29 @@
     return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
 }
 
+//////////////////////////////////////////////////////////////////
+MgByteReader* MgProxyFeatureService::GetCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource)
+{
+    Ptr<MgUserInformation> userInfo = m_connProp->GetUserInfo();
+    // conectionString is a pseudo parameter to distinguish this method from other GetCapabilities methods
+    STRING connectionString = L"";
+    MgCommand cmd;
+    cmd.ExecuteCommand(m_connProp,                   // Connection
+        MgCommand::knObject,                         // Return type expected
+        MgFeatureServiceOpId::GetCapabilities_Id,    // Command Code
+        3,                                           // No of arguments
+        Feature_Service,                             // Service Id
+        userInfo->GetApiVersion(),                   // Operation version
+        MgCommand::knString, &providerName,          // Argument#1
+        MgCommand::knString, &connectionString,      // Argument#2
+        MgCommand::knObject, resource,               // Argument#3
+        MgCommand::knNone);                          // End of argument
 
+    SetWarning(cmd.GetWarningObject());
+
+    return (MgByteReader*)cmd.GetReturnValue().val.m_obj;
+}
+
 //////////////////////////////////////////////////////////////////
 /// <summary>
 /// Creates or updates a feature schema within the specified feature source.

Modified: sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.h
===================================================================
--- sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.h	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Common/MapGuideCommon/Services/ProxyFeatureService.h	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -240,6 +240,39 @@
 
     /////////////////////////////////////////////////////////////////
     /// \brief
+    /// This method returns capabilities of the provider applicable for the
+    /// specified connection string.
+    ///
+    /// \remarks
+    /// This would provide details on the following
+    /// capabilities:
+    /// <ol>
+    /// <li>Connection</li>
+    /// <li>Schema</li>
+    /// <li>Command</li>
+    /// <li>Filter</li>
+    /// <li>Expression</li>
+    /// </ol>
+    /// \n
+    /// Schema Definition: FeatureProviderCapabilities.xsd
+    /// Sample XML:        FeatureProviderCapabilities.xml
+    ///
+    /// \param providerName
+    /// Input
+    /// Name of provider for which capabilities are requested
+    /// \param resource (MgResourceIdentifier)
+    /// Input
+    /// A resource identifier referring to a feature source.
+    ///
+    /// \return
+    /// Byte array representing XML (or NULL)
+    ///
+    /// \exception MgInvalidProviderNameException
+    ///
+    MgByteReader* GetCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource);
+
+    /////////////////////////////////////////////////////////////////
+    /// \brief
     /// This method returns list of ALL schemas names available with
     /// with the provider
     ///

Modified: sandbox/adsk/3.2o.AIMS/Common/PlatformBase/Services/FeatureService.h
===================================================================
--- sandbox/adsk/3.2o.AIMS/Common/PlatformBase/Services/FeatureService.h	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Common/PlatformBase/Services/FeatureService.h	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -389,6 +389,47 @@
 
     /////////////////////////////////////////////////////////////////////////////////////////////
     /// \brief
+    /// Gets the capabilities of an FDO Provider expressed in XML
+    /// according to the \link FdoProviderCapabilities_schema FdoProviderCapabilities \endlink schema.
+    ///
+    /// \remarks
+    /// MgFeatureService derives most of its capabilities from the
+    /// FDO Provider to which it is connected. Capabilities vary
+    /// among providers. For example, the FDO Provider for ArcSDE
+    /// supports all of the spatial operators, and the FDO Provider
+    /// for Oracle supports only a subset. For a fuller discussion,
+    /// see \link ProviderCapabilities Provider Capabilities \endlink.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual MgByteReader GetCapabilities(string providerName, MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual MgByteReader GetCapabilities(String providerName, MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual MgByteReader GetCapabilities(string providerName, MgResourceIdentifier resource);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param providerName (String/string)
+    /// The name of the FDO provider. Get the exact
+    /// form of the name from
+    /// MgFeatureService::GetFeatureProviders.
+    /// \param resource (MgResourceIdentifier)
+    /// A resource identifier referring to a feature source.
+    ///
+    /// \return
+    /// Returns an MgByteReader containing the capabilities in XML
+    /// format (or NULL).
+    ///
+    /// \exception MgInvalidArgumentException
+    /// \exception MgFdoException
+    ///
+    /// \since 3.2
+    virtual MgByteReader* GetCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource) = 0;
+
+    /////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
     /// Creates or updates a feature schema within the specified feature source. For this method to
     /// actually delete any schema elements, the matching elements in the input schema must be marked
     /// for deletion using the MgFeatureSchema::Delete(), MgClassDefinition::Delete() and 

Modified: sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/OpGetCapabilities.cpp
===================================================================
--- sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/OpGetCapabilities.cpp	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/OpGetCapabilities.cpp	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -106,6 +106,36 @@
         // Write the response
         EndExecution(byteReader);
     }
+    else if (3 == m_packet.m_NumArguments)
+    {
+        // Get property name
+        STRING providerName;
+        m_stream->GetString(providerName);
+        // conectionString is a pseudo parameter to distinguish this command from other GetCapabilities commands
+        STRING connectionString;
+        m_stream->GetString(connectionString);
+        // Get the feature source
+        Ptr<MgResourceIdentifier> resource = (MgResourceIdentifier*)m_stream->GetObject();
+
+        BeginExecution();
+
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(providerName.c_str());
+        MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING(connectionString.c_str());
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+        MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+        MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == resource) ? L"MgResourceIdentifier" : resource->ToString().c_str());
+        MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
+
+        Validate();
+
+        // Execute the operation
+        Ptr<MgByteReader> byteReader = m_service->GetCapabilities(providerName, resource);
+
+        // Write the response
+        EndExecution(byteReader);
+    }
     else
     {
         MG_LOG_OPERATION_MESSAGE_PARAMETERS_START();

Modified: sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.cpp	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.cpp	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -298,7 +298,15 @@
     return msgpc.GetProviderCapabilities();
 }
 
+///////////////////////////////////////////////////////////////////////////
+MgByteReader* MgServerFeatureService::GetCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource)
+{
+    MG_LOG_TRACE_ENTRY(L"MgServerFeatureService::GetCapabilities()");
 
+    MgServerGetProviderCapabilities msgpc(providerName, resource);
+    return msgpc.GetProviderCapabilities();
+}
+
 ///////////////////////////////////////////////////////////////////////////
 /// \brief
 /// Creates or updates a feature schema within the specified feature source.

Modified: sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.h
===================================================================
--- sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.h	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerFeatureService.h	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -213,6 +213,39 @@
     /// MgInvalidProviderNameException
     MgByteReader* GetCapabilities(CREFSTRING providerName, CREFSTRING connectionString);
 
+    /////////////////////////////////////////////////////////////////
+    /// \brief
+    /// This method returns capabilities of the provider applicable for the
+    /// specified connection string.
+    ///
+    /// \remarks
+    /// This would provide details on the following
+    /// capabilities:
+    /// <ol>
+    /// <li>Connection</li>
+    /// <li>Schema</li>
+    /// <li>Command</li>
+    /// <li>Filter</li>
+    /// <li>Expression</li>
+    /// </ol>
+    /// \n
+    /// Schema Definition: FeatureProviderCapabilities.xsd
+    /// Sample XML:        FeatureProviderCapabilities.xml
+    ///
+    /// \param providerName
+    /// Input
+    /// Name of provider for which capabilities are requested
+    /// \param resource (MgResourceIdentifier)
+    /// Input
+    /// A resource identifier referring to a feature source.
+    ///
+    /// \return
+    /// Byte array representing XML (or NULL)
+    ///
+    /// \exception MgInvalidProviderNameException
+    ///
+    MgByteReader* GetCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource);
+
     //////////////////////////////////////////////////////////////////
     /// <summary>
     /// This method returns list of ALL schemas names available with

Modified: sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.cpp
===================================================================
--- sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.cpp	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.cpp	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -88,6 +88,45 @@
     m_version = userInfo->GetApiVersion();
 }
 
+MgServerGetProviderCapabilities::MgServerGetProviderCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource)
+{
+    if (providerName.empty())
+    {
+        MgStringCollection arguments;
+        arguments.Add(L"1");
+        arguments.Add(MgResources::BlankArgument);
+
+        throw new MgInvalidArgumentException(L"MgServerGetProviderCapabilities.MgServerGetProviderCapabilities",
+            __LINE__, __WFILE__, &arguments, L"MgStringEmpty", NULL);
+    }
+
+    FdoPtr<IConnectionManager> connManager = FdoFeatureAccessManager::GetConnectionManager();
+    CHECKNULL(connManager, L"MgServerGetProviderCapabilities.MgServerGetProviderCapabilities");
+
+    FdoPtr<FdoIConnection> fdoConn;
+    // Remove the version from the provider name
+    STRING providerNoVersion = providerName;
+    MgFdoConnectionManager* fdoConnectionManager = MgFdoConnectionManager::GetInstance();
+    if (NULL != fdoConnectionManager)
+    {
+        providerNoVersion = fdoConnectionManager->UpdateProviderName(providerName);
+        fdoConn = fdoConnectionManager->Open(resource);
+    }
+
+    CHECKNULL(fdoConn, L"MgServerGetProviderCapabilities.MgServerGetProviderCapabilities");
+
+    m_xmlUtil = new MgXmlUtil();
+    CHECKNULL(m_xmlUtil, L"MgServerGetProviderCapabilities.MgServerGetProviderCapabilities");
+
+    m_xmlCap = NULL;
+
+    // no more risk of exceptions, so we can now assign these
+    m_fdoConn = fdoConn.Detach();
+    m_providerName = providerNoVersion;
+    Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
+    m_version = userInfo->GetApiVersion();
+}
+
 MgServerGetProviderCapabilities::~MgServerGetProviderCapabilities()
 {
     // Check if the connection needs to be closed

Modified: sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.h
===================================================================
--- sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.h	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Server/src/Services/Feature/ServerGetProviderCapabilities.h	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -27,6 +27,7 @@
 {
 public:
     MgServerGetProviderCapabilities(CREFSTRING providerName, CREFSTRING connectionString);
+    MgServerGetProviderCapabilities(CREFSTRING providerName, MgResourceIdentifier* resource);
     ~MgServerGetProviderCapabilities();
     MgByteReader* GetProviderCapabilities();
 

Modified: sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.cpp
===================================================================
--- sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.cpp	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.cpp	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -37,6 +37,7 @@
     Ptr<MgHttpRequestParam> params = hRequest->GetRequestParam();
     m_providerName = params->GetParameterValue(MgHttpResourceStrings::reqFeatProvider);
     m_connectionString = params->GetParameterValue(MgHttpResourceStrings::reqFeatConnectionString);
+    m_resourceId = params->GetParameterValue(MgHttpResourceStrings::reqResourceId);
 }
 
 /// <summary>
@@ -57,9 +58,15 @@
 
     // Create Proxy Feature Service instance
     Ptr<MgFeatureService> service = (MgFeatureService*)(CreateService(MgServiceType::FeatureService));
-
+    Ptr<MgByteReader> byteReader;
     // call the C++ API
-    Ptr<MgByteReader> byteReader = service->GetCapabilities(m_providerName, m_connectionString);
+    if (m_resourceId == L"")
+        byteReader = service->GetCapabilities(m_providerName, m_connectionString);
+    else
+    {
+        MgResourceIdentifier resource(m_resourceId);
+        byteReader = service->GetCapabilities(m_providerName, &resource);
+    }
 
     // Convert to requested response format, if necessary
     ProcessFormatConversion(byteReader);

Modified: sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.h
===================================================================
--- sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.h	2017-04-05 04:44:02 UTC (rev 9140)
+++ sandbox/adsk/3.2o.AIMS/Web/src/HttpHandler/HttpGetCapabilities.h	2017-04-05 06:05:32 UTC (rev 9141)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2017 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -46,6 +46,7 @@
 private:
     STRING  m_providerName;
     STRING  m_connectionString;
+    STRING  m_resourceId;
 };
 
 #endif  // _FS_GET_CAPABILITIES_H



More information about the mapguide-commits mailing list