The CM API distinguishes between a CcFile, which is the file in a view through which the above operations are performed, from the underlying ClearCase element and version (CcElement and CcVersion) it is associated with.
The CcFile.doVersionControl() method creates a CcElement resource and an initial CcVersion resource, which will have the same contents as the CcFile.
// Get the ClearCase provider.
CcProvider provider = ...;
// Create a CcFile proxy for the file to be checked out.
// First, create a plain old Java "File" instance from the file's path.
// Then create an StpLocation instance from that file.
// Finally, create a CcFile proxy from the location.
File file = new File("C:/my_views/example_view/avob/example.txt");
StpLocation fileLoc = provider.filePathLocation(Domain.CLEAR_CASE, file);
CcFile testFile = provider.ccFile(fileLoc);
// Create a property request for the file's properties that we're
// interested in. Read those properties. Note that the resulting
// property values are available *only* in the CcFile proxy returned by
// doReadProperties(), not in the original proxy.
PropertyRequest wantedProps = new PropertyRequest(
CcFile.IS_VERSION_CONTROLLED,
CcFile.IS_CHECKED_OUT);
testFile = (CcFile) testFile.doReadProperties(wantedProps);
if ( ! testFile.getIsVersionControlled()) {
// The file is not yet under version control, so control it.
// At the same time, re-read the properties we're interested in.
testFile = (CcFile) testFile.doVersionControl(wantedProps);
}
if ( ! testFile.getIsCheckedOut()) {
// The file is not yet checked out, so check it out.
// At the same time, re-read the properties we're interested in.
testFile = testFile.doCcCheckout(null, wantedProps);
}
// Verify that the file is now version controlled and checked out.
assert(testFile.getIsVersionControlled() == true);
assert(testFile.getIsCheckedOut() == true);
Certain operations on resources in a local Web view may or may not interact with a server. For example:
The Resource interface itself does not supply a method for creating the underlying resource, because some resources cannot be created by the user. Note the distinction between creating the proxy, which is a matter of instantiating a Resource object, and creating the resource, which must be done by calling the doCreateResource() or doCreateVersionControlledResource() method.