Source Code Cross Referenced for CCUnlock.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » clearcase » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs.optional.clearcase 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs.optional.clearcase;
020:
021:        import org.apache.tools.ant.BuildException;
022:        import org.apache.tools.ant.Project;
023:        import org.apache.tools.ant.taskdefs.Execute;
024:        import org.apache.tools.ant.types.Commandline;
025:
026:        /**
027:         * TODO:
028:         * comment field doesn't include all options yet
029:         */
030:
031:        /**
032:         * Performs a ClearCase Unlock command.
033:         *
034:         * <p>
035:         * The following attributes are interpreted:
036:         * <table border="1">
037:         *   <tr>
038:         *     <th>Attribute</th>
039:         *     <th>Values</th>
040:         *     <th>Required</th>
041:         *   </tr>
042:         *   <tr>
043:         *      <td>comment</td>
044:         *      <td>Specifies how to populate comments fields</td>
045:         *      <td>No</td>
046:         *   <tr>
047:         *   <tr>
048:         *      <td>pname</td>
049:         *      <td>Specifies the object pathname to be unlocked.</td>
050:         *      <td>No</td>
051:         *   <tr>
052:         *      <td>objselect</td>
053:         *      <td>This variable is obsolete. Should use <i>objsel</i> instead.</td>
054:         *      <td>no</td>
055:         *   <tr>
056:         *   <tr>
057:         *      <td>objsel</td>
058:         *      <td>Specifies the object(s) to be unlocked.</td>
059:         *      <td>No</td>
060:         *   <tr>
061:         *   <tr>
062:         *      <td>failonerr</td>
063:         *      <td>Throw an exception if the command fails. Default is true</td>
064:         *      <td>No</td>
065:         *   <tr>
066:         *
067:         * </table>
068:         *
069:         */
070:        public class CCUnlock extends ClearCase {
071:            private String mComment = null;
072:            private String mPname = null;
073:
074:            /**
075:             * Executes the task.
076:             * <p>
077:             * Builds a command line to execute cleartool and then calls Exec's run method
078:             * to execute the command line.
079:             * @throws BuildException if the command fails and failonerr is set to true
080:             */
081:            public void execute() throws BuildException {
082:                Commandline commandLine = new Commandline();
083:                Project aProj = getProject();
084:                int result = 0;
085:
086:                // Default the viewpath to basedir if it is not specified
087:                if (getViewPath() == null) {
088:                    setViewPath(aProj.getBaseDir().getPath());
089:                }
090:
091:                // build the command line from what we got the format is
092:                // cleartool lock [options...]
093:                // as specified in the CLEARTOOL.EXE help
094:                commandLine.setExecutable(getClearToolCommand());
095:                commandLine.createArgument().setValue(COMMAND_UNLOCK);
096:
097:                // Check the command line options
098:                checkOptions(commandLine);
099:
100:                // For debugging
101:                // System.out.println(commandLine.toString());
102:
103:                if (!getFailOnErr()) {
104:                    getProject().log(
105:                            "Ignoring any errors that occur for: "
106:                                    + getOpType(), Project.MSG_VERBOSE);
107:                }
108:                result = run(commandLine);
109:                if (Execute.isFailure(result) && getFailOnErr()) {
110:                    String msg = "Failed executing: " + commandLine.toString();
111:                    throw new BuildException(msg, getLocation());
112:                }
113:            }
114:
115:            /**
116:             * Check the command line options.
117:             */
118:            private void checkOptions(Commandline cmd) {
119:                // ClearCase items
120:                getCommentCommand(cmd);
121:
122:                if (getObjSelect() == null && getPname() == null) {
123:                    throw new BuildException("Should select either an element "
124:                            + "(pname) or an object (objselect)");
125:                }
126:                getPnameCommand(cmd);
127:                // object selector
128:                if (getObjSelect() != null) {
129:                    cmd.createArgument().setValue(getObjSelect());
130:                }
131:            }
132:
133:            /**
134:             * Sets how comments should be written
135:             * for the event record(s)
136:             *
137:             * @param comment comment method to use
138:             */
139:            public void setComment(String comment) {
140:                mComment = comment;
141:            }
142:
143:            /**
144:             * Get comment method
145:             *
146:             * @return String containing the desired comment method
147:             */
148:            public String getComment() {
149:                return mComment;
150:            }
151:
152:            /**
153:             * Sets the pathname to be locked
154:             *
155:             * @param pname pathname to be locked
156:             */
157:            public void setPname(String pname) {
158:                mPname = pname;
159:            }
160:
161:            /**
162:             * Get the pathname to be locked
163:             *
164:             * @return String containing the pathname to be locked
165:             */
166:            public String getPname() {
167:                return mPname;
168:            }
169:
170:            /**
171:             * Sets the object(s) to be locked
172:             *
173:             * @param objselect objects to be locked
174:             */
175:            public void setObjselect(String objselect) {
176:                setObjSelect(objselect);
177:            }
178:
179:            /**
180:             * Sets the object(s) to be locked
181:             *
182:             * @param objsel objects to be locked
183:             * @since ant 1.6.1
184:             */
185:            public void setObjSel(String objsel) {
186:                setObjSelect(objsel);
187:            }
188:
189:            /**
190:             * Get list of objects to be locked
191:             *
192:             * @return String containing the objects to be locked
193:             */
194:            public String getObjselect() {
195:                return getObjSelect();
196:            }
197:
198:            /**
199:             * Get the 'comment' command
200:             *
201:             * @param cmd containing the command line string with or without the
202:             *            comment flag and value appended
203:             */
204:            private void getCommentCommand(Commandline cmd) {
205:                if (getComment() == null) {
206:                    return;
207:                } else {
208:                    /* Had to make two separate commands here because if a space is
209:                       inserted between the flag and the value, it is treated as a
210:                       Windows filename with a space and it is enclosed in double
211:                       quotes ("). This breaks clearcase.
212:                     */
213:                    cmd.createArgument().setValue(FLAG_COMMENT);
214:                    cmd.createArgument().setValue(getComment());
215:                }
216:            }
217:
218:            /**
219:             * Get the 'pname' command
220:             *
221:             * @param cmd containing the command line string with or without the
222:             *            pname flag and value appended
223:             */
224:            private void getPnameCommand(Commandline cmd) {
225:                if (getPname() == null) {
226:                    return;
227:                } else {
228:                    /* Had to make two separate commands here because if a space is
229:                       inserted between the flag and the value, it is treated as a
230:                       Windows filename with a space and it is enclosed in double
231:                       quotes ("). This breaks clearcase.
232:                     */
233:                    cmd.createArgument().setValue(FLAG_PNAME);
234:                    cmd.createArgument().setValue(getPname());
235:                }
236:            }
237:
238:            /**
239:             * Return which object/pname is being operated on
240:             *
241:             * @return String containing the object/pname being worked on
242:             */
243:            private String getOpType() {
244:
245:                if (getPname() != null) {
246:                    return getPname();
247:                } else {
248:                    return getObjSelect();
249:                }
250:            }
251:
252:            /**
253:             * -comment flag -- method to use for commenting events
254:             */
255:            public static final String FLAG_COMMENT = "-comment";
256:            /**
257:             * -pname flag -- pathname to lock
258:             */
259:            public static final String FLAG_PNAME = "-pname";
260:        }
w__w___w_.___j___a___v___a___2__s_.__com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.