CcFile 和 CcDirectory 代理方法

CcFile 或 CcDirectory 资源表示 Rational® ClearCase® 视图(CcView)中的文件或目录。这些资源处于源控制之下或可以使其处于源控制之下。CcFile 和 CcDirectory 是 Cm API 的特定于 ClearCase 的扩展。CcFile 将扩展 ControllableResource 接口,而 CcDirectory 将扩展 ControllableFolder 接口。CcFile 支持多种方法,如:

CM API 用于区别 CcFile(它是视图中的文件,用于执行上述操作)和与其相关联的底层 ClearCase 元素和版本(CcElement 和 CcVersion)。

CcFile.doVersionControl() 方法将创建 CcElement 资源和初始的 CcVersion 资源,它们将与 CcFile 具有相同的内容。

以下代码段为文件区域中的已知文件构建 CcFile 代理并检出该文件。在检出操作之前和之后都需要检查 IS_CHECKED_OUT 属性。
 // 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);

对本地 Web 视图中资源的特定操作可以与服务器交互。例如:

Resource 接口本身不提供创建底层资源的方法,因为某些资源不能由用户创建。请注意创建代理与创建资源之间的区别,前者是实例化 Resource 对象,而后者必须通过调用 doCreateResource()doCreateVersionControlledResource() 方法才能完成。


反馈