FileDocCategorySizeDatePackage
CCLock.javaAPI DocApache Ant 1.7010516Wed Dec 13 06:16:24 GMT 2006org.apache.tools.ant.taskdefs.optional.clearcase

CCLock

public class CCLock extends ClearCase
Performs a ClearCase Lock command.

The following attributes are interpreted:
Attribute Values Required
replace Specifies replacing an existing lock No
nusers Specifies user(s) who can still modify the object/pname No
obsolete Specifies that the object/pname should be marked obsolete No
comment Specifies how to populate comments fields No
pname Specifies the pathname to be locked. No
objselect This variable is obsolete. Should use objsel instead. No
objsel Specifies the object(s) to be unlocked. No
failonerr Throw an exception if the command fails. Default is true No

Fields Summary
private boolean
mReplace
private boolean
mObsolete
private String
mComment
private String
mNusers
private String
mPname
private String
mObjselect
public static final String
FLAG_REPLACE
-replace flag -- replace existing lock on object(s)
public static final String
FLAG_NUSERS
-nusers flag -- list of users to exclude from lock
public static final String
FLAG_OBSOLETE
-obsolete flag -- mark locked object as obsolete
public static final String
FLAG_COMMENT
-comment flag -- method to use for commenting events
public static final String
FLAG_PNAME
-pname flag -- pathname to lock
Constructors Summary
Methods Summary
private voidcheckOptions(org.apache.tools.ant.types.Commandline cmd)
Check the command line options.

        // ClearCase items
        if (getReplace()) {
            // -replace
            cmd.createArgument().setValue(FLAG_REPLACE);
        }
        if (getObsolete()) {
            // -obsolete
            cmd.createArgument().setValue(FLAG_OBSOLETE);
        } else {
            getNusersCommand(cmd);
        }
        getCommentCommand(cmd);

        if (getObjselect() == null && getPname() == null) {
            throw new BuildException("Should select either an element "
            + "(pname) or an object (objselect)");
        }
        getPnameCommand(cmd);
        // object selector
        if (getObjselect() != null) {
            cmd.createArgument().setValue(getObjselect());
        }
public voidexecute()
Executes the task.

Builds a command line to execute cleartool and then calls Exec's run method to execute the command line.

throws
BuildException if the command fails and failonerr is set to true


                                           
         
        Commandline commandLine = new Commandline();
        Project aProj = getProject();
        int result = 0;

        // Default the viewpath to basedir if it is not specified
        if (getViewPath() == null) {
            setViewPath(aProj.getBaseDir().getPath());
        }

        // build the command line from what we got the format is
        // cleartool lock [options...]
        // as specified in the CLEARTOOL.EXE help
        commandLine.setExecutable(getClearToolCommand());
        commandLine.createArgument().setValue(COMMAND_LOCK);

        // Check the command line options
        checkOptions(commandLine);

        // For debugging
        // System.out.println(commandLine.toString());

        if (!getFailOnErr()) {
            getProject().log("Ignoring any errors that occur for: "
                    + getOpType(), Project.MSG_VERBOSE);
        }
        result = run(commandLine);
        if (Execute.isFailure(result) && getFailOnErr()) {
            String msg = "Failed executing: " + commandLine.toString();
            throw new BuildException(msg, getLocation());
        }
    
public java.lang.StringgetComment()
Get comment method

return
String containing the desired comment method

        return mComment;
    
private voidgetCommentCommand(org.apache.tools.ant.types.Commandline cmd)
Get the 'comment' command

param
cmd containing the command line string with or without the comment flag and value appended

        if (getComment() == null) {
            return;
        } else {
            /* Had to make two separate commands here because if a space is
               inserted between the flag and the value, it is treated as a
               Windows filename with a space and it is enclosed in double
               quotes ("). This breaks clearcase.
            */
            cmd.createArgument().setValue(FLAG_COMMENT);
            cmd.createArgument().setValue(getComment());
        }
    
public java.lang.StringgetNusers()
Get nusers list

return
String containing the list of users excluded from lock

        return mNusers;
    
private voidgetNusersCommand(org.apache.tools.ant.types.Commandline cmd)
Get the 'nusers' command

param
cmd containing the command line string with or without the nusers flag and value appended

        if (getNusers() == null) {
            return;
        } else {
            /* Had to make two separate commands here because if a space is
               inserted between the flag and the value, it is treated as a
               Windows filename with a space and it is enclosed in double
               quotes ("). This breaks clearcase.
            */
            cmd.createArgument().setValue(FLAG_NUSERS);
            cmd.createArgument().setValue(getNusers());
        }
    
public java.lang.StringgetObjselect()
Get list of objects to be locked

return
String containing the objects to be locked

        return mObjselect;
    
public booleangetObsolete()
Get obsolete flag status

return
boolean containing status of obsolete flag

        return mObsolete;
    
private java.lang.StringgetOpType()
Return which object/pname is being operated on

return
String containing the object/pname being worked on


        if (getPname() != null) {
            return getPname();
        } else {
            return getObjselect();
        }
    
public java.lang.StringgetPname()
Get the pathname to be locked

return
String containing the pathname to be locked

        return mPname;
    
private voidgetPnameCommand(org.apache.tools.ant.types.Commandline cmd)
Get the 'pname' command

param
cmd containing the command line string with or without the pname flag and value appended

        if (getPname() == null) {
            return;
        } else {
            /* Had to make two separate commands here because if a space is
               inserted between the flag and the value, it is treated as a
               Windows filename with a space and it is enclosed in double
               quotes ("). This breaks clearcase.
            */
            cmd.createArgument().setValue(FLAG_PNAME);
            cmd.createArgument().setValue(getPname());
        }
    
public booleangetReplace()
Get replace flag status

return
boolean containing status of replace flag

        return mReplace;
    
public voidsetComment(java.lang.String comment)
Sets how comments should be written for the event record(s)

param
comment comment method to use

        mComment = comment;
    
public voidsetNusers(java.lang.String nusers)
Sets the users who may continue to edit the object while it is locked.

param
nusers users excluded from lock

        mNusers = nusers;
    
public voidsetObjSel(java.lang.String objsel)
Sets the object(s) to be locked

param
objsel objects to be locked
since
ant 1.6.1

        mObjselect = objsel;
    
public voidsetObjselect(java.lang.String objselect)
Sets the object(s) to be locked

param
objselect objects to be locked

        mObjselect = objselect;
    
public voidsetObsolete(boolean obsolete)
If true, mark object as obsolete.

param
obsolete the status to set the flag to

        mObsolete = obsolete;
    
public voidsetPname(java.lang.String pname)
Sets the pathname to be locked

param
pname pathname to be locked

        mPname = pname;
    
public voidsetReplace(boolean replace)
If true, replace an existing lock.

param
replace the status to set the flag to

        mReplace = replace;