CM API は、CcFile (上記の操作の実行に使用されるビュー内のファイル) を、それが関連づけられている、基礎となる ClearCase エレメントとバージョン (CcElement and CcVersion) から区別します。
CcFile.doVersionControl() メソッドは、CcElement リソースと初期の CcVersion リソースを作成します。これは 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);
ローカル Web ビュー内のリソースに対する操作によっては、サーバーとの対話がある場合とない場合があります。 例を次に示します。
Resource インターフェイス自体は、基本リソース作成用のメソッドを提供しません。一部のリソースは、ユーザーが作成することができないためです。 プロキシの作成とリソースの作成の違いに注意してください。プロキシの作成は、Resource オブジェクトのインスタンス化に関するものであり、リソースの作成は doCreateResource() メソッド、または doCreateVersionControlledResource() メソッドを呼び出すことで実行される必要があります。