Creating
Resources
When you create a resource, you use the methods offered by the ICollection interface. This is necessary because only a collection can contain a resource. The collection where you invoke the create()method becomes the parent collection of the new resource.
ICollection methods for creating a resource are:
Method |
Description |
createResource() |
Creates a resource with content and properties |
createCollection() |
Creates a collection with properties |
createLink() |
Creates a link with target, link type and properties |
The code extract below shows how to create a resource, a collection and link. It:
IResourceContext context = new ResourceContext(user);
RID rid = RID.getRid(″/documents″);
ICollection parent = (ICollection)ResourceFactory.getInstance()
.getResource(rid, context);
IResource resource = parent.createResource(″file″, null, null);
ICollection collection = parent.createCollection(″folder″, null);
ILink link = parent.createLink(″link″, ″/documents/file″, LinkType.INTERNAL, null);