Source Code Cross Referenced for CCLock.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 Lock 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>replace</td>
044:         *      <td>Specifies replacing an existing lock</td>
045:         *      <td>No</td>
046:         *   <tr>
047:         *   <tr>
048:         *      <td>nusers</td>
049:         *      <td>Specifies user(s) who can still modify the object/pname</td>
050:         *      <td>No</td>
051:         *   <tr>
052:         *   <tr>
053:         *      <td>obsolete</td>
054:         *      <td>Specifies that the object/pname should be marked obsolete</td>
055:         *      <td>No</td>
056:         *   <tr>
057:         *   <tr>
058:         *      <td>comment</td>
059:         *      <td>Specifies how to populate comments fields</td>
060:         *      <td>No</td>
061:         *   <tr>
062:         *   <tr>
063:         *      <td>pname</td>
064:         *      <td>Specifies the pathname to be locked.</td>
065:         *      <td>No</td>
066:         *   <tr>
067:         *      <td>objselect</td>
068:         *      <td>This variable is obsolete. Should use <i>objsel</i> instead.</td>
069:         *      <td>No</td>
070:         *   <tr>
071:         *   <tr>
072:         *      <td>objsel</td>
073:         *      <td>Specifies the object(s) to be unlocked.</td>
074:         *      <td>No</td>
075:         *   <tr>
076:         *   <tr>
077:         *      <td>failonerr</td>
078:         *      <td>Throw an exception if the command fails. Default is true</td>
079:         *      <td>No</td>
080:         *   <tr>
081:         * </table>
082:         *
083:         */
084:        public class CCLock extends ClearCase {
085:            private boolean mReplace = false;
086:            private boolean mObsolete = false;
087:            private String mComment = null;
088:            private String mNusers = null;
089:            private String mPname = null;
090:            private String mObjselect = null;
091:
092:            /**
093:             * Executes the task.
094:             * <p>
095:             * Builds a command line to execute cleartool and then calls Exec's run method
096:             * to execute the command line.
097:             * @throws BuildException if the command fails and failonerr is set to true
098:             */
099:            public void execute() throws BuildException {
100:                Commandline commandLine = new Commandline();
101:                Project aProj = getProject();
102:                int result = 0;
103:
104:                // Default the viewpath to basedir if it is not specified
105:                if (getViewPath() == null) {
106:                    setViewPath(aProj.getBaseDir().getPath());
107:                }
108:
109:                // build the command line from what we got the format is
110:                // cleartool lock [options...]
111:                // as specified in the CLEARTOOL.EXE help
112:                commandLine.setExecutable(getClearToolCommand());
113:                commandLine.createArgument().setValue(COMMAND_LOCK);
114:
115:                // Check the command line options
116:                checkOptions(commandLine);
117:
118:                // For debugging
119:                // System.out.println(commandLine.toString());
120:
121:                if (!getFailOnErr()) {
122:                    getProject().log(
123:                            "Ignoring any errors that occur for: "
124:                                    + getOpType(), Project.MSG_VERBOSE);
125:                }
126:                result = run(commandLine);
127:                if (Execute.isFailure(result) && getFailOnErr()) {
128:                    String msg = "Failed executing: " + commandLine.toString();
129:                    throw new BuildException(msg, getLocation());
130:                }
131:            }
132:
133:            /**
134:             * Check the command line options.
135:             */
136:            private void checkOptions(Commandline cmd) {
137:                // ClearCase items
138:                if (getReplace()) {
139:                    // -replace
140:                    cmd.createArgument().setValue(FLAG_REPLACE);
141:                }
142:                if (getObsolete()) {
143:                    // -obsolete
144:                    cmd.createArgument().setValue(FLAG_OBSOLETE);
145:                } else {
146:                    getNusersCommand(cmd);
147:                }
148:                getCommentCommand(cmd);
149:
150:                if (getObjselect() == null && getPname() == null) {
151:                    throw new BuildException("Should select either an element "
152:                            + "(pname) or an object (objselect)");
153:                }
154:                getPnameCommand(cmd);
155:                // object selector
156:                if (getObjselect() != null) {
157:                    cmd.createArgument().setValue(getObjselect());
158:                }
159:            }
160:
161:            /**
162:             * If true, replace an existing lock.
163:             *
164:             * @param replace the status to set the flag to
165:             */
166:            public void setReplace(boolean replace) {
167:                mReplace = replace;
168:            }
169:
170:            /**
171:             * Get replace flag status
172:             *
173:             * @return boolean containing status of replace flag
174:             */
175:            public boolean getReplace() {
176:                return mReplace;
177:            }
178:
179:            /**
180:             * If true, mark object as obsolete.
181:             *
182:             * @param obsolete the status to set the flag to
183:             */
184:            public void setObsolete(boolean obsolete) {
185:                mObsolete = obsolete;
186:            }
187:
188:            /**
189:             * Get obsolete flag status
190:             *
191:             * @return boolean containing status of obsolete flag
192:             */
193:            public boolean getObsolete() {
194:                return mObsolete;
195:            }
196:
197:            /**
198:             * Sets the users who may continue to
199:             * edit the object while it is locked.
200:             *
201:             * @param nusers users excluded from lock
202:             */
203:            public void setNusers(String nusers) {
204:                mNusers = nusers;
205:            }
206:
207:            /**
208:             * Get nusers list
209:             *
210:             * @return String containing the list of users excluded from lock
211:             */
212:            public String getNusers() {
213:                return mNusers;
214:            }
215:
216:            /**
217:             * Sets how comments should be written
218:             * for the event record(s)
219:             *
220:             * @param comment comment method to use
221:             */
222:            public void setComment(String comment) {
223:                mComment = comment;
224:            }
225:
226:            /**
227:             * Get comment method
228:             *
229:             * @return String containing the desired comment method
230:             */
231:            public String getComment() {
232:                return mComment;
233:            }
234:
235:            /**
236:             * Sets the pathname to be locked
237:             *
238:             * @param pname pathname to be locked
239:             */
240:            public void setPname(String pname) {
241:                mPname = pname;
242:            }
243:
244:            /**
245:             * Get the pathname to be locked
246:             *
247:             * @return String containing the pathname to be locked
248:             */
249:            public String getPname() {
250:                return mPname;
251:            }
252:
253:            /**
254:             * Sets the object(s) to be locked
255:             *
256:             * @param objsel objects to be locked
257:             * @since ant 1.6.1
258:             */
259:            public void setObjSel(String objsel) {
260:                mObjselect = objsel;
261:            }
262:
263:            /**
264:             * Sets the object(s) to be locked
265:             *
266:             * @param objselect objects to be locked
267:             */
268:            public void setObjselect(String objselect) {
269:                mObjselect = objselect;
270:            }
271:
272:            /**
273:             * Get list of objects to be locked
274:             *
275:             * @return String containing the objects to be locked
276:             */
277:            public String getObjselect() {
278:                return mObjselect;
279:            }
280:
281:            /**
282:             * Get the 'nusers' command
283:             *
284:             * @param cmd containing the command line string with or
285:             *            without the nusers flag and value appended
286:             */
287:            private void getNusersCommand(Commandline cmd) {
288:                if (getNusers() == null) {
289:                    return;
290:                } else {
291:                    /* Had to make two separate commands here because if a space is
292:                       inserted between the flag and the value, it is treated as a
293:                       Windows filename with a space and it is enclosed in double
294:                       quotes ("). This breaks clearcase.
295:                     */
296:                    cmd.createArgument().setValue(FLAG_NUSERS);
297:                    cmd.createArgument().setValue(getNusers());
298:                }
299:            }
300:
301:            /**
302:             * Get the 'comment' command
303:             *
304:             * @param cmd containing the command line string with or without the
305:             *            comment flag and value appended
306:             */
307:            private void getCommentCommand(Commandline cmd) {
308:                if (getComment() == null) {
309:                    return;
310:                } else {
311:                    /* Had to make two separate commands here because if a space is
312:                       inserted between the flag and the value, it is treated as a
313:                       Windows filename with a space and it is enclosed in double
314:                       quotes ("). This breaks clearcase.
315:                     */
316:                    cmd.createArgument().setValue(FLAG_COMMENT);
317:                    cmd.createArgument().setValue(getComment());
318:                }
319:            }
320:
321:            /**
322:             * Get the 'pname' command
323:             *
324:             * @param cmd containing the command line string with or
325:             *            without the pname flag and value appended
326:             */
327:            private void getPnameCommand(Commandline cmd) {
328:                if (getPname() == null) {
329:                    return;
330:                } else {
331:                    /* Had to make two separate commands here because if a space is
332:                       inserted between the flag and the value, it is treated as a
333:                       Windows filename with a space and it is enclosed in double
334:                       quotes ("). This breaks clearcase.
335:                     */
336:                    cmd.createArgument().setValue(FLAG_PNAME);
337:                    cmd.createArgument().setValue(getPname());
338:                }
339:            }
340:
341:            /**
342:             * Return which object/pname is being operated on
343:             *
344:             * @return String containing the object/pname being worked on
345:             */
346:            private String getOpType() {
347:
348:                if (getPname() != null) {
349:                    return getPname();
350:                } else {
351:                    return getObjselect();
352:                }
353:            }
354:
355:            /**
356:             *  -replace flag -- replace existing lock on object(s)
357:             */
358:            public static final String FLAG_REPLACE = "-replace";
359:            /**
360:             * -nusers flag -- list of users to exclude from lock
361:             */
362:            public static final String FLAG_NUSERS = "-nusers";
363:            /**
364:             * -obsolete flag -- mark locked object as obsolete
365:             */
366:            public static final String FLAG_OBSOLETE = "-obsolete";
367:            /**
368:             * -comment flag -- method to use for commenting events
369:             */
370:            public static final String FLAG_COMMENT = "-comment";
371:            /**
372:             * -pname flag -- pathname to lock
373:             */
374:            public static final String FLAG_PNAME = "-pname";
375:        }
w__w_w___.___j_a___v__a__2_s_.___co_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.