[mapguide-commits] r4196 - in trunk/MgDev: Common/MapGuideCommon/Services Common/PlatformBase/Services Server/src/Services/Resource UnitTest/WebTier/MapAgent/MapAgentForms Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Aug 28 12:08:13 EDT 2009


Author: brucedechant
Date: 2009-08-28 12:08:13 -0400 (Fri, 28 Aug 2009)
New Revision: 4196

Modified:
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.cpp
   trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.h
   trunk/MgDev/Common/PlatformBase/Services/ResourceService.cpp
   trunk/MgDev/Common/PlatformBase/Services/ResourceService.h
   trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
   trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.h
   trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.cpp
   trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.h
   trunk/MgDev/Server/src/Services/Resource/OpMoveResource.cpp
   trunk/MgDev/Server/src/Services/Resource/ResourceOperationFactory.cpp
   trunk/MgDev/Server/src/Services/Resource/ResourcePackageLoader.cpp
   trunk/MgDev/Server/src/Services/Resource/ServerResourceService.cpp
   trunk/MgDev/Server/src/Services/Resource/ServerResourceService.h
   trunk/MgDev/UnitTest/WebTier/MapAgent/MapAgentForms/moveresourceform.html
   trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.h
   trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.cpp
   trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.h
Log:
Fix for trac ticket 1076 - Move or rename resource should avoid breaking links

Notes:
- This patch implements RFC 74
http://trac.osgeo.org/mapguide/wiki/MapGuideRfc74


Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -427,6 +427,61 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 /// <summary>
+/// Moves an existing resource from this repository to another location.
+///
+/// This function can serve multiple purposes:
+///   - Move a resource if resource path and name are different.
+///   - Rename a resource if resource path is the same and name is different.
+/// </summary>
+/// <param name="sourceResource">
+/// Resource identifier for the resource to be moved/renamed.
+/// This resource can be a document or folder.
+/// </param>
+/// <param name="destResource">
+/// Resource identifier describing where/what the resource should be moved/renamed to.
+/// </param>
+/// <param name="overwrite">
+/// Flag to determine whether or not the destination
+/// resource should be overwritten if it exists.
+/// </param>
+/// <param name="cascade">
+/// Flag to determine whether or not the
+/// referencing resources should be updated.
+/// </param>
+/// <returns>
+/// Nothing.
+/// </returns>
+/// EXCEPTIONS:
+/// MgResourceNotFoundException
+/// MgDuplicateResourceException
+/// MgInvalidRepositoryTypeException
+/// MgInvalidRepositoryNameException
+/// MgInvalidResourcePathException
+/// MgInvalidResourceNameException
+/// MgInvalidResourceTypeException
+
+void MgProxyResourceService::MoveResource(MgResourceIdentifier* sourceResource,
+                                          MgResourceIdentifier* destResource, bool overwrite, bool cascade)
+{
+    MgCommand cmd;
+
+    cmd.ExecuteCommand(m_connProp,
+        MgCommand::knVoid,
+        MgResourceService::opIdMoveResource,
+        4,
+        Resource_Service,
+        BUILD_VERSION(2,2,0),
+        MgCommand::knObject, sourceResource,
+        MgCommand::knObject, destResource,
+        MgCommand::knInt8, (int)overwrite,
+        MgCommand::knInt8, (int)cascade,
+        MgCommand::knNone);
+
+    SetWarning(cmd.GetWarningObject());
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// <summary>
 /// Copies an existing resource to another location.
 /// </summary>
 /// <param name="sourceResource">

Modified: trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Common/MapGuideCommon/Services/ProxyResourceService.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -449,6 +449,41 @@
 
     ///////////////////////////////////////////////////////////////////////////
     /// \brief
+    /// Moves an existing resource from this repository to another location.
+    ///
+    /// This function can serve multiple purposes:
+    ///   - Move a resource if resource path and name are different.
+    ///   - Rename a resource if resource path is the same and name is different.
+    ///
+    /// \param sourceResource
+    /// Resource identifier for the resource to be moved/renamed.
+    /// This resource can be a document or folder.
+    /// \param destResource
+    /// Resource identifier describing where/what the resource should be moved/renamed to.
+    /// \param overwrite
+    /// Flag to determine whether or not the destination
+    /// resource should be overwritten if it exists.
+    /// \param cascade
+    /// Flag to determine whether or not the
+    /// referencing resources should be updated.
+    ///
+    /// \return
+    /// Nothing.
+    ///
+    /// \exception MgResourceNotFoundException
+    /// \exception MgDuplicateResourceException
+    /// \exception MgInvalidRepositoryTypeException
+    /// \exception MgInvalidRepositoryNameException
+    /// \exception MgInvalidResourcePathException
+    /// \exception MgInvalidResourceNameException
+    /// \exception MgInvalidResourceTypeException
+    ///
+
+    virtual void MoveResource(MgResourceIdentifier* sourceResource,
+        MgResourceIdentifier* destResource, bool overwrite, bool cascade);
+
+    ///////////////////////////////////////////////////////////////////////////
+    /// \brief
     /// Copies an existing resource to another location.
     ///
     /// \param sourceResource

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceService.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceService.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceService.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -108,6 +108,24 @@
         __LINE__, __WFILE__, NULL, L"", NULL);
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Moves an existing resource to another location.
+///
+void MgResourceService::MoveResource(MgResourceIdentifier* sourceResource,
+                   MgResourceIdentifier* destResource, bool overwrite)
+{
+    throw new MgNotImplementedException(L"MgResourceService.MoveResource",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
+void MgResourceService::MoveResource(MgResourceIdentifier* sourceResource,
+                  MgResourceIdentifier* destResource, bool overwrite, bool cascade)
+{
+    throw new MgNotImplementedException(L"MgResourceService.MoveResource",
+        __LINE__, __WFILE__, NULL, L"", NULL);
+}
+
 //////////////////////////////////////////////////////////////////
 /// <summary>
 /// Gets the content of the specified resource.

Modified: trunk/MgDev/Common/PlatformBase/Services/ResourceService.h
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/ResourceService.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Common/PlatformBase/Services/ResourceService.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -784,10 +784,96 @@
     /// left intact.
     ///
     virtual void MoveResource(MgResourceIdentifier* sourceResource,
-        MgResourceIdentifier* destResource, bool overwrite) = 0;
+        MgResourceIdentifier* destResource, bool overwrite);
 
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     /// \brief
+    /// Moves an existing resource to another location.
+    ///
+    /// \remarks
+    /// You can also use this method to rename a resource.
+    ///
+    /// <!-- Syntax in .Net, Java, and PHP -->
+    /// \htmlinclude DotNetSyntaxTop.html
+    /// virtual void MoveResource(MgResourceIdentifier sourceResource, MgResourceIdentifier destResource, bool overwrite, bool cascade);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude JavaSyntaxTop.html
+    /// virtual void MoveResource(MgResourceIdentifier sourceResource, MgResourceIdentifier destResource, boolean overwrite, boolean cascade);
+    /// \htmlinclude SyntaxBottom.html
+    /// \htmlinclude PHPSyntaxTop.html
+    /// virtual void MoveResource(MgResourceIdentifier sourceResource, MgResourceIdentifier destResource, bool overwrite, bool cascade);
+    /// \htmlinclude SyntaxBottom.html
+    ///
+    /// \param sourceResource (MgResourceIdentifier)
+    /// Resource to be moved. This can be a document
+    /// or folder.
+    /// <ul>
+    ///    <li>If it is a folder, this method also moves the contents of the folder and all folders below it.</li>
+    ///    <li>If it is a folder, you must include the trailing slash in the identifier.</li>
+    /// </ul>
+    /// \param destResource (MgResourceIdentifier)
+    /// Where the resource should be moved to.
+    /// \param overwrite (boolean/bool)
+    /// Flag to determine whether or not the
+    /// destination resource should be overwritten if
+    /// it exists.
+    /// \param cascade (boolean/bool)
+    /// Flag to determine whether or not the
+    /// referencing resources should be updated.
+    ///
+    /// \return
+    /// Returns nothing.
+    ///
+    /// <!-- Example (PHP) -->
+    /// \htmlinclude PHPExampleTop.html
+    /// This example moves the file
+    /// Library://Geography/World.MapDefinition to
+    /// Library://Atlas/Oceans.MapDefinition:
+    /// \code
+    /// // Assuming $resourceService has already been initialized
+    /// $oldPath = new MgResourceIdentifier("Library://Geography/World.MapDefinition");
+    /// $newPath = new MgResourceIdentifier("Library://Atlas/Oceans.MapDefinition");
+    /// $resourceService->MoveResource($oldPath, $newPath, true, true);
+    /// \endcode
+    ///
+    /// This example moves the folder Library://Geography/ to
+    /// Library://World Geography/:
+    /// \code
+    /// $oldPath = new MgResourceIdentifier("Library://Geography/");
+    /// $newPath = new MgResourceIdentifier("Library://World Geography/");
+    /// $resourceService->MoveResource($oldPath, $newPath, true, true);
+    /// \endcode
+    ///
+    /// This example renames Oceans.MapDefinition to Pacific
+    /// Ocean.MapDefinition:
+    /// \code
+    /// /**************************************************************************/
+    /// $oldPath = new MgResourceIdentifier("Library://Atlas/Oceans.MapDefinition");
+    /// $newPath = new MgResourceIdentifier("Library://Atlas/Pacific Ocean.MapDefinition");
+    /// $resourceService->MoveResource($oldPath, $newPath, true, false);
+    /// \endcode
+    /// \htmlinclude ExampleBottom.html
+    ///
+    /// \exception MgResourceNotFoundException
+    /// \exception MgDuplicateResourceException
+    /// \exception MgInvalidRepositoryTypeException
+    /// \exception MgInvalidRepositoryNameException
+    /// \exception MgInvalidResourcePathException
+    /// \exception MgInvalidResourceNameException
+    /// \exception MgInvalidResourceTypeException
+    ///
+    /// \note
+    /// When copying a folder with the "overwrite" flag turned on, if
+    /// the destination folder already exists, then only the children
+    /// in the destination folder that have the same names as those
+    /// in the source folder are overwritten. The rest should are
+    /// left intact.
+    ///
+    virtual void MoveResource(MgResourceIdentifier* sourceResource,
+        MgResourceIdentifier* destResource, bool overwrite, bool cascade);
+
+    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    /// \brief
     /// Copies an existing resource to another location.
     ///
     /// <!-- Syntax in .Net, Java, and PHP -->

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -417,7 +417,7 @@
 
 void MgApplicationRepositoryManager::MoveResource(
     MgResourceIdentifier* sourceResource, MgResourceIdentifier* destResource,
-    bool overwrite)
+    bool overwrite, bool cascade)
 {
     assert(NULL != sourceResource && NULL != destResource) ;
 
@@ -486,6 +486,15 @@
             __LINE__, __WFILE__, &arguments, L"MgResourcesIdentical", NULL);
     }
 
+    // If cascade update referencing resources, get the references and check permission. 
+    // An MgUnauthorizedAccessException will throw if current user doesn't have write permission to any referencing resource.
+    Ptr<MgStringCollection> referencingIds = NULL;
+    if(cascade)
+    {
+        MgApplicationResourceContentManager* resourceContentMan = GetApplicationResourceContentManager();
+        referencingIds = resourceContentMan->EnumerateAllReferences(sourceResource, MgResourcePermission::ReadWrite);
+    }
+
     // Move the resource and all of its children.
 
     MgResourceHeaderManager* resourceHeaderMan = GetResourceHeaderManager();
@@ -504,6 +513,38 @@
 
     resourceContentMan->MoveResource(sourceResource, destResource, overwrite);
 
+    // If cascade update referencing resources, update referencing resources' content, 
+    // setting ResourceId from sourceResource to destResource
+    if(cascade && referencingIds != NULL &&  referencingIds->GetCount() != 0)
+    {
+        STRING source = sourceResource->ToString();
+        STRING dest = destResource->ToString();
+        STRING prefix = L"<ResourceId>";
+        for(int i = 0; i < referencingIds->GetCount(); i ++)
+        {
+            STRING referencingId = referencingIds->GetItem(i);
+            if(referencingId.find(source) != STRING::npos)
+            {
+                referencingId = referencingId.replace(0, source.size(), dest);
+            }
+            Ptr<MgResourceIdentifier> referenceResource = new MgResourceIdentifier(referencingId);
+            Ptr<MgByteReader> contentReader = GetResourceContent(referenceResource, L"");
+            STRING mimeType = contentReader->GetByteSource()->GetMimeType();
+            STRING content = contentReader->ToString();
+            size_t pos = content.find(prefix + source);
+            if(pos != STRING::npos)
+            {
+                content = content.replace(pos + prefix.size(), source.size(), dest);
+            }
+            string utf8Text = MgUtil::WideCharToMultiByte(content);
+            Ptr<MgByteSource> byteSource = new MgByteSource((BYTE_ARRAY_IN)utf8Text.c_str(), (INT32)utf8Text.length());
+            byteSource->SetMimeType(mimeType);
+            contentReader = byteSource->GetReader();
+            Ptr<MgByteReader> headerReader = GetResourceHeader(referenceResource);
+            SetResource(referenceResource, contentReader, headerReader);
+        }
+    }
+
     UpdateDateModifiedResourceSet(sourceResource->GetFullPath(true));
     UpdateDateModifiedResourceSet(destResource->GetFullPath(true));
 

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.h
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationRepositoryManager.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -65,7 +65,7 @@
     virtual MgByteReader* GetResourceHeader(
         MgResourceIdentifier* resource);
     void MoveResource(MgResourceIdentifier* sourceResource,
-        MgResourceIdentifier* destResource, bool overwrite);
+        MgResourceIdentifier* destResource, bool overwrite, bool cascade);
     void CopyResource(MgResourceIdentifier* sourceResource,
         MgResourceIdentifier* destResource, bool overwrite);
     MgByteReader* EnumerateReferences(MgResourceIdentifier* resource);

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -124,6 +124,67 @@
     return byteReader.Detach();
 }
 
+///----------------------------------------------------------------------------
+/// <summary>
+/// Enumerates all resources which reference to a document or folder resource.
+/// </summary>
+///
+/// <exceptions>
+/// MgDbXmlException, MgDbException, MgUnauthorizedAccessException
+/// </exceptions>
+///----------------------------------------------------------------------------
+MgStringCollection* MgApplicationResourceContentManager::EnumerateAllReferences(MgResourceIdentifier* resource, const STRING permission)
+{
+    assert(NULL != resource);
+    Ptr<MgStringCollection> references = new MgStringCollection();
+
+    MG_RESOURCE_SERVICE_TRY()
+
+    string resourceId;
+    MgUtil::WideCharToMultiByte(resource->ToString(), resourceId);
+
+    // Set up an XQuery.
+
+    string query = "collection('";
+    query += m_container.getName();
+    query += "')";
+    query += "//*/ResourceId[starts-with(.,\"";
+    query += resourceId;
+    query += "\")]";
+
+    // Execute the XQuery.
+
+    XmlManager& xmlMan = m_container.getManager();
+    XmlQueryContext queryContext = xmlMan.createQueryContext();
+    XmlResults results = IsTransacted() ?
+        xmlMan.query(GetXmlTxn(), query, queryContext, 0) :
+    xmlMan.query(query, queryContext, 0);
+
+    // Get the resource and populate the resource reference list.
+
+    // this XML follows the ResourceReferenceList-1.0.0.xsd schema
+    MgResourceIdentifier currResource;
+    XmlValue xmlValue;
+    
+    while (results.next(xmlValue)) // TODO: Need an XML writer
+    {
+        const XmlDocument& xmlDoc = xmlValue.asDocument();
+
+        // Check if the current user has a required permission.
+
+        currResource.SetResource(MgUtil::MultiByteToWideChar(xmlDoc.getName()));
+
+        if (CheckPermission(currResource, permission))
+        {
+            references->Add(currResource.ToString());
+        }
+    }
+
+    MG_RESOURCE_CONTAINER_CATCH_AND_THROW(L"MgApplicationResourceContentManager.EnumerateReferences")
+
+    return references.Detach();
+}
+
 ///////////////////////////////////////////////////////////////////////////
 /// \brief
 /// Enumerate all the parent Map Definition resources of the specified

Modified: trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.h
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ApplicationResourceContentManager.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -45,7 +45,11 @@
 
     // Resource Management APIs
 
+    // Enumerates all resources which reference the specified resource by ResourceId='***'
     MgByteReader* EnumerateReferences(MgResourceIdentifier* resource);
+    // Enumerates all resources which reference to a document or folder resource by starts-with(ResourceId,'***')
+    // If the reference resource doesn't have specific permission, through exception.
+    MgStringCollection* EnumerateAllReferences(MgResourceIdentifier* resource, const STRING permission);
     void EnumerateParentMapDefinitions(
         const set<string>& currSearchResources, set<string>& nextSearchResources,
         set<string>& childResources, set<STRING>& parentResources);

Modified: trunk/MgDev/Server/src/Services/Resource/OpMoveResource.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/OpMoveResource.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/OpMoveResource.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -62,7 +62,7 @@
 
     ACE_ASSERT(m_stream != NULL);
 
-    if (3 == m_packet.m_NumArguments)
+    if (3 == m_packet.m_NumArguments || 4 == m_packet.m_NumArguments)
     {
         Ptr<MgResourceIdentifier> sourceResource =
             (MgResourceIdentifier*)m_stream->GetObject();
@@ -70,6 +70,11 @@
             (MgResourceIdentifier*)m_stream->GetObject();
         bool overwrite;
         m_stream->GetBoolean(overwrite);
+        bool cascade = false;
+        if(4 == m_packet.m_NumArguments)
+        {
+            m_stream->GetBoolean(cascade);
+        }
 
         BeginExecution();
 
@@ -79,11 +84,13 @@
         MG_LOG_OPERATION_MESSAGE_ADD_STRING((NULL == destResource) ? L"MgResourceIdentifier" : destResource->ToString().c_str());
         MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
         MG_LOG_OPERATION_MESSAGE_ADD_BOOL(overwrite);
+        MG_LOG_OPERATION_MESSAGE_ADD_SEPARATOR();
+        MG_LOG_OPERATION_MESSAGE_ADD_BOOL(cascade);
         MG_LOG_OPERATION_MESSAGE_PARAMETERS_END();
 
         Validate();
 
-        m_service->MoveResource(sourceResource, destResource, overwrite);
+        m_service->MoveResource(sourceResource, destResource, overwrite, cascade);
 
         EndExecution();
     }

Modified: trunk/MgDev/Server/src/Services/Resource/ResourceOperationFactory.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ResourceOperationFactory.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ResourceOperationFactory.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -247,6 +247,7 @@
         switch (VERSION_NO_PHASE(operationVersion))
         {
         case VERSION_SUPPORTED(1,0):
+        case VERSION_SUPPORTED(2,2):
             handler.reset(new MgOpMoveResource());
             break;
         default:

Modified: trunk/MgDev/Server/src/Services/Resource/ResourcePackageLoader.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ResourcePackageLoader.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ResourcePackageLoader.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -356,6 +356,9 @@
     bool overwrite = ACE_OS::atoi(opInfo.GetParameter(
         MgOperationParameter::Overwrite, false).GetValue().c_str()) != 0;
 
+    CREFSTRING paramCascade = opInfo.GetParameter(MgOperationParameter::Overwrite, false).GetValue();
+    bool cascade = !paramCascade.empty() && (ACE_OS::atoi(paramCascade.c_str()) != 0);
+
     if (m_packageLogWriter != NULL)
     {
         MG_LOG_OPERATION_MESSAGE(L"MoveResource");
@@ -370,7 +373,7 @@
         m_packageLogWriter->AddOperation(operationMessage);
     }
 
-    m_repositoryManager.MoveResource(srcResource, destResource, overwrite);
+    m_repositoryManager.MoveResource(srcResource, destResource, overwrite, cascade);
 
     MG_RESOURCE_SERVICE_CATCH_AND_THROW(L"MgResourcePackageLoader.MoveResource")
 }

Modified: trunk/MgDev/Server/src/Services/Resource/ServerResourceService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ServerResourceService.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ServerResourceService.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -797,9 +797,14 @@
 /// MgException
 /// </exceptions>
 ///----------------------------------------------------------------------------
+void MgServerResourceService::MoveResource(MgResourceIdentifier* sourceResource,
+     MgResourceIdentifier* destResource, bool overwrite)
+{
+    MoveResource(sourceResource, destResource, overwrite, false);
+}
 
 void MgServerResourceService::MoveResource(MgResourceIdentifier* sourceResource,
-    MgResourceIdentifier* destResource, bool overwrite)
+    MgResourceIdentifier* destResource, bool overwrite, bool cascade)
 {
     MG_RESOURCE_SERVICE_TRY()
 
@@ -816,7 +821,7 @@
 
     MG_RESOURCE_SERVICE_BEGIN_OPERATION(true)
 
-    repositoryMan->MoveResource(sourceResource, destResource, overwrite);
+    repositoryMan->MoveResource(sourceResource, destResource, overwrite, cascade);
 
     MG_RESOURCE_SERVICE_END_OPERATION(sm_retryAttempts)
 

Modified: trunk/MgDev/Server/src/Services/Resource/ServerResourceService.h
===================================================================
--- trunk/MgDev/Server/src/Services/Resource/ServerResourceService.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Server/src/Services/Resource/ServerResourceService.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -81,6 +81,8 @@
     virtual void DeleteResource(MgResourceIdentifier* resource);
     virtual void MoveResource(MgResourceIdentifier* sourceResource,
         MgResourceIdentifier* destResource, bool overwrite);
+    virtual void MoveResource(MgResourceIdentifier* sourceResource,
+        MgResourceIdentifier* destResource, bool overwrite, bool cascade);
     virtual void CopyResource(MgResourceIdentifier* sourceResource,
         MgResourceIdentifier* destResource, bool overwrite);
     virtual MgByteReader* GetResourceContent(

Modified: trunk/MgDev/UnitTest/WebTier/MapAgent/MapAgentForms/moveresourceform.html
===================================================================
--- trunk/MgDev/UnitTest/WebTier/MapAgent/MapAgentForms/moveresourceform.html	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/UnitTest/WebTier/MapAgent/MapAgentForms/moveresourceform.html	2009-08-28 16:08:13 UTC (rev 4196)
@@ -9,7 +9,7 @@
 <b>Operation:</b>
 <input type="text" name="OPERATION" value="MOVERESOURCE" size="50">
 <p> Version:
-<input type="text" name="VERSION" value="1.0.0" size="10">
+<input type="text" name="VERSION" value="2.2.0" size="10">
 <p> Locale:
 <input type="text" name="LOCALE" value="en" size="10">
 <p> Client Agent:
@@ -20,6 +20,8 @@
 <input type="text" name="DESTINATION" value="Library://Test/Sources/World2.FeatureSource" size="100">
 <p> Overwrite:
 <input type="text" name="OVERWRITE" value="0" size="10">
+<p> Cascade:
+<input type="text" name="CASCADE" value="1" size="10">
 <p>
 <input type="submit" value="Submit" onclick="SetActionTarget()"> <input type="reset">
 </form>

Modified: trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -48,6 +48,12 @@
     m_overwrite = ::atoi(MgUtil::WideCharToMultiByte(
         hrParam->GetParameterValue(
         MgHttpResourceStrings::reqOverwrite)).c_str()) != 0;
+
+    // In order to maintain backward compatibility, the Cascade flag
+    // will be set to false by default if it is not specified.
+    STRING cascadeParam = hrParam->GetParameterValue(MgHttpResourceStrings::reqCascade);
+
+    m_cascade = (!cascadeParam.empty() && 0 != MgUtil::StringToInt32(cascadeParam));
 }
 
 /// <summary>
@@ -76,7 +82,7 @@
     MgResourceIdentifier mgrDestIdentifier(m_destResourceId);
 
     // Run API command
-    mgprService->MoveResource(&mgrSourceIdentifier, &mgrDestIdentifier, m_overwrite);
+    mgprService->MoveResource(&mgrSourceIdentifier, &mgrDestIdentifier, m_overwrite, m_cascade);
 
     MG_HTTP_HANDLER_CATCH_AND_THROW_EX(L"MgHttpMoveResource.Execute")
 }

Modified: trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Web/src/HttpHandler/HttpMoveResource.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -47,6 +47,7 @@
     STRING m_sourceResourceId;
     STRING m_destResourceId;
     bool m_overwrite;
+    bool m_cascade;
 };
 
 #endif

Modified: trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.cpp	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.cpp	2009-08-28 16:08:13 UTC (rev 4196)
@@ -97,6 +97,7 @@
 const STRING MgHttpResourceStrings::reqOldDataName = L"OLDDATANAME";
 const STRING MgHttpResourceStrings::reqNewDataName = L"NEWDATANAME";
 const STRING MgHttpResourceStrings::reqOverwrite = L"OVERWRITE";
+const STRING MgHttpResourceStrings::reqCascade = L"CASCADE";
 const STRING MgHttpResourceStrings::reqPackage = L"PACKAGE";
 const STRING MgHttpResourceStrings::reqOwner = L"OWNER";
 const STRING MgHttpResourceStrings::reqIncludeDescendants = L"INCLUDEDESCENDANTS";

Modified: trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.h	2009-08-28 01:06:33 UTC (rev 4195)
+++ trunk/MgDev/Web/src/HttpHandler/HttpResourceStrings.h	2009-08-28 16:08:13 UTC (rev 4196)
@@ -101,6 +101,7 @@
     static const STRING reqOldDataName;
     static const STRING reqNewDataName;
     static const STRING reqOverwrite;
+    static const STRING reqCascade;
     static const STRING reqPackage;
     static const STRING reqOwner;
     static const STRING reqIncludeDescendants;



More information about the mapguide-commits mailing list