Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1974 jgill 1
package com.erggroup.mass.ant.taskdefs;
2
 
3
import net.sourceforge.clearcase.api.IClearcase;
4
import net.sourceforge.clearcase.simple.ClearcaseCLI;
5
import org.apache.tools.ant.BuildException;
6
import org.apache.tools.ant.Project;
7
 
8
/**
9
 *
10
 */
11
public class CCRemoveView extends org.apache.tools.ant.Task
12
{
13
	/**
14
	 * The view name to remove
15
	 */
16
	private String viewname;
17
 
18
	/**
19
	 * Drive letter to unmap (optional)
20
	 */
21
	private String unmap;
22
 
23
	public void setViewname( String value )
24
	{
25
		this.viewname = value;
26
	}
27
 
28
	public void setUnmap( String value )
29
	{
30
		this.unmap = value;
31
	}
32
 
33
	public void execute() throws BuildException
34
	{
35
		// Remove network drive mapping (if any)
36
		try
37
		{
38
			if ( unmap != null )
39
			{
40
				Process p = Runtime.getRuntime().exec("subst " + unmap + " /D");
41
				int rv = p.waitFor();
42
			}
43
		}
44
		catch ( Exception x )
45
		{
46
			project.log(x.getMessage(),Project.MSG_ERR);
47
		}
48
 
49
		IClearcase clearcase = new ClearcaseCLI();
50
		IClearcase.Status rmview = clearcase.cleartool( "rmview -tag \"" + viewname + "\"");
51
		if ( ! rmview.status )
52
		{
53
			project.log("The view \'" + viewname + "\' could not be removed; you should remove this view manually.",Project.MSG_WARN);
54
			throw new BuildException("Could not remove view \'" + viewname + "\'.\nThe view may not exist.");
55
		}
56
		else
57
		{
58
			project.log("Successfully removed view '" + viewname + "'.",Project.MSG_INFO);
59
		}
60
	}
61
}