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

CCMklabel

public class CCMklabel extends ClearCase
Task to perform mklabel command to ClearCase.

The following attributes are interpreted:
Attribute Values Required
viewpath Path to the ClearCase view file or directory that the command will operate on No
replace Replace a label of the same type on the same branch No
recurse Process each subdirectory under viewpath No
version Identify a specific version to attach the label to No
typename Name of the label type Yes
vob Name of the VOB No
comment Specify a comment. Only one of comment or cfile may be used. No
commentfile Specify a file containing a comment. Only one of comment or cfile may be used. No
failonerr Throw an exception if the command fails. Default is true No

Fields Summary
private boolean
mReplace
private boolean
mRecurse
private String
mVersion
private String
mTypeName
private String
mVOB
private String
mComment
private String
mCfile
public static final String
FLAG_REPLACE
-replace flag -- replace another label of the same type
public static final String
FLAG_RECURSE
-recurse flag -- process all subdirectories
public static final String
FLAG_VERSION
-version flag -- attach label to specified version
public static final String
FLAG_COMMENT
-c flag -- comment to attach to the file
public static final String
FLAG_COMMENTFILE
-cfile flag -- file containing a comment to attach to the file
public static final String
FLAG_NOCOMMENT
-nc flag -- no comment is specified
Constructors Summary
Methods Summary
private voidcheckOptions(org.apache.tools.ant.types.Commandline cmd)
Check the command line options.

        if (getReplace()) {
            // -replace
            cmd.createArgument().setValue(FLAG_REPLACE);
        }

        if (getRecurse()) {
            // -recurse
            cmd.createArgument().setValue(FLAG_RECURSE);
        }

        if (getVersion() != null) {
            // -version
            getVersionCommand(cmd);
        }

        if (getComment() != null) {
            // -c
            getCommentCommand(cmd);
        } else {
            if (getCommentFile() != null) {
                // -cfile
                getCommentFileCommand(cmd);
            } else {
                cmd.createArgument().setValue(FLAG_NOCOMMENT);
            }
        }

        if (getTypeName() != null) {
            // type
            getTypeCommand(cmd);
        }

        // viewpath
        cmd.createArgument().setValue(getViewPath());
    
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;

        // Check for required attributes
        if (getTypeName() == null) {
            throw new BuildException("Required attribute TypeName not specified");
        }

        // 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 mklabel [options...] [viewpath ...]
        // as specified in the CLEARTOOL help
        commandLine.setExecutable(getClearToolCommand());
        commandLine.createArgument().setValue(COMMAND_MKLABEL);

        checkOptions(commandLine);

        if (!getFailOnErr()) {
            getProject().log("Ignoring any errors that occur for: "
                    + getViewPathBasename(), 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 string

return
String containing the comment

        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 string appended

        if (getComment() != null) {
            /* 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.StringgetCommentFile()
Get comment file

return
String containing the path to the comment file

        return mCfile;
    
private voidgetCommentFileCommand(org.apache.tools.ant.types.Commandline cmd)
Get the 'commentfile' command

param
cmd containing the command line string with or without the commentfile flag and file appended

        if (getCommentFile() != null) {
            /* 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_COMMENTFILE);
            cmd.createArgument().setValue(getCommentFile());
        }
    
public booleangetRecurse()
Get recurse flag status

return
boolean containing status of recurse flag

        return mRecurse;
    
public booleangetReplace()
Get replace flag status

return
boolean containing status of replace flag

        return mReplace;
    
private voidgetTypeCommand(org.apache.tools.ant.types.Commandline cmd)
Get the type-name

param
cmd containing the command line string with or without the type-name

        String typenm = null;

        if (getTypeName() != null) {
            typenm = getTypeName();
            if (getVOB() != null) {
                typenm += "@" + getVOB();
            }
            cmd.createArgument().setValue(typenm);
        }
    
public java.lang.StringgetTypeName()
Get type-name

return
String containing type name

        return mTypeName;
    
public java.lang.StringgetVOB()
Get VOB name

return
String containing VOB name

        return mVOB;
    
public java.lang.StringgetVersion()
Get version flag status

return
boolean containing status of version flag

        return mVersion;
    
private voidgetVersionCommand(org.apache.tools.ant.types.Commandline cmd)
Get the 'version' command

param
cmd CommandLine containing the command line string with or without the version flag and string appended

        if (getVersion() != null) {
            /* 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_VERSION);
            cmd.createArgument().setValue(getVersion());
        }
    
public voidsetComment(java.lang.String comment)
Set comment string

param
comment the comment string

        mComment = comment;
    
public voidsetCommentFile(java.lang.String cfile)
Set comment file

param
cfile the path to the comment file

        mCfile = cfile;
    
public voidsetRecurse(boolean recurse)
Set recurse flag

param
recurse the status to set the flag to

        mRecurse = recurse;
    
public voidsetReplace(boolean replace)
Set the replace flag

param
replace the status to set the flag to

        mReplace = replace;
    
public voidsetTypeName(java.lang.String tn)
Set the type-name

param
tn the type name

        mTypeName = tn;
    
public voidsetVOB(java.lang.String vob)
Set the VOB name

param
vob the VOB name

        mVOB = vob;
    
public voidsetVersion(java.lang.String version)
Set the version flag

param
version the status to set the flag to

        mVersion = version;