Application Programming Interface Guide > Web Services Operations > Operations Reference > copyResource
 
copyResource
Replicate the specified resource into an existing folder. This procedure allows the resource to be copied into a new location and renamed. Owner and security privileges remain the same in the new copy of the resource.
Note: This web services operation is different from the procedure of the same name, which is in the resource tree under /lib/resource.
Location
/services/webservices/system/admin/resource/operations/
Request Elements
path: The TDV source path, which is also known as the Resource Name for copying.
type: The type of the source resource to be copied. Valid TDV types are DATA_SOURCE, DEFINITION_SET, LINK, PROCEDURE, TABLE, TREE, and TRIGGER
targetContainerPath: The path of the target container to copy the resource into.
newName: The new name to call the copied resource.
copyMode: Controls behavior in the case where a resource exists with the same name and type in the container specified by newPath. This element can be one of the following:
ALTER_NAME_IF_EXISTS: If a resource of the same name and type of the source resource already exists in the target container, avoid conflicts by automatically generating a new name. Names are generated by appending a number to the end of the provided name.
FAIL_IF_EXISTS: Fails if a resource of the same name and type already exists in the target container. The resource are not copied if this occurs.
OVERWRITE_MERGE_IF_EXISTS: If a resource of the same name and type as the source resource already exists in the target container, overwrite the resource in the target container. If the source resource is a container, merge the contents of the source container with the corresponding resource in the target. All resources in the source container overwrite those resources with the same name in the target, but child resources in the target with different names are not overwritten and remain unaltered.
OVERWRITE_REPLACE_IF_EXISTS: If a resource of the same name and type of the source resource already exists in the target container, overwrite the resource in the target container. If the source resource is a container, replace the container within the target container with the source container. This is equivalent to deleting the container in the target before copying the source.
Response Elements
N/A
Faults
DuplicateName: If a resource in the target container exists with the same type as the source, same name as newName, and the copy mode is FAIL_IF_EXISTS.
IllegalArgument: If any of the given paths or types are malformed, or if the copyMode is not one of the legal values.
IllegalState: If the source resource is not allowed to be copied. Resources in /services/databases/system, /services/webservices/system, or within any physical data source, cannot be copied.
NotAllowed: If the source resource is not allowed to exist within the target container. Resources cannot be copied into a physical data source. LINK resources can only be copied into a RELATIONAL_DATA_SOURCE, SCHEMA, or a PORT under /services. Non-LINK resources cannot be copied into any location under /services.
NotFound: If the source resource or any portion of the new path does not exist.
Security: If the user does not have READ access on all items in the source path.
Security: If the user does not have READ access on the items in targetContainerPath other than the last item.
Security: If the user does not have WRITE access to the last item in targetContainerPath.
Security: If the user does not have WRITE access to a resource that is to be overwritten in one of the overwrite modes.
Security: If the user does not have the ACCESS_TOOLS right.