FileDocCategorySizeDatePackage
CCRmtype.javaAPI DocApache Ant 1.7010351Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.clearcase

CCRmtype

public class CCRmtype extends ClearCase
Task to perform rmtype command to ClearCase.

The following attributes are interpreted:
Attribute Values Required
typekind The kind of type to create. Valid types are:
attype attribute type
brtype branch type
eltype element type
hltype hyperlink type
lbtype label type
trtype trigger type
Yes
typename The name of the type to remove Yes
vob Name of the VOB No
ignore Used with trigger types only. Forces removal of trigger type even if a pre-operation trigger would prevent its removal No
rmall Removes all instances of a type and the type object itself 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
mTypeKind
private String
mTypeName
private String
mVOB
private String
mComment
private String
mCfile
private boolean
mRmall
private boolean
mIgnore
public static final String
FLAG_IGNORE
-ignore flag -- ignore pre-trigger operations when removing a trigger type
public static final String
FLAG_RMALL
-rmall flag -- removes all instances of a type and the type object itself
public static final String
FLAG_FORCE
-force flag -- suppresses confirmation prompts
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 (getIgnore()) {
            // -ignore
            cmd.createArgument().setValue(FLAG_IGNORE);
        }
        if (getRmAll()) {
            // -rmall -force
            cmd.createArgument().setValue(FLAG_RMALL);
            cmd.createArgument().setValue(FLAG_FORCE);
        }
        if (getComment() != null) {
            // -c
            getCommentCommand(cmd);
        } else {
            if (getCommentFile() != null) {
                // -cfile
                getCommentFileCommand(cmd);
            } else {
                cmd.createArgument().setValue(FLAG_NOCOMMENT);
            }
        }

        // type-kind:type-name
        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 (getTypeKind() == null) {
            throw new BuildException("Required attribute TypeKind not specified");
        }
        if (getTypeName() == null) {
            throw new BuildException("Required attribute TypeName not specified");
        }

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

        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 booleangetIgnore()
Get ignore flag status

return
boolean containing status of ignore flag

        return mIgnore;
    
public booleangetRmAll()
Get rmall flag status

return
boolean containing status of rmall flag

        return mRmall;
    
public java.lang.StringgetTypeKind()
Get type-kind string

return
String containing the type-kind

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

return
String containing the type-name

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

return
the 'type-kind:type-name@vob' specifier

        String tkind = getTypeKind();
        String tname = getTypeName();
        String typeSpec = null;

        // Return the type-selector
        typeSpec = tkind + ":" + tname;
        if (getVOB() != null) {
            typeSpec += "@" + getVOB();
        }
        return typeSpec;
    
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 voidsetIgnore(boolean ignore)
Set the ignore flag

param
ignore the status to set the flag to

        mIgnore = ignore;
    
public voidsetRmAll(boolean rmall)
Set rmall flag

param
rmall the status to set the flag to

        mRmall = rmall;
    
public voidsetTypeKind(java.lang.String tk)
Set type-kind string

param
tk the type-kind string

        mTypeKind = tk;
    
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;