MapGuide API Reference
 All Classes Functions Variables Enumerations Enumerator Friends
virtual void MgResourceService::MoveResource ( MgResourceIdentifier sourceResource,
MgResourceIdentifier destResource,
bool  overwrite,
bool  cascade 
) [virtual]

Moves an existing resource to another location.

Remarks:
You can also use this method to rename a resource.
.NET Syntax
virtual void MoveResource(MgResourceIdentifier sourceResource, MgResourceIdentifier destResource, bool overwrite, bool cascade);
Java Syntax
virtual void MoveResource(MgResourceIdentifier sourceResource, MgResourceIdentifier destResource, boolean overwrite, boolean cascade);
PHP Syntax
virtual void MoveResource(MgResourceIdentifier sourceResource, MgResourceIdentifier destResource, bool overwrite, bool cascade);
Parameters:
sourceResource(MgResourceIdentifier) Resource to be moved. This can be a document or folder.
  • If it is a folder, this method also moves the contents of the folder and all folders below it.
  • If it is a folder, you must include the trailing slash in the identifier.
destResource(MgResourceIdentifier) Where the resource should be moved to.
overwrite(boolean/bool) Flag to determine whether or not the destination resource should be overwritten if it exists.
cascade(boolean/bool) Flag to determine whether or not the referencing resources should be updated.
Returns:
Returns nothing.
Example (PHP)
This example moves the file Library://Geography/World.MapDefinition to Library://Atlas/Oceans.MapDefinition:

 // 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);

This example moves the folder Library://Geography/ to Library://World Geography/:

 $oldPath = new MgResourceIdentifier("Library://Geography/");
 $newPath = new MgResourceIdentifier("Library://World Geography/");
 $resourceService->MoveResource($oldPath, $newPath, true, true);

This example renames Oceans.MapDefinition to Pacific Ocean.MapDefinition:

 /**************************************************************************/
 $oldPath = new MgResourceIdentifier("Library://Atlas/Oceans.MapDefinition");
 $newPath = new MgResourceIdentifier("Library://Atlas/Pacific Ocean.MapDefinition");
 $resourceService->MoveResource($oldPath, $newPath, true, false);
Exceptions:
MgResourceNotFoundException
MgDuplicateResourceException
MgInvalidRepositoryTypeException
MgInvalidRepositoryNameException
MgInvalidResourcePathException
MgInvalidResourceNameException
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.
Since:
2.2