Show TOC Start of Content Area

Syntax documentation Copying, Moving and Deleting Resources Locate the document in its SAP Library structure

To copy, rename or delete a resource, you use the IResource interface. The methods available for these operations are shown in the table:

Method

Purpose

copy()

Copies the resource. It requires the destination RID and an optional ICopyParameter as arguments. The parameter is a descriptor that can supply additional options for the copy operation, for example, to specify that children must be copied recursively.

delete()

Deletes the resource, collection or link. When the collection is deleted, all its children are also deleted.

move()

Moves the resource to another parent collection. It requires the same arguments as the copy() method.

rename()

Moves the resource to another parent collection. It requires the  same parameters as the copy() method.

 

The code extract below shows how to copy, move, rename and delete a resource. It:

     Copies /documents/file to /documents/copy

     Moves /documents/copy to /documents/folder/copy

     Renames /documents/folder/copyto /documents/folder/renamed.

     Deletes the renamed resource

 

IResourceContext context = new ResourceContext(user);
IResource resource = ResourceFactory.getInstance()
                     .getResource(″/documents/file″, context);
IResource copied = resource.copy(RID.getRID(″/documents/copy″), null);
IResource moved = copied.move(RID.getRID(″/documents/folder″), null);
IResource renamed = moved.rename(″renamed″);
renamed.delete();

Note

When delete() is called, all the IResource objects in the example above are invalidated because they all reference the same resource. The resource only exists once. After the deletion of renamed, calling copied.delete() or moved.delete() throws a ResourceException.

End of Content Area