001 /* 002 * file CheckoutDemo.java 003 * 004 * Licensed Materials - Property of IBM 005 * Restricted Materials of IBM - you are allowed to copy, modify and 006 * redistribute this file as part of any program that interfaces with 007 * IBM Rational CM API. 008 * 009 * com.ibm.rational.stp.client.samples.CheckoutDemo 010 * 011 * (C) Copyright IBM Corporation 2007, 2008. All Rights Reserved. 012 * Note to U.S. Government Users Restricted Rights: Use, duplication or 013 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 014 */ 015 016 package com.ibm.rational.stp.client.samples.cc; 017 018 import javax.wvcm.PropertyRequestItem.PropertyRequest; 019 020 import com.ibm.rational.wvcm.stp.cc.CcFile; 021 022 /** 023 * Checkout a file in a web view. 024 * Demonstrates basic web view operations. 025 */ 026 public class CheckoutDemo extends CcDemoBase { 027 028 public void testSimpleCheckout() throws Exception { 029 030 ViewHelper viewHelper = ViewHelper.getNonUcmViewHelper(this); 031 032 // Create a version controlled file we can work with 033 CcFile demoFile = viewHelper.createDemoFile("CheckoutDemo.txt", true/*version controlled*/); 034 035 // Fetch the demo file. 036 // This file should already exist, should be loaded in this web view, 037 // should be version controlled, and should be checked in. 038 // Verify that by reading the file's properties. 039 trace("Got demo file: " + demoFile.clientResourceFile()); 040 041 PropertyRequest wantedProps = new PropertyRequest( 042 CcFile.LOAD_STATE, 043 CcFile.IS_VERSION_CONTROLLED, 044 CcFile.IS_CHECKED_OUT); 045 046 demoFile = (CcFile) demoFile.doReadProperties(wantedProps); 047 assertEquals(CcFile.LoadState.LOADED, demoFile.getLoadState()); 048 assertTrue(demoFile.getIsVersionControlled()); 049 assertFalse(demoFile.getIsCheckedOut()); 050 051 // Check out the demo file. 052 // As part of the checkout operation, ask for the file's checkout-related 053 // properties so we can verify that the operation succeeded. 054 trace("Checking out demo file: " + demoFile.clientResourceFile()); 055 demoFile = (CcFile) demoFile.doCheckout(null, wantedProps); 056 assertTrue(demoFile.getIsCheckedOut()); 057 } 058 }