FileDocCategorySizeDatePackage
CCMklbtype.javaAPI DocApache Ant 1.7011771Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs.optional.clearcase

CCMklbtype

public class CCMklbtype extends ClearCase
Task to perform mklbtype command to ClearCase.

The following attributes are interpreted:
Attribute Values Required
typename Name of the label type to create Yes
vob Name of the VOB No
replace Replace an existing label definition of the same type No
global Either global or ordinary can be specified, not both. Creates a label type that is global to the VOB or to VOBs that use this VOB No
ordinary Either global or ordinary can be specified, not both. Creates a label type that can be used only in the current VOB. Default No
pbranch Allows the label type to be used once per branch in a given element's version tree No
shared Sets the way mastership is checked by ClearCase. See ClearCase documentation for details 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 String
mTypeName
private String
mVOB
private String
mComment
private String
mCfile
private boolean
mReplace
private boolean
mGlobal
private boolean
mOrdinary
private boolean
mPbranch
private boolean
mShared
public static final String
FLAG_REPLACE
-replace flag -- replace existing label definition of the same type
public static final String
FLAG_GLOBAL
-global flag -- creates a label type that is global to the VOB or to VOBs that use this VOB
public static final String
FLAG_ORDINARY
-ordinary flag -- creates a label type that can be used only in the current VOB
public static final String
FLAG_PBRANCH
-pbranch flag -- allows label type to be used once per branch
public static final String
FLAG_SHARED
-shared flag -- sets the way mastership is checked by ClearCase
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 (getOrdinary()) {
            // -ordinary
            cmd.createArgument().setValue(FLAG_ORDINARY);
        } else {
            if (getGlobal()) {
                // -global
                cmd.createArgument().setValue(FLAG_GLOBAL);
            }
        }

        if (getPbranch()) {
            // -pbranch
            cmd.createArgument().setValue(FLAG_PBRANCH);
        }

        if (getShared()) {
            // -shared
            cmd.createArgument().setValue(FLAG_SHARED);
        }

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

        // type-name@vob
        cmd.createArgument().setValue(getTypeSpecifier());
    
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();
        int result = 0;

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

        // build the command line from what we got. the format is
        // cleartool mklbtype [options...] type-selector...
        // as specified in the CLEARTOOL help
        commandLine.setExecutable(getClearToolCommand());
        commandLine.createArgument().setValue(COMMAND_MKLBTYPE);

        checkOptions(commandLine);

        if (!getFailOnErr()) {
            getProject().log("Ignoring any errors that occur for: "
                    + getTypeSpecifier(), 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 booleangetGlobal()
Get global flag status

return
boolean containing status of global flag

        return mGlobal;
    
public booleangetOrdinary()
Get ordinary flag status

return
boolean containing status of ordinary flag

        return mOrdinary;
    
public booleangetPbranch()
Get pbranch flag status

return
boolean containing status of pbranch flag

        return mPbranch;
    
public booleangetReplace()
Get replace flag status

return
boolean containing status of replace flag

        return mReplace;
    
public booleangetShared()
Get shared flag status

return
boolean containing status of shared flag

        return mShared;
    
public java.lang.StringgetTypeName()
Get type-name string

return
String containing the type-name

        return mTypeName;
    
private java.lang.StringgetTypeSpecifier()
Get the type-name specifier

return
the 'type-name-specifier' command if the attribute was specified, otherwise an empty string

        String typenm = null;

        typenm = getTypeName();
        if (getVOB() != null) {
            typenm += "@" + getVOB();
        }

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

return
String containing VOB name

        return mVOB;
    
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 voidsetGlobal(boolean glob)
Set the global flag

param
glob the status to set the flag to

        mGlobal = glob;
    
public voidsetOrdinary(boolean ordinary)
Set the ordinary flag

param
ordinary the status to set the flag to

        mOrdinary = ordinary;
    
public voidsetPbranch(boolean pbranch)
Set the pbranch flag

param
pbranch the status to set the flag to

        mPbranch = pbranch;
    
public voidsetReplace(boolean repl)
Set the replace flag

param
repl the status to set the flag to

        mReplace = repl;
    
public voidsetShared(boolean shared)
Set the shared flag

param
shared the status to set the flag to

        mShared = shared;
    
public voidsetTypeName(java.lang.String tn)
Set type-name string

param
tn the type-name string

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

param
vob the VOB name

        mVOB = vob;