Source Code Cross Referenced for OtterProject.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » common » node » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.common.node 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Enhydra Java Application Server Project
0003:         *
0004:         * The contents of this file are subject to the Enhydra Public License
0005:         * Version 1.1 (the "License"); you may not use this file except in
0006:         * compliance with the License. You may obtain a copy of the License on
0007:         * the Enhydra web site ( http://www.enhydra.org/ ).
0008:         *
0009:         * Software distributed under the License is distributed on an "AS IS"
0010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
0011:         * the License for the specific terms governing rights and limitations
0012:         * under the license.
0013:         *
0014:         * The Initial Developer of the Enhydra Application Server is Lutris
0015:         * Technologies, Inc. The Enhydra Application Server and portions created
0016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
0017:         * All Rights Reserved.
0018:         *
0019:         * Contributor(s):
0020:         * Paul Mahar
0021:         *
0022:         */
0023:        package org.enhydra.kelp.common.node;
0024:
0025:        // ToolBox
0026:        import org.enhydra.tool.ToolBoxInfo;
0027:        import org.enhydra.tool.archive.Descriptor;
0028:        import org.enhydra.tool.archive.JarPlan;
0029:        import org.enhydra.tool.archive.WarPlan;
0030:        import org.enhydra.tool.archive.ArchiveException;
0031:        import org.enhydra.tool.archive.PropertyReader;
0032:        import org.enhydra.tool.archive.PropertyWriter;
0033:        import org.enhydra.tool.common.PathHandle;
0034:        import org.enhydra.tool.common.ToolException;
0035:        import org.enhydra.tool.configure.ConfigTool;
0036:
0037:        // AddinCore
0038:        import org.enhydra.kelp.KelpInfo;
0039:        import org.enhydra.kelp.common.Constants;
0040:        import org.enhydra.kelp.common.Backward;
0041:        import org.enhydra.kelp.common.PathUtil;
0042:        import org.enhydra.kelp.common.PropUtil;
0043:        import org.enhydra.kelp.common.map.MapEntry;
0044:        import org.enhydra.kelp.common.map.MapUtil;
0045:
0046:        // JDK
0047:        import java.io.BufferedInputStream;
0048:        import java.io.BufferedOutputStream;
0049:        import java.io.File;
0050:        import java.io.FileInputStream;
0051:        import java.io.FileNotFoundException;
0052:        import java.io.FileOutputStream;
0053:        import java.io.IOException;
0054:        import java.util.Vector;
0055:        import java.util.ArrayList;
0056:        import java.util.Arrays;
0057:        import java.util.Properties;
0058:
0059:        //
0060:        abstract public class OtterProject implements  OtterNode {
0061:            public final static int MAP_SCOPE_ALL = 0;
0062:            public final static int MAP_SCOPE_SELECTED = 1;
0063:            public final static int MAP_SCOPE_NONE = 2;
0064:
0065:            //
0066:            public final static int TYPE_UNKNOWN = -1;
0067:            //Dusan 05.02.2003.
0068:            //    public final static int TYPE_WEBAPP = 0;
0069:            public final static int TYPE_WEBAPP = 0;
0070:            //    public final static int TYPE_SERVICE = 1;
0071:            //    public final static int TYPE_EN3APP = 2;
0072:            public final static int TYPE_EN3APP = 1;
0073:
0074:            //
0075:            abstract public String getCodeGenDefaultDestination();
0076:
0077:            /**
0078:             * Find and return first .policy node found in project.
0079:             */
0080:            abstract public OtterTextFileNode getFirstPolicy();
0081:
0082:            /**
0083:             * Get working directory for project run.
0084:             */
0085:            abstract public String getWorkingPath();
0086:
0087:            /**
0088:             * Set working directory for project run.
0089:             */
0090:            abstract public void setWorkingPath(String path);
0091:
0092:            /**
0093:             * Return all web.xml nodes.
0094:             */
0095:            abstract public OtterTextFileNode[] getAllDeploymentDescs();
0096:
0097:            /**
0098:             * Return all nodes that ends with an extension in
0099:             * the provided extension list.
0100:             *
0101:             * @param extensions
0102:             */
0103:            abstract public OtterFileNode[] findFileNodesByType(
0104:                    String[] extensions);
0105:
0106:            /**
0107:             * Get all templates contained in the input directory.
0108:             */
0109:            abstract public OtterFileNode[] getAllInput();
0110:
0111:            /**
0112:             * Get all document nodes in the project.
0113:             */
0114:            abstract public OtterDocumentNode[] getAllDocuments();
0115:
0116:            /**
0117:             * Return the IDE implementation of the project node.
0118:             */
0119:            abstract public Object getNativeProject();
0120:
0121:            abstract public String getRootPath();
0122:
0123:            /**
0124:             * Does IDE allow for integrated build.
0125:             */
0126:            abstract public boolean isOpenBuild();
0127:
0128:            /**
0129:             * Method declaration
0130:             *
0131:             * @return
0132:             */
0133:            abstract public String getClassOutputPath();
0134:
0135:            abstract public void setClassOutputPath(String p);
0136:
0137:            //
0138:            abstract public boolean isDefaultProject();
0139:
0140:            /**
0141:             * Method declaration
0142:             *
0143:             * @return
0144:             */
0145:            abstract public String getSourcePath();
0146:
0147:            /**
0148:             * Method declaration
0149:             *
0150:             * @return
0151:             */
0152:            abstract public String[] getSourcePathArray();
0153:
0154:            /**
0155:             * Method declaration
0156:             *
0157:             * @param pathAsArray
0158:             */
0159:            abstract public void setSourcePathArray(String[] pathAsArray);
0160:
0161:            /**
0162:             * Method declaration
0163:             *
0164:             *
0165:             * @return
0166:             */
0167:            abstract public String getClassPath();
0168:
0169:            /**
0170:             * Method declaration
0171:             *
0172:             * @param property
0173:             *
0174:             * @return
0175:             */
0176:            abstract public String getProperty(String property);
0177:
0178:            /**
0179:             * Method declaration
0180:             *
0181:             * @return
0182:             */
0183:            abstract public OtterNodeFactory getNodeFactory();
0184:
0185:            /**
0186:             * Method declaration
0187:             *
0188:             */
0189:            abstract public void configureRunClass();
0190:
0191:            /**
0192:             * Method declaration
0193:             *
0194:             * @param property
0195:             * @param value
0196:             */
0197:            abstract public void setProperty(String property, String value);
0198:
0199:            /**
0200:             * Method declaration
0201:             *
0202:             * @param property
0203:             * @param value
0204:             */
0205:            abstract public void setProperty(String property, int value);
0206:
0207:            //
0208:            //
0209:            public String getProjectRootName() {
0210:                File root = new File(getRootPath());
0211:                String projectName = root.getName();
0212:
0213:                return projectName;
0214:            }
0215:
0216:            public String[] getDocTypes() {
0217:                String[] exts = new String[0];
0218:                String extList = null;
0219:
0220:                exts = ToolBoxInfo.getSupportedDocTypes(); // defaults
0221:                extList = getProperty(XMLC_DOC_TYPES);
0222:                exts = PropUtil.listToArray(extList, exts);
0223:                return exts;
0224:            }
0225:
0226:            public void setDocTypes(String[] exts) {
0227:                String extList = null;
0228:
0229:                extList = PropUtil.arrayToList(exts);
0230:                setProperty(XMLC_DOC_TYPES, extList);
0231:            }
0232:
0233:            public String[] getNonDocumentContentTypes() {
0234:                String[] exts = PropertyKeys.DEFAULT_CONTENT;
0235:                String extTypes = null;
0236:
0237:                extTypes = getProperty(DEPLOY_CONTENT_TYPES);
0238:                exts = PropUtil.listToArray(extTypes, exts);
0239:                return exts;
0240:            }
0241:
0242:            public String[] getContentTypes() {
0243:                ArrayList list = null;
0244:                String[] docs = new String[0];
0245:                String[] exts = getNonDocumentContentTypes();
0246:
0247:                // add doc types
0248:                list = new ArrayList(Arrays.asList(exts));
0249:                docs = getDocTypes();
0250:                for (int i = 0; i < docs.length; i++) {
0251:                    if (!list.contains(docs[i])) {
0252:                        list.add(docs[i]);
0253:                    }
0254:                }
0255:                //Dusan
0256:                /*        if (getDeployType() == OtterProject.TYPE_SERVICE) {
0257:                 if (!list.contains("xml")) {
0258:                 list.add("xml");
0259:                 }
0260:                 } */
0261:                list.trimToSize();
0262:                exts = new String[list.size()];
0263:                exts = (String[]) list.toArray(exts);
0264:                return exts;
0265:            }
0266:
0267:            public void setContentTypes(String[] exts) {
0268:                ArrayList list = null;
0269:                String[] docs = new String[0];
0270:                String extTypes = null;
0271:
0272:                // remove doc types
0273:                list = new ArrayList(Arrays.asList(exts));
0274:                docs = getDocTypes();
0275:                for (int i = 0; i < docs.length; i++) {
0276:                    if (list.contains(docs[i])) {
0277:                        list.remove(docs[i]);
0278:                    }
0279:                }
0280:                list.trimToSize();
0281:                exts = new String[list.size()];
0282:                exts = (String[]) list.toArray(exts);
0283:                extTypes = PropUtil.arrayToList(exts);
0284:                setProperty(DEPLOY_CONTENT_TYPES, extTypes);
0285:            }
0286:
0287:            /**
0288:             * Method declaration
0289:             *
0290:             *
0291:             * @return
0292:             */
0293:            public OtterXMLCNode[] getAllXMLCNodes() {
0294:                OtterDocumentNode[] docNodes = new OtterDocumentNode[0];
0295:                OtterXMLCNode[] xmlcNodes = new OtterXMLCNode[0];
0296:
0297:                docNodes = getAllDocuments();
0298:                xmlcNodes = new OtterXMLCNode[docNodes.length];
0299:                for (int i = 0; i < docNodes.length; i++) {
0300:                    xmlcNodes[i] = new OtterXMLCNode(docNodes[i]);
0301:                }
0302:                return xmlcNodes;
0303:            }
0304:
0305:            /**
0306:             * Method declaration
0307:             *
0308:             * @return
0309:             */
0310:            public String getXMLCOptionFilePath() {
0311:                String filename = new String();
0312:                File file = PathUtil.getFileRelativeToProject(this ,
0313:                        PropertyKeys.NAME_XMLC_OPTION_FILEPATH);
0314:
0315:                if ((file != null) && file.exists() && (!file.isDirectory())) {
0316:                    filename = file.getAbsolutePath();
0317:                }
0318:                return filename;
0319:            }
0320:
0321:            /**
0322:             * Method declaration
0323:             *
0324:             * @param filename
0325:             */
0326:            public void setXMLCOptionFilePath(String filename) {
0327:                PathUtil.putFileRelativeToProject(this ,
0328:                        PropertyKeys.NAME_XMLC_OPTION_FILEPATH, filename);
0329:            }
0330:
0331:            /**
0332:             * Method declaration
0333:             *
0334:             *
0335:             * @return
0336:             */
0337:            public String getXMLCParameters() {
0338:                String params = getProperty(PropertyKeys.NAME_XMLC_PARAMETERS);
0339:
0340:                params = PropUtil.removeQuotes(params);
0341:                return params;
0342:            }
0343:
0344:            /**
0345:             * Method declaration
0346:             *
0347:             * @param p
0348:             */
0349:            public void setXMLCParameters(String p) {
0350:                setProperty(PropertyKeys.NAME_XMLC_PARAMETERS, p);
0351:            }
0352:
0353:            /**
0354:             * Method declaration
0355:             *
0356:             *
0357:             * @return
0358:             */
0359:            public boolean isPrintDOM() {
0360:                return readBooleanProperty(XMLC_PRINT_DOM, false);
0361:            }
0362:
0363:            /**
0364:             * Method declaration
0365:             *
0366:             * @param b
0367:             */
0368:            public void setPrintDOM(boolean b) {
0369:                writeBooleanProperty(XMLC_PRINT_DOM, b);
0370:            }
0371:
0372:            /**
0373:             * Method declaration
0374:             *
0375:             * @return
0376:             */
0377:            public boolean isXMLCBuild() {
0378:                return readBooleanProperty(XMLC_BUILD, false);
0379:            }
0380:
0381:            /** Dusan
0382:             * Method declaration
0383:             *
0384:             * @return
0385:             */
0386:            public boolean isDodsBuild() {
0387:                return readBooleanProperty(DODS_BUILD, false);
0388:            }
0389:
0390:            /**
0391:             * Method declaration
0392:             *
0393:             *
0394:             * @param b
0395:             */
0396:            public void setXMLCBuild(boolean b) {
0397:                writeBooleanProperty(XMLC_BUILD, b);
0398:            }
0399:
0400:            /**
0401:             * Method declaration
0402:             *
0403:             * @return
0404:             */
0405:            public int getDeployType() {
0406:                String in = getProperty(DEPLOY_TYPE);
0407:                int type = TYPE_UNKNOWN;
0408:
0409:                type = PropUtil.stringToInt(in, TYPE_UNKNOWN);
0410:                if (type == TYPE_UNKNOWN) {
0411:                    if (Backward.createIsWebApp(getSourcePathArray())) {
0412:                        type = TYPE_WEBAPP;
0413:                    }
0414:                }
0415:                return type;
0416:            }
0417:
0418:            /**
0419:             * Method declaration
0420:             *
0421:             * @return
0422:             */
0423:            public int getDodsType() {
0424:                String in = getProperty(DODS_TYPE);
0425:                int type = TYPE_UNKNOWN;
0426:
0427:                type = PropUtil.stringToInt(in, TYPE_UNKNOWN);
0428:                if (type == TYPE_UNKNOWN) {
0429:                    if (Backward.createIsWebApp(getSourcePathArray())) {
0430:                        type = TYPE_WEBAPP;
0431:                    }
0432:                }
0433:                return type;
0434:            }
0435:
0436:            /**
0437:             * Method declaration
0438:             *
0439:             * @param b
0440:             */
0441:            public void setDeployType(int type) {
0442:                setProperty(DEPLOY_TYPE, type);
0443:            }
0444:
0445:            /**
0446:             * Method declaration
0447:             *
0448:             * @param b
0449:             */
0450:            public void setDodsType(int type) {
0451:                setProperty(DODS_TYPE, type);
0452:            }
0453:
0454:            public String getDeployResourcePath() {
0455:                String out = new String();
0456:
0457:                out = getProperty(DEPLOY_PATH_RESOURCE);
0458:                if ((out == null) || (out.trim().length() == 0)) {
0459:                    out = getSourcePathArray()[0];
0460:                } else {
0461:                    out = PathUtil.expandPathRelativeToProject(this , out);
0462:                }
0463:                out = PathHandle.createPathString(out);
0464:                return out;
0465:            }
0466:
0467:            public void setDeployResourcePath(String path) {
0468:                path = PathUtil.compressPathRelativeToProject(this , path);
0469:                setProperty(DEPLOY_PATH_RESOURCE, path.replace('\\', '/'));
0470:            }
0471:
0472:            public String getDeployRootPath() {
0473:                String out = new String();
0474:
0475:                out = getProperty(DEPLOY_PATH_ROOT);
0476:                if ((out == null) || (out.trim().length() == 0)) {
0477:                    out = getWorkingPath() + File.separator
0478:                            + Constants.DIR_OUTPUT;
0479:                } else {
0480:                    out = PathUtil.expandPathRelativeToProject(this , out);
0481:                }
0482:                return PathHandle.createPathString(out);
0483:            }
0484:
0485:            /*    public String getDodsRootPath() {
0486:             String out = new String();
0487:
0488:             out = getProperty(DODS_PATH_ROOT);
0489:             if ((out == null) || (out.trim().length() == 0)) {
0490:             out = getWorkingPath() + File.separator + Constants.DIR_OUTPUT;
0491:             } else {
0492:             out = PathUtil.expandPathRelativeToProject(this, out);
0493:             }
0494:             return PathHandle.createPathString(out);
0495:             } */
0496:
0497:            public void setDeployRootPath(String path) {
0498:                path = PathUtil.compressPathRelativeToProject(this , path);
0499:                setProperty(DEPLOY_PATH_ROOT, path.replace('\\', '/'));
0500:            }
0501:
0502:            /*    public void setDodsRootPath(String path) {
0503:             path = PathUtil.compressPathRelativeToProject(this, path);
0504:             setProperty(DODS_PATH_ROOT, path.replace('\\', '/'));
0505:             }
0506:             */
0507:            public boolean isDeployInput() {
0508:                boolean def = false;
0509:                int type = getDeployType();
0510:
0511:                if (type == OtterProject.TYPE_EN3APP
0512:                        || type == OtterProject.TYPE_WEBAPP) {
0513:                    def = true;
0514:                }
0515:                return readBooleanProperty(DEPLOY_INPUT_ENABLE, def);
0516:            }
0517:
0518:            public void setDeployInput(boolean b) {
0519:                writeBooleanProperty(DEPLOY_INPUT_ENABLE, b);
0520:            }
0521:
0522:            public boolean isDeployContent() {
0523:                boolean def = false;
0524:                int type = getDeployType();
0525:
0526:                if (type == OtterProject.TYPE_EN3APP
0527:                        || type == OtterProject.TYPE_WEBAPP
0528:                //Dusan
0529:                //            type == OtterProject.TYPE_SERVICE) {
0530:                ) {
0531:                    def = true;
0532:                }
0533:
0534:                return readBooleanProperty(DEPLOY_CONTENT_ENABLE, def);
0535:            }
0536:
0537:            public void setDeployContent(boolean b) {
0538:                writeBooleanProperty(DEPLOY_CONTENT_ENABLE, b);
0539:            }
0540:
0541:            public boolean isDeployRun() {
0542:                boolean def = true;
0543:
0544:                if (getDeployType() == OtterProject.TYPE_UNKNOWN) {
0545:                    def = false;
0546:                }
0547:
0548:                return readBooleanProperty(DEPLOY_RUN_ENABLE, def);
0549:            }
0550:
0551:            public void setDeployRun(boolean b) {
0552:                writeBooleanProperty(DEPLOY_RUN_ENABLE, b);
0553:            }
0554:
0555:            public String getDeployInputPath() {
0556:                String out = new String();
0557:
0558:                out = getProperty(DEPLOY_PATH_INPUT);
0559:                if ((out == null) || (out.trim().length() == 0)) {
0560:                    out = getWorkingPath() + File.separator
0561:                            + Constants.DIR_INPUT;
0562:                    out = Backward.createDefaultInputPath(out,
0563:                            getSourcePathArray());
0564:                } else {
0565:                    out = PathUtil.expandPathRelativeToProject(this , out);
0566:                }
0567:                out = PathHandle.createPathString(out);
0568:                return out;
0569:            }
0570:
0571:            public void setDeployInputPath(String path) {
0572:                path = PathUtil.compressPathRelativeToProject(this , path);
0573:                path = path.replace('\\', '/');
0574:                setProperty(DEPLOY_PATH_INPUT, path);
0575:            }
0576:
0577:            /**
0578:             * Method declaration
0579:             *
0580:             *
0581:             * @return
0582:             */
0583:            public boolean isPrintParseInfo() {
0584:                return readBooleanProperty(XMLC_PRINT_PARSE, false);
0585:            }
0586:
0587:            /**
0588:             * Method declaration
0589:             *
0590:             *
0591:             * @param b
0592:             */
0593:            public void setPrintParseInfo(boolean b) {
0594:                writeBooleanProperty(XMLC_PRINT_PARSE, b);
0595:            }
0596:
0597:            /**
0598:             * Method declaration
0599:             *
0600:             *
0601:             * @return
0602:             */
0603:            public boolean isPrintAccessorInfo() {
0604:                return readBooleanProperty(XMLC_PRINT_ACCESSOR, false);
0605:            }
0606:
0607:            /**
0608:             * Method declaration
0609:             *
0610:             *
0611:             * @param b
0612:             */
0613:            public void setPrintAccessorInfo(boolean b) {
0614:                writeBooleanProperty(XMLC_PRINT_ACCESSOR, b);
0615:            }
0616:
0617:            /**
0618:             * Method declaration
0619:             *
0620:             *
0621:             * @return
0622:             */
0623:            public boolean isPrintDocumentInfo() {
0624:                return readBooleanProperty(XMLC_PRINT_DOC, false);
0625:            }
0626:
0627:            /**
0628:             * Method declaration
0629:             *
0630:             *
0631:             * @param b
0632:             */
0633:            public void setPrintDocumentInfo(boolean b) {
0634:                writeBooleanProperty(XMLC_PRINT_DOC, b);
0635:            }
0636:
0637:            /**
0638:             * Method declaration
0639:             *
0640:             *
0641:             * @return
0642:             */
0643:            public boolean isVerbose() {
0644:                return readBooleanProperty(XMLC_VERBOSE, false);
0645:            }
0646:
0647:            /**
0648:             * Method declaration
0649:             *
0650:             *
0651:             * @param b
0652:             */
0653:            public void setVerbose(boolean b) {
0654:                writeBooleanProperty(XMLC_VERBOSE, b);
0655:            }
0656:
0657:            /**
0658:             * Method declaration
0659:             *
0660:             *
0661:             * @return
0662:             */
0663:            public int getVerifiedMapScope() {
0664:                int scope = MAP_SCOPE_ALL;
0665:
0666:                scope = getMapScope();
0667:
0668:                // if selected, verify
0669:                if (scope == MAP_SCOPE_SELECTED) {
0670:                    OtterXMLCNode[] nodes = new OtterXMLCNode[0];
0671:                    int mapCount = 0;
0672:                    int type = OtterXMLCNode.CLASS_NAME_MAPPED;
0673:
0674:                    nodes = getAllXMLCNodes();
0675:                    if (nodes.length > 0) {
0676:                        for (int i = 0; i < nodes.length; i++) {
0677:                            type = nodes[i].getClassNameType();
0678:                            if (type == OtterXMLCNode.CLASS_NAME_MAPPED) {
0679:                                mapCount++;
0680:                            }
0681:                        }
0682:                        if (mapCount == 0) {
0683:                            scope = MAP_SCOPE_NONE;
0684:                            setMapScope(MAP_SCOPE_NONE);
0685:                        } else if (mapCount == nodes.length) {
0686:                            scope = MAP_SCOPE_ALL;
0687:                            setMapScope(MAP_SCOPE_ALL);
0688:                        }
0689:                    }
0690:                    nodes = new OtterXMLCNode[0];
0691:                }
0692:                return scope;
0693:            }
0694:
0695:            public int getMapScope() {
0696:                String strScope;
0697:                int intScope;
0698:
0699:                strScope = getProperty(XMLC_MAP_SCOPE);
0700:                intScope = PropUtil.stringToInt(strScope, MAP_SCOPE_ALL);
0701:                return intScope;
0702:            }
0703:
0704:            /**
0705:             * Method declaration
0706:             *
0707:             *
0708:             * @param b
0709:             */
0710:            public void setMapScope(int i) {
0711:                setProperty(XMLC_MAP_SCOPE, i);
0712:            }
0713:
0714:            /**
0715:             * Method declaration
0716:             *
0717:             *
0718:             * @return
0719:             */
0720:            public String getOutputFilename() {
0721:                String out = null;
0722:
0723:                out = getProperty(XMLC_OUTPUT_FILENAME);
0724:                return out;
0725:            }
0726:
0727:            /**
0728:             * Method declaration
0729:             *
0730:             *
0731:             * @param n
0732:             */
0733:            public void setOutputFilename(String n) {
0734:                setProperty(XMLC_OUTPUT_FILENAME, n);
0735:            }
0736:
0737:            /**
0738:             * Method declaration
0739:             *
0740:             *
0741:             * @return
0742:             */
0743:            public String[][] getPackageMap() {
0744:                String[][] map = PropUtil.getArrayProperty(this ,
0745:                        XMLC_MAP_PACKAGE_LENGTH, XMLC_MAP_PACKAGE_FROM,
0746:                        XMLC_MAP_PACKAGE_TO);
0747:                File from;
0748:
0749:                for (int i = 0; i < map.length; i++) {
0750:                    map[i][0] = PathUtil.expandPathRelativeToProject(this ,
0751:                            map[i][0]);
0752:                }
0753:                map = MapUtil.optimize(map);
0754:                return map;
0755:            }
0756:
0757:            /**
0758:             * Method declaration
0759:             *
0760:             * @param map
0761:             */
0762:            public void setPackageMap(String[][] map) {
0763:                map = MapUtil.optimize(map);
0764:                for (int i = 0; i < map.length; i++) {
0765:                    map[i][0] = PathUtil.compressPathRelativeToProject(this ,
0766:                            map[i][0]);
0767:                }
0768:                PropUtil.putArrayProperty(this , XMLC_MAP_PACKAGE_LENGTH,
0769:                        XMLC_MAP_PACKAGE_FROM, XMLC_MAP_PACKAGE_TO, map);
0770:            }
0771:
0772:            /**
0773:             * Method declaration
0774:             *
0775:             *
0776:             * @return
0777:             */
0778:            public String[][] getReplacementTable() {
0779:                String[][] table = PropUtil.getArrayProperty(this ,
0780:                        DEPLOY_TABLE_LENGTH, DEPLOY_TABLE_FIND,
0781:                        DEPLOY_TABLE_REPLACE);
0782:
0783:                // replace relative paths in replaceWith column
0784:                if (table.length == 0) {
0785:                    try {
0786:                        table = ConfigTool.createReplacementStringArray(
0787:                                getRootPath(), getDeployRootPath(), ToolBoxInfo
0788:                                        .getJavaPath());
0789:                    } catch (ToolException e) {
0790:                        table = new String[0][0];
0791:                        e.printStackTrace();
0792:                    }
0793:                    table = Backward.createReplacementTable(table, PathUtil
0794:                            .getInputTemplates(this ));
0795:                }
0796:                for (int i = 0; i < table.length; i++) {
0797:                    if (table[i][0] != "@ENHYDRA_DIR@") // vl
0798:                        table[i][1] = PathUtil.compressPathRelativeToProject(
0799:                                this , table[i][1]);
0800:                }
0801:                return table;
0802:            }
0803:
0804:            /**
0805:             * Method declaration
0806:             *
0807:             * @param map
0808:             */
0809:            public void setReplacementTable(String[][] table) {
0810:
0811:                // replace relative paths in replaceWith column
0812:                for (int i = 0; i < table.length; i++) {
0813:                    if (table[i][0] != "@ENHYDRA_DIR@") // vl
0814:                        table[i][1] = PathUtil.compressPathRelativeToProject(
0815:                                this , table[i][1]);
0816:                }
0817:                PropUtil.putArrayProperty(this , DEPLOY_TABLE_LENGTH,
0818:                        DEPLOY_TABLE_FIND, DEPLOY_TABLE_REPLACE, table);
0819:            }
0820:
0821:            /**
0822:             * Method declaration
0823:             *
0824:             *
0825:             * @return
0826:             */
0827:            public String getGenerateToDirectory() {
0828:                String genToDir = null;
0829:
0830:                if (readBooleanProperty(PropertyKeys.NAME_GENTO, true)) {
0831:                    genToDir = getClassOutputPath() + File.separator
0832:                            + Constants.DIR_GEN_SOURCE;
0833:                }
0834:                return genToDir;
0835:            }
0836:
0837:            /**
0838:             * Method declaration
0839:             *
0840:             *
0841:             * @return
0842:             */
0843:            public boolean isDeployOverwrite() {
0844:                String in = getProperty(DEPLOY_OVERWRITE);
0845:
0846:                return PropUtil.stringToBoolean(in, true);
0847:            }
0848:
0849:            /**
0850:             * Method declaration
0851:             *
0852:             *
0853:             * @return
0854:             */
0855:            public boolean isDodsOverwrite() {
0856:                String in = getProperty(DODS_OVERWRITE);
0857:
0858:                return PropUtil.stringToBoolean(in, true);
0859:            }
0860:
0861:            /**
0862:             * Method declaration
0863:             *
0864:             *
0865:             * @param b
0866:             */
0867:            public void setDeployOverwrite(boolean b) {
0868:                setProperty(DEPLOY_OVERWRITE, PropUtil.booleanToString(b));
0869:            }
0870:
0871:            /**
0872:             * Method declaration
0873:             *
0874:             *
0875:             * @param b
0876:             */
0877:            public void setDodsOverwrite(boolean b) {
0878:                setProperty(DODS_OVERWRITE, PropUtil.booleanToString(b));
0879:            }
0880:
0881:            /**
0882:             * Method declaration
0883:             *
0884:             *
0885:             * @return
0886:             */
0887:            public boolean isDeployInputFilter() {
0888:                String in = getProperty(DEPLOY_INPUT_FILTER);
0889:                boolean inFilter = false;
0890:
0891:                inFilter = PathUtil.isInputInSource(this );
0892:                if (!inFilter) {
0893:                    inFilter = PropUtil.stringToBoolean(in, false);
0894:                }
0895:                return inFilter;
0896:            }
0897:
0898:            /**
0899:             * Method declaration
0900:             *
0901:             *
0902:             * @param b
0903:             */
0904:            public void setDeployInputFilter(boolean b) {
0905:                boolean inFilter = false;
0906:
0907:                inFilter = PathUtil.isInputInSource(this );
0908:                if (inFilter) {
0909:                    b = true;
0910:                }
0911:                setProperty(DEPLOY_INPUT_FILTER, PropUtil.booleanToString(b));
0912:            }
0913:
0914:            /**
0915:             * Method declaration
0916:             *
0917:             *
0918:             * @return
0919:             */
0920:            public boolean isDeployStartupRun() {
0921:                String in = getProperty(DEPLOY_STARTUP_RUN);
0922:
0923:                return PropUtil.stringToBoolean(in, true);
0924:            }
0925:
0926:            /**
0927:             * Method declaration
0928:             *
0929:             *
0930:             * @param b
0931:             */
0932:            public void setDeployStartupRun(boolean b) {
0933:                setProperty(DEPLOY_STARTUP_RUN, PropUtil.booleanToString(b));
0934:            }
0935:
0936:            public boolean isDeployStartupJavaReadOnly() {
0937:                return false;
0938:            }
0939:
0940:            /**
0941:             * Method declaration
0942:             *
0943:             *
0944:             * @return
0945:             */
0946:            public boolean isDeployStartupJava() {
0947:                boolean javaStartup = false;
0948:                String in = getProperty(DEPLOY_STARTUP_JAVA);
0949:
0950:                javaStartup = PropUtil.stringToBoolean(in, !isOpenBuild());
0951:                return javaStartup;
0952:            }
0953:
0954:            /**
0955:             * Method declaration
0956:             *
0957:             *
0958:             * @param b
0959:             */
0960:            public void setDeployStartupJava(boolean b) {
0961:                setProperty(DEPLOY_STARTUP_JAVA, PropUtil.booleanToString(b));
0962:            }
0963:
0964:            /**
0965:             * Method declaration
0966:             *
0967:             *
0968:             * @return
0969:             */
0970:            public String getDeployBootstrapPath() {
0971:                PathHandle ph = null;
0972:                File file = null;
0973:
0974:                file = PathUtil.getFileRelativeToProject(this ,
0975:                        DEPLOY_PATH_BOOTSTRAP);
0976:                ph = PathHandle.createPathHandle(file);
0977:                if (ph.isEmpty()) {
0978:                    ph = PathHandle.createPathHandle(PathUtil
0979:                            .getDefaultDeployBootstrapPath(this ));
0980:                }
0981:                return ph.getPath();
0982:            }
0983:
0984:            /**
0985:             * Method declaration
0986:             *
0987:             *
0988:             * @param conf
0989:             */
0990:            public void setDeployBootstrapPath(String path) {
0991:                PathUtil.putFileRelativeToProject(this , DEPLOY_PATH_BOOTSTRAP,
0992:                        path);
0993:            }
0994:
0995:            /**
0996:             * Method declaration
0997:             *
0998:             *
0999:             * @param conf
1000:             */
1001:            public void setDodsBootstrapPath(String path) {
1002:                PathUtil.putFileRelativeToProject(this , DODS_PATH_BOOTSTRAP,
1003:                        path);
1004:            }
1005:
1006:            public void setArchivePlans(JarPlan[] plans) {
1007:                PropertyWriter writer = null;
1008:
1009:                writer = new PropertyWriter();
1010:                writer.write(plans, getArchivePH().getFile());
1011:            }
1012:
1013:            public JarPlan[] getArchivePlans(boolean validate) {
1014:                PropertyReader reader = null;
1015:                JarPlan[] plans = null;
1016:
1017:                reader = new PropertyReader();
1018:                reader.setValidate(validate);
1019:                if (getArchivePH().isFile()) {
1020:                    try {
1021:                        plans = reader.read(getArchivePH().getFile());
1022:                    } catch (IOException e) {
1023:                        e.printStackTrace(System.err);
1024:                        plans = null;
1025:                    }
1026:                }
1027:                if (plans == null) {
1028:                    plans = reader.read(defaultArchiveProperties());
1029:                }
1030:                return plans;
1031:            }
1032:
1033:            public String getAutoDeployFilePath() {
1034:                String path = new String();
1035:                StringBuffer buf = new StringBuffer();
1036:                PathHandle ph = null;
1037:                JarPlan[] plans = new JarPlan[0];
1038:                int dep = 0;
1039:
1040:                path = getProperty(PropertyKeys.AUTO_DEPLOY_FILE);
1041:                ph = PathHandle.createPathHandle(path);
1042:                if (ph.isEmpty()) {
1043:                    if (getDeployType() == OtterProject.TYPE_EN3APP) {
1044:                        buf.append(PathUtil.getDeployConfPath(this ));
1045:                        buf.append(File.separator);
1046:                        buf.append(getProjectRootName());
1047:                        buf.append(".conf");
1048:                        path = PathHandle.createPathString(buf.toString());
1049:                    } else {
1050:                        plans = getArchivePlans(false);
1051:                        if (plans.length > 0) {
1052:                            path = plans[plans.length - 1].getArchivePath();
1053:                        }
1054:                    }
1055:                } else {
1056:                    path = ph.getPath();
1057:                }
1058:                return path;
1059:            }
1060:
1061:            public void setAutoDeployFile(String path) {
1062:                setProperty(PropertyKeys.AUTO_DEPLOY_FILE, PathHandle
1063:                        .createPathString(path));
1064:            }
1065:
1066:            /**
1067:             * Is deployment desired during project build.
1068:             */
1069:            public boolean isDeployBuild() {
1070:                return readBooleanProperty(DEPLOY_BUILD, false);
1071:            }
1072:
1073:            /**
1074:             * Set if deployment is desired during project build.
1075:             */
1076:            public void setDeployBuild(boolean b) {
1077:                writeBooleanProperty(DEPLOY_BUILD, b);
1078:            }
1079:
1080:            /**
1081:             * Set if deployment is desired during project build.
1082:             */
1083:            public void setDodsBuild(boolean b) {
1084:                writeBooleanProperty(DODS_BUILD, b);
1085:            }
1086:
1087:            /**
1088:             * Is processing shown during deployment.
1089:             */
1090:            public boolean isDeployEcho() {
1091:                return readBooleanProperty(DEPLOY_ECHO, true);
1092:            }
1093:
1094:            /**
1095:             * Is processing shown during generating.
1096:             */
1097:            public boolean isDodsEcho() {
1098:                return readBooleanProperty(DODS_ECHO, true);
1099:            }
1100:
1101:            /**
1102:             * Set if processing should be shown during deployment.
1103:             */
1104:            public void setDeployEcho(boolean b) {
1105:                writeBooleanProperty(DEPLOY_ECHO, b);
1106:            }
1107:
1108:            /**
1109:             * Set if processing should be shown during deployment.
1110:             */
1111:            public void setDodsEcho(boolean b) {
1112:                writeBooleanProperty(DODS_ECHO, b);
1113:            }
1114:
1115:            /**
1116:             * Method declaration
1117:             *
1118:             *
1119:             * @param node
1120:             *
1121:             * @return
1122:             */
1123:            public String getSourcePathOf(OtterFileNode node) {
1124:                String out = new String();
1125:                String filePath = node.getFilePath();
1126:
1127:                out = PathUtil.getSourcePathOf(this , filePath);
1128:                return out;
1129:            }
1130:
1131:            /**
1132:             * Method declaration
1133:             *
1134:             *
1135:             * @param property
1136:             * @param b
1137:             */
1138:            protected void writeBooleanProperty(String property, boolean b) {
1139:                String flag = b ? Boolean.TRUE.toString() : Boolean.FALSE
1140:                        .toString();
1141:
1142:                setProperty(property, flag);
1143:            }
1144:
1145:            /**
1146:             * Method declaration
1147:             *
1148:             * @param property
1149:             * @param def
1150:             *
1151:             * @return
1152:             */
1153:            protected boolean readBooleanProperty(String property, boolean def) {
1154:                boolean flag = def;
1155:                String in = getProperty(property);
1156:
1157:                return PropUtil.stringToBoolean(in, def);
1158:            }
1159:
1160:            public boolean isSelected() {
1161:                return false;
1162:            }
1163:
1164:            public void setSelected(boolean b) {
1165:            }
1166:
1167:            public void setException(Throwable e) {
1168:            }
1169:
1170:            public Throwable getException() {
1171:                return null;
1172:            }
1173:
1174:            private PathHandle getArchivePH() {
1175:                PathHandle ph = null;
1176:                StringBuffer buf = new StringBuffer();
1177:
1178:                buf.append(getRootPath());
1179:                buf.append(File.separator);
1180:                buf.append("archive.properties");
1181:                ph = PathHandle.createPathHandle(buf.toString());
1182:                return ph;
1183:            }
1184:
1185:            private Properties defaultArchiveProperties() {
1186:                Descriptor[] dd = new Descriptor[0];
1187:                JarPlan plan = null;
1188:                PropertyWriter writer = null;
1189:                Properties props = new Properties();
1190:                int type = getDeployType();
1191:
1192:                try {
1193:                    switch (type) {
1194:                    case TYPE_WEBAPP:
1195:                        WarPlan wp = new WarPlan();
1196:
1197:                        wp.setValidate(false);
1198:                        wp.setContentRoot(PathUtil.getDeployContentPath(this ));
1199:                        dd = new Descriptor[1];
1200:                        dd[0] = new Descriptor(true, Descriptor.WEB);
1201:                        dd[0].setPath(getSourcePathArray()[0]
1202:                                + "/WEB-INF/web.xml");
1203:                        plan = wp;
1204:                        break;
1205:                    case TYPE_EN3APP:
1206:                        plan = new JarPlan();
1207:                        plan.setValidate(false);
1208:                        break;
1209:                    //Dusan
1210:                    /*            case TYPE_SERVICE:
1211:                     plan = new JarPlan();
1212:                     plan.setValidate(false);
1213:                     dd = new Descriptor[1];
1214:                     dd[0] = new Descriptor(true, Descriptor.ENHYDRA_SERVICE);
1215:                     dd[0].setPath(getSourcePathArray()[0]
1216:                     + "/META-INF/enhydra-service.xml");
1217:                     break; */
1218:                    }
1219:                    if (plan != null) {
1220:                        plan.setDescriptors(dd);
1221:                        plan.setClassRoot(getClassOutputPath());
1222:                        plan.setArchivePath(PathUtil
1223:                                .getDefaultDeployArchivePath(this ));
1224:                        writer = new PropertyWriter();
1225:                        props = writer.write(plan);
1226:                    }
1227:                } catch (ArchiveException e) {
1228:                    e.printStackTrace(System.err);
1229:                    if (props == null) {
1230:                        props = new Properties();
1231:                    }
1232:                }
1233:                return props;
1234:            }
1235:
1236:            /**
1237:             * Method declaration
1238:             *
1239:             * @param p
1240:             */
1241:            public void setDodsParameters(String p) {
1242:                setProperty(NAME_DODS_PARAMETERS, p);
1243:            }
1244:
1245:            /**
1246:             * Method declaration
1247:             *
1248:             *
1249:             * @return
1250:             */
1251:            public String getDodsParameters() {
1252:                return getProperty(NAME_DODS_PARAMETERS);
1253:            }
1254:
1255:            /**
1256:             * Method declaration
1257:             *
1258:             *
1259:             * @return
1260:             */
1261:            public void setDomlFilePath(String path) {
1262:                setProperty(NAME_DOML_FILEPATH, path);
1263:            }
1264:
1265:            /**
1266:             * Method declaration
1267:             *
1268:             *
1269:             * @return
1270:             */
1271:            public String getDomlFilePath() {
1272:                return getProperty(NAME_DOML_FILEPATH);
1273:            }
1274:
1275:            /**
1276:             * Method declaration
1277:             *
1278:             *
1279:             * @return
1280:             */
1281:            public String getEnhydraPath() {
1282:                return getProperty(DODS_ENHYDRA_PATH);
1283:            }
1284:
1285:            /**
1286:             * Method declaration
1287:             *
1288:             *
1289:             * @return
1290:             */
1291:            public String getProjectJavaPath() {
1292:                return getProperty(DODS_PROJECT_JAVA_PATH);
1293:            }
1294:
1295:            /**
1296:             * Method declaration
1297:             *
1298:             *
1299:             * @return
1300:             */
1301:            public void setDodsRootPath(String path) {
1302:                setProperty(NAME_DODS_ROOTPATH, path);
1303:            }
1304:
1305:            /**
1306:             * Method declaration
1307:             *
1308:             *
1309:             * @return
1310:             */
1311:            public String getDodsRootPath() {
1312:                return getProperty(NAME_DODS_ROOTPATH);
1313:            }
1314:
1315:            /**
1316:             * Method declaration
1317:             *
1318:             *
1319:             * @return
1320:             */
1321:            public void setExstensionParameter(String ext) {
1322:                setProperty(NAME_DODS_EXTENSION, ext);
1323:            }
1324:
1325:            /**
1326:             * Method declaration
1327:             *
1328:             *
1329:             * @return
1330:             */
1331:            public String getExstensionParameter() {
1332:                return getProperty(NAME_DODS_EXTENSION);
1333:            }
1334:
1335:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.