Creating a new resource

A resource is created by providing a location as an argument to a type-specific creation method.

Any properties that might be needed to create the resource, such as the stream for the activity, must be set in the proxy before calling the create method. You cannot create a resource with empty or invalid values for required properties. The failure occurs (as a WvcmException) when you call the doCreateResource() or doCreateGeneratedResource() method.

The Activity proxy (a2, in the following example) is constructed before the server-side object. For example:
CcStream stream = . . .;
CcActivity a2 = provider.ccActivity(provider.stpLocation("cc.activity:a_new_activity@\projects"));

// set the headline
a2.setHeadline("The new task");

// Set the stream
a2.setStream(stream);

// create the activity
a2.doCreateCcActivity(); 
A new resource (including a file-area private ControllableResource such as CcFile or CcDirectory) is constructed as follows:
  1. Determine the address for the new resource.
  2. Construct a Location object for that address by using one of the StpProvider.stpLocation() methods. Create a location for the resource by adding a child segment to the selected folder location.
  3. Obtain a proxy for that location from the provider. Construct a proxy whose object class matches the type of the new resource by using the appropriate Provider proxy factory method.
  4. Populate the proxy with any property values required or appropriate for the new resource. Establish the initial values for the resource properties that can be set by using the set methods on the new proxy.
  5. Invoke the create-resource operation (doCreateResource method) on the proxy, which returns a proxy for the newly created resource that contains any property values requested in the create-resource operation.