KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > node > OtterProject


1 /*
2 * Enhydra Java Application Server Project
3 *
4 * The contents of this file are subject to the Enhydra Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License on
7 * the Enhydra web site ( http://www.enhydra.org/ ).
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific terms governing rights and limitations
12 * under the license.
13 *
14 * The Initial Developer of the Enhydra Application Server is Lutris
15 * Technologies, Inc. The Enhydra Application Server and portions created
16 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17 * All Rights Reserved.
18 *
19 * Contributor(s):
20 * Paul Mahar
21 *
22  */

23 package org.enhydra.kelp.common.node;
24
25 // ToolBox
26
import org.enhydra.tool.ToolBoxInfo;
27 import org.enhydra.tool.archive.Descriptor;
28 import org.enhydra.tool.archive.JarPlan;
29 import org.enhydra.tool.archive.WarPlan;
30 import org.enhydra.tool.archive.ArchiveException;
31 import org.enhydra.tool.archive.PropertyReader;
32 import org.enhydra.tool.archive.PropertyWriter;
33 import org.enhydra.tool.common.PathHandle;
34 import org.enhydra.tool.common.ToolException;
35 import org.enhydra.tool.configure.ConfigTool;
36
37 // AddinCore
38
import org.enhydra.kelp.KelpInfo;
39 import org.enhydra.kelp.common.Constants;
40 import org.enhydra.kelp.common.Backward;
41 import org.enhydra.kelp.common.PathUtil;
42 import org.enhydra.kelp.common.PropUtil;
43 import org.enhydra.kelp.common.map.MapEntry;
44 import org.enhydra.kelp.common.map.MapUtil;
45
46 // JDK
47
import java.io.BufferedInputStream JavaDoc;
48 import java.io.BufferedOutputStream JavaDoc;
49 import java.io.File JavaDoc;
50 import java.io.FileInputStream JavaDoc;
51 import java.io.FileNotFoundException JavaDoc;
52 import java.io.FileOutputStream JavaDoc;
53 import java.io.IOException JavaDoc;
54 import java.util.Vector JavaDoc;
55 import java.util.ArrayList JavaDoc;
56 import java.util.Arrays JavaDoc;
57 import java.util.Properties JavaDoc;
58 import org.enhydra.dods.generator.DODSGenerator;
59
60
61 //
62
abstract public class OtterProject implements OtterNode {
63   public final static int MAP_SCOPE_ALL = 0;
64   public final static int MAP_SCOPE_SELECTED = 1;
65   public final static int MAP_SCOPE_NONE = 2;
66
67   //
68
public final static int TYPE_UNKNOWN = -1;
69 //Dusan 05.02.2003.
70
// public final static int TYPE_WEBAPP = 0;
71
public final static int TYPE_WEBAPP = 0;
72 // public final static int TYPE_SERVICE = 1;
73
// public final static int TYPE_EN3APP = 2;
74
public final static int TYPE_EN3APP = 1;
75
76   private DODSGenerator generator = null;
77   private boolean documentationHtml;
78   private boolean documentationPdf;
79   private boolean documentationXmi;
80   private boolean documentationPtl;
81
82   //
83
abstract public String JavaDoc getCodeGenDefaultDestination();
84
85   /**
86    * Find and return first .policy node found in project.
87    */

88   abstract public OtterTextFileNode getFirstPolicy();
89
90   /**
91    * Get working directory for project run.
92    */

93   abstract public String JavaDoc getWorkingPath();
94
95   /**
96    * Set working directory for project run.
97    */

98   abstract public void setWorkingPath(String JavaDoc path);
99
100   /**
101    * Return all web.xml nodes.
102    */

103   abstract public OtterTextFileNode[] getAllDeploymentDescs();
104
105   /**
106    * Return all nodes that ends with an extension in
107    * the provided extension list.
108    *
109    * @param extensions
110    */

111   abstract public OtterFileNode[] findFileNodesByType(String JavaDoc[] extensions);
112
113   /**
114    * Get all templates contained in the input directory.
115    */

116   abstract public OtterFileNode[] getAllInput();
117
118   /**
119    * Get all document nodes in the project.
120    */

121   abstract public OtterDocumentNode[] getAllDocuments();
122
123   /**
124    * Return the IDE implementation of the project node.
125    */

126   abstract public Object JavaDoc getNativeProject();
127   abstract public String JavaDoc getRootPath();
128
129   /**
130    * Does IDE allow for integrated build.
131    */

132   abstract public boolean isOpenBuild();
133
134   /**
135    * Method declaration
136    *
137    * @return
138    */

139   abstract public String JavaDoc getClassOutputPath();
140   abstract public void setClassOutputPath(String JavaDoc p);
141
142   //
143
abstract public boolean isDefaultProject();
144
145   /**
146    * Method declaration
147    *
148    * @return
149    */

150   abstract public String JavaDoc getSourcePath();
151
152   /**
153    * Method declaration
154    *
155    * @return
156    */

157   abstract public String JavaDoc[] getSourcePathArray();
158
159   /**
160    * Method declaration
161    *
162    * @param pathAsArray
163    */

164   abstract public void setSourcePathArray(String JavaDoc[] pathAsArray);
165
166   /**
167    * Method declaration
168    *
169    *
170    * @return
171    */

172   abstract public String JavaDoc getClassPath();
173
174   /**
175    * Method declaration
176    *
177    * @param property
178    *
179    * @return
180    */

181   abstract public String JavaDoc getProperty(String JavaDoc property);
182
183   /**
184    * Method declaration
185    *
186    * @return
187    */

188   abstract public OtterNodeFactory getNodeFactory();
189
190   /**
191    * Method declaration
192    *
193    */

194   abstract public void configureRunClass();
195
196   /**
197    * Method declaration
198    *
199    * @param property
200    * @param value
201    */

202   abstract public void setProperty(String JavaDoc property, String JavaDoc value);
203
204   /**
205    * Method declaration
206    *
207    * @param property
208    * @param value
209    */

210   abstract public void setProperty(String JavaDoc property, int value);
211
212   //
213
//
214
public String JavaDoc getProjectRootName() {
215     File JavaDoc root = new File JavaDoc(getRootPath());
216     String JavaDoc projectName = root.getName();
217
218     return projectName;
219   }
220
221   public String JavaDoc[] getDocTypes() {
222     String JavaDoc[] exts = new String JavaDoc[0];
223     String JavaDoc extList = null;
224
225     exts = ToolBoxInfo.getSupportedDocTypes(); // defaults
226
extList = getProperty(XMLC_DOC_TYPES);
227     exts = PropUtil.listToArray(extList, exts);
228     return exts;
229   }
230
231   public void setDocTypes(String JavaDoc[] exts) {
232     String JavaDoc extList = null;
233
234     extList = PropUtil.arrayToList(exts);
235     setProperty(XMLC_DOC_TYPES, extList);
236   }
237
238   public String JavaDoc[] getNonDocumentContentTypes() {
239     String JavaDoc[] exts = PropertyKeys.DEFAULT_CONTENT;
240     String JavaDoc extTypes = null;
241
242     extTypes = getProperty(DEPLOY_CONTENT_TYPES);
243     exts = PropUtil.listToArray(extTypes, exts);
244     return exts;
245   }
246
247   public String JavaDoc[] getContentTypes() {
248     ArrayList JavaDoc list = null;
249     String JavaDoc[] docs = new String JavaDoc[0];
250     String JavaDoc[] exts = getNonDocumentContentTypes();
251
252     // add doc types
253
list = new ArrayList JavaDoc(Arrays.asList(exts));
254     docs = getDocTypes();
255     for (int i = 0; i < docs.length; i++) {
256       if (!list.contains(docs[i])) {
257         list.add(docs[i]);
258       }
259     }
260 //Dusan
261
/* if (getDeployType() == OtterProject.TYPE_SERVICE) {
262             if (!list.contains("xml")) {
263                 list.add("xml");
264             }
265         } */

266     list.trimToSize();
267             exts = new String JavaDoc[list.size()];
268             exts = (String JavaDoc[]) list.toArray(exts);
269             return exts;
270   }
271
272   public void setContentTypes(String JavaDoc[] exts) {
273     ArrayList JavaDoc list = null;
274     String JavaDoc[] docs = new String JavaDoc[0];
275     String JavaDoc extTypes = null;
276
277     // remove doc types
278
list = new ArrayList JavaDoc(Arrays.asList(exts));
279     docs = getDocTypes();
280     for (int i = 0; i < docs.length; i++) {
281       if (list.contains(docs[i])) {
282         list.remove(docs[i]);
283       }
284     }
285     list.trimToSize();
286     exts = new String JavaDoc[list.size()];
287     exts = (String JavaDoc[]) list.toArray(exts);
288     extTypes = PropUtil.arrayToList(exts);
289     setProperty(DEPLOY_CONTENT_TYPES, extTypes);
290   }
291
292   /**
293    * Method declaration
294    *
295    *
296    * @return
297    */

298   public OtterXMLCNode[] getAllXMLCNodes() {
299     OtterDocumentNode[] docNodes = new OtterDocumentNode[0];
300     OtterXMLCNode[] xmlcNodes = new OtterXMLCNode[0];
301
302     docNodes = getAllDocuments();
303     xmlcNodes = new OtterXMLCNode[docNodes.length];
304     for (int i = 0; i < docNodes.length; i++) {
305       xmlcNodes[i] = new OtterXMLCNode(docNodes[i]);
306     }
307     return xmlcNodes;
308   }
309
310   /**
311    * Method declaration
312    *
313    * @return
314    */

315   public String JavaDoc getXMLCOptionFilePath() {
316     String JavaDoc filename = new String JavaDoc();
317     File JavaDoc file = PathUtil.getFileRelativeToProject(this,
318         PropertyKeys.NAME_XMLC_OPTION_FILEPATH);
319
320     if ((file != null) && file.exists() && (!file.isDirectory())) {
321       filename = file.getAbsolutePath();
322     }
323     return filename;
324   }
325
326   /**
327    * Method declaration
328    *
329    * @param filename
330    */

331   public void setXMLCOptionFilePath(String JavaDoc filename) {
332     PathUtil.putFileRelativeToProject(this,
333                                       PropertyKeys.NAME_XMLC_OPTION_FILEPATH,
334                                       filename);
335   }
336
337   /**
338    * Method declaration
339    *
340    *
341    * @return
342    */

343   public String JavaDoc getXMLCParameters() {
344     String JavaDoc params = getProperty(PropertyKeys.NAME_XMLC_PARAMETERS);
345
346     params = PropUtil.removeQuotes(params);
347     return params;
348   }
349
350   /**
351    * Method declaration
352    *
353    * @param p
354    */

355   public void setXMLCParameters(String JavaDoc p) {
356     setProperty(PropertyKeys.NAME_XMLC_PARAMETERS, p);
357   }
358
359   /**
360    * Method declaration
361    *
362    *
363    * @return
364    */

365   public boolean isPrintDOM() {
366     return readBooleanProperty(XMLC_PRINT_DOM, false);
367   }
368
369   /**
370    * Method declaration
371    *
372    * @param b
373    */

374   public void setPrintDOM(boolean b) {
375     writeBooleanProperty(XMLC_PRINT_DOM, b);
376   }
377
378   /**
379    * Method declaration
380    *
381    * @return
382    */

383   public boolean isXMLCBuild() {
384     return readBooleanProperty(XMLC_BUILD, false);
385   }
386
387   /** Dusan
388    * Method declaration
389    *
390    * @return
391    */

392   public boolean isDodsBuild() {
393     return readBooleanProperty(DODS_BUILD, false);
394   }
395
396   /**
397    * Method declaration
398    *
399    *
400    * @param b
401    */

402   public void setXMLCBuild(boolean b) {
403     writeBooleanProperty(XMLC_BUILD, b);
404   }
405
406   /**
407    * Method declaration
408    *
409    * @return
410    */

411   public int getDeployType() {
412     String JavaDoc in = getProperty(DEPLOY_TYPE);
413     int type = TYPE_UNKNOWN;
414
415     type = PropUtil.stringToInt(in, TYPE_UNKNOWN);
416     if (type == TYPE_UNKNOWN) {
417       if (Backward.createIsWebApp(getSourcePathArray())) {
418         type = TYPE_WEBAPP;
419       }
420     }
421     return type;
422   }
423
424   /**
425    * Method declaration
426    *
427    * @return
428    */

429   public int getDodsType() {
430     String JavaDoc in = getProperty(DODS_TYPE);
431     int type = TYPE_UNKNOWN;
432
433     type = PropUtil.stringToInt(in, TYPE_UNKNOWN);
434     if (type == TYPE_UNKNOWN) {
435       if (Backward.createIsWebApp(getSourcePathArray())) {
436         type = TYPE_WEBAPP;
437       }
438     }
439     return type;
440   }
441
442   /**
443    * Method declaration
444    *
445    * @param b
446    */

447   public void setDeployType(int type) {
448     setProperty(DEPLOY_TYPE, type);
449   }
450
451   /**
452    * Method declaration
453    *
454    * @param b
455    */

456   public void setDodsType(int type) {
457     setProperty(DODS_TYPE, type);
458   }
459
460   public String JavaDoc getDeployResourcePath() {
461     String JavaDoc out = new String JavaDoc();
462
463     out = getProperty(DEPLOY_PATH_RESOURCE);
464     if ((out == null) || (out.trim().length() == 0)) {
465       out = getSourcePathArray()[0];
466     } else {
467       out = PathUtil.expandPathRelativeToProject(this, out);
468     }
469     out = PathHandle.createPathString(out);
470     return out;
471   }
472
473   public void setDeployResourcePath(String JavaDoc path) {
474     path = PathUtil.compressPathRelativeToProject(this, path);
475     setProperty(DEPLOY_PATH_RESOURCE, path.replace('\\', '/'));
476   }
477
478   public String JavaDoc getDeployRootPath() {
479     String JavaDoc out = new String JavaDoc();
480
481     out = getProperty(DEPLOY_PATH_ROOT);
482     if ((out == null) || (out.trim().length() == 0)) {
483       out = getWorkingPath() + File.separator + Constants.DIR_OUTPUT;
484     } else {
485       out = PathUtil.expandPathRelativeToProject(this, out);
486     }
487     return PathHandle.createPathString(out);
488   }
489
490 /* public String getDodsRootPath() {
491         String out = new String();
492
493         out = getProperty(DODS_PATH_ROOT);
494         if ((out == null) || (out.trim().length() == 0)) {
495             out = getWorkingPath() + File.separator + Constants.DIR_OUTPUT;
496         } else {
497             out = PathUtil.expandPathRelativeToProject(this, out);
498         }
499         return PathHandle.createPathString(out);
500     } */

501
502   public void setDeployRootPath(String JavaDoc path) {
503     path = PathUtil.compressPathRelativeToProject(this, path);
504     setProperty(DEPLOY_PATH_ROOT, path.replace('\\', '/'));
505   }
506
507 /* public void setDodsRootPath(String path) {
508         path = PathUtil.compressPathRelativeToProject(this, path);
509         setProperty(DODS_PATH_ROOT, path.replace('\\', '/'));
510     }
511 */

512   public boolean isDeployInput() {
513     boolean def = false;
514     int type = getDeployType();
515
516     if (type == OtterProject.TYPE_EN3APP ||
517         type == OtterProject.TYPE_WEBAPP) {
518       def = true;
519     }
520     return readBooleanProperty(DEPLOY_INPUT_ENABLE, def);
521   }
522
523   public void setDeployInput(boolean b) {
524     writeBooleanProperty(DEPLOY_INPUT_ENABLE, b);
525   }
526
527   public boolean isDeployContent() {
528     boolean def = false;
529     int type = getDeployType();
530
531     if (type == OtterProject.TYPE_EN3APP ||
532         type == OtterProject.TYPE_WEBAPP
533 //Dusan
534
// type == OtterProject.TYPE_SERVICE) {
535
) {
536       def = true;
537     }
538
539     return readBooleanProperty(DEPLOY_CONTENT_ENABLE, def);
540   }
541
542   public void setDeployContent(boolean b) {
543     writeBooleanProperty(DEPLOY_CONTENT_ENABLE, b);
544   }
545
546   public boolean isDeployRun() {
547     boolean def = true;
548
549     if (getDeployType() == OtterProject.TYPE_UNKNOWN){
550       def = false;
551     }
552
553     return readBooleanProperty(DEPLOY_RUN_ENABLE, def);
554   }
555
556   public void setDeployRun(boolean b) {
557     writeBooleanProperty(DEPLOY_RUN_ENABLE, b);
558   }
559
560
561   public String JavaDoc getDeployInputPath() {
562     String JavaDoc out = new String JavaDoc();
563
564     out = getProperty(DEPLOY_PATH_INPUT);
565     if ((out == null) || (out.trim().length() == 0)) {
566       out = getWorkingPath() + File.separator + Constants.DIR_INPUT;
567       out = Backward.createDefaultInputPath(out, getSourcePathArray());
568     } else {
569       out = PathUtil.expandPathRelativeToProject(this, out);
570     }
571     out = PathHandle.createPathString(out);
572     return out;
573   }
574
575   public void setDeployInputPath(String JavaDoc path) {
576     path = PathUtil.compressPathRelativeToProject(this, path);
577     path = path.replace('\\', '/');
578     setProperty(DEPLOY_PATH_INPUT, path);
579   }
580
581   /**
582    * Method declaration
583    *
584    *
585    * @return
586    */

587   public boolean isPrintParseInfo() {
588     return readBooleanProperty(XMLC_PRINT_PARSE, false);
589   }
590
591   /**
592    * Method declaration
593    *
594    *
595    * @param b
596    */

597   public void setPrintParseInfo(boolean b) {
598     writeBooleanProperty(XMLC_PRINT_PARSE, b);
599   }
600
601   /**
602    * Method declaration
603    *
604    *
605    * @return
606    */

607   public boolean isPrintAccessorInfo() {
608     return readBooleanProperty(XMLC_PRINT_ACCESSOR, false);
609   }
610
611   /**
612    * Method declaration
613    *
614    *
615    * @param b
616    */

617   public void setPrintAccessorInfo(boolean b) {
618     writeBooleanProperty(XMLC_PRINT_ACCESSOR, b);
619   }
620
621   /**
622    * Method declaration
623    *
624    *
625    * @return
626    */

627   public boolean isPrintDocumentInfo() {
628     return readBooleanProperty(XMLC_PRINT_DOC, false);
629   }
630
631   /**
632    * Method declaration
633    *
634    *
635    * @param b
636    */

637   public void setPrintDocumentInfo(boolean b) {
638     writeBooleanProperty(XMLC_PRINT_DOC, b);
639   }
640
641   /**
642    * Method declaration
643    *
644    *
645    * @return
646    */

647   public boolean isVerbose() {
648     return readBooleanProperty(XMLC_VERBOSE, false);
649   }
650
651   /**
652    * Method declaration
653    *
654    *
655    * @param b
656    */

657   public void setVerbose(boolean b) {
658     writeBooleanProperty(XMLC_VERBOSE, b);
659   }
660
661   /**
662    * Method declaration
663    *
664    *
665    * @return
666    */

667   public int getVerifiedMapScope() {
668     int scope = MAP_SCOPE_ALL;
669
670     scope = getMapScope();
671
672     // if selected, verify
673
if (scope == MAP_SCOPE_SELECTED) {
674       OtterXMLCNode[] nodes = new OtterXMLCNode[0];
675       int mapCount = 0;
676       int type = OtterXMLCNode.CLASS_NAME_MAPPED;
677
678       nodes = getAllXMLCNodes();
679       if (nodes.length > 0) {
680         for (int i = 0; i < nodes.length; i++) {
681           type = nodes[i].getClassNameType();
682           if (type == OtterXMLCNode.CLASS_NAME_MAPPED) {
683             mapCount++;
684           }
685         }
686         if (mapCount == 0) {
687           scope = MAP_SCOPE_NONE;
688           setMapScope(MAP_SCOPE_NONE);
689         } else if (mapCount == nodes.length) {
690           scope = MAP_SCOPE_ALL;
691           setMapScope(MAP_SCOPE_ALL);
692         }
693       }
694       nodes = new OtterXMLCNode[0];
695     }
696     return scope;
697   }
698
699   public int getMapScope() {
700     String JavaDoc strScope;
701     int intScope;
702
703     strScope = getProperty(XMLC_MAP_SCOPE);
704     intScope = PropUtil.stringToInt(strScope, MAP_SCOPE_ALL);
705     return intScope;
706   }
707
708   /**
709    * Method declaration
710    *
711    *
712    * @param b
713    */

714   public void setMapScope(int i) {
715     setProperty(XMLC_MAP_SCOPE, i);
716   }
717
718   /**
719    * Method declaration
720    *
721    *
722    * @return
723    */

724   public String JavaDoc getOutputFilename() {
725     String JavaDoc out = null;
726
727     out = getProperty(XMLC_OUTPUT_FILENAME);
728     return out;
729   }
730
731   /**
732    * Method declaration
733    *
734    *
735    * @param n
736    */

737   public void setOutputFilename(String JavaDoc n) {
738     setProperty(XMLC_OUTPUT_FILENAME, n);
739   }
740
741   /**
742    * Method declaration
743    *
744    *
745    * @return
746    */

747   public String JavaDoc[][] getPackageMap() {
748     String JavaDoc[][] map = PropUtil.getArrayProperty(this,
749         XMLC_MAP_PACKAGE_LENGTH,
750         XMLC_MAP_PACKAGE_FROM,
751         XMLC_MAP_PACKAGE_TO);
752     File JavaDoc from;
753
754     for (int i = 0; i < map.length; i++) {
755       map[i][0] = PathUtil.expandPathRelativeToProject(this, map[i][0]);
756     }
757     map = MapUtil.optimize(map);
758     return map;
759   }
760
761   /**
762    * Method declaration
763    *
764    * @param map
765    */

766   public void setPackageMap(String JavaDoc[][] map) {
767     map = MapUtil.optimize(map);
768     for (int i = 0; i < map.length; i++) {
769       map[i][0] = PathUtil.compressPathRelativeToProject(this,
770       map[i][0]);
771     }
772     PropUtil.putArrayProperty(this, XMLC_MAP_PACKAGE_LENGTH,
773                               XMLC_MAP_PACKAGE_FROM, XMLC_MAP_PACKAGE_TO,
774                               map);
775   }
776
777   /**
778    * Method declaration
779    *
780    *
781    * @return
782    */

783   public String JavaDoc[][] getReplacementTable() {
784     String JavaDoc[][] table = PropUtil.getArrayProperty(this,
785         DEPLOY_TABLE_LENGTH, DEPLOY_TABLE_FIND, DEPLOY_TABLE_REPLACE);
786
787     // replace relative paths in replaceWith column
788
if (table.length == 0) {
789       try {
790         table = ConfigTool.createReplacementStringArray(getRootPath(),
791             getDeployRootPath(), ToolBoxInfo.getJavaPath());
792       } catch (ToolException e) {
793         table = new String JavaDoc[0][0];
794         e.printStackTrace();
795       }
796       table =
797           Backward.createReplacementTable(table,
798           PathUtil.getInputTemplates(this));
799     }
800     for (int i = 0; i < table.length; i++) {
801       if (table[i][0]!="@ENHYDRA_DIR@") // vl
802
table[i][1] = PathUtil.compressPathRelativeToProject(this,table[i][1]);
803     }
804     return table;
805   }
806
807   /**
808    * Method declaration
809    *
810    * @param map
811    */

812   public void setReplacementTable(String JavaDoc[][] table) {
813
814     // replace relative paths in replaceWith column
815
for (int i = 0; i < table.length; i++) {
816       if (table[i][0]!="@ENHYDRA_DIR@") // vl
817
table[i][1] = PathUtil.compressPathRelativeToProject(this,table[i][1]);
818     }
819     PropUtil.putArrayProperty(this, DEPLOY_TABLE_LENGTH,
820                               DEPLOY_TABLE_FIND, DEPLOY_TABLE_REPLACE,
821                               table);
822   }
823
824   /**
825    * Method declaration
826    *
827    *
828    * @return
829    */

830   public String JavaDoc getGenerateToDirectory() {
831     String JavaDoc genToDir = null;
832
833     if (readBooleanProperty(PropertyKeys.NAME_GENTO, true)) {
834       genToDir = getClassOutputPath() + File.separator
835                + Constants.DIR_GEN_SOURCE;
836     }
837     return genToDir;
838   }
839
840   /**
841    * Method declaration
842    *
843    *
844    * @return
845    */

846   public boolean isDeployOverwrite() {
847     String JavaDoc in = getProperty(DEPLOY_OVERWRITE);
848
849     return PropUtil.stringToBoolean(in, true);
850   }
851
852   /**
853    * Method declaration
854    *
855    *
856    * @return
857    */

858   public boolean isDodsOverwrite() {
859     String JavaDoc in = getProperty(DODS_OVERWRITE);
860
861     return PropUtil.stringToBoolean(in, true);
862   }
863
864   /**
865    * Method declaration
866    *
867    *
868    * @param b
869    */

870   public void setDeployOverwrite(boolean b) {
871     setProperty(DEPLOY_OVERWRITE, PropUtil.booleanToString(b));
872   }
873
874   /**
875    * Method declaration
876    *
877    *
878    * @param b
879    */

880   public void setDodsOverwrite(boolean b) {
881     setProperty(DODS_OVERWRITE, PropUtil.booleanToString(b));
882   }
883
884   /**
885    * Method declaration
886    *
887    *
888    * @return
889    */

890   public boolean isDeployInputFilter() {
891     String JavaDoc in = getProperty(DEPLOY_INPUT_FILTER);
892     boolean inFilter = false;
893
894     inFilter = PathUtil.isInputInSource(this);
895     if (!inFilter) {
896       inFilter = PropUtil.stringToBoolean(in, false);
897     }
898     return inFilter;
899   }
900
901   /**
902    * Method declaration
903    *
904    *
905    * @param b
906    */

907   public void setDeployInputFilter(boolean b) {
908     boolean inFilter = false;
909
910     inFilter = PathUtil.isInputInSource(this);
911     if (inFilter) {
912       b = true;
913     }
914     setProperty(DEPLOY_INPUT_FILTER, PropUtil.booleanToString(b));
915   }
916
917   /**
918    * Method declaration
919    *
920    *
921    * @return
922    */

923   public boolean isDeployStartupRun() {
924     String JavaDoc in = getProperty(DEPLOY_STARTUP_RUN);
925
926     return PropUtil.stringToBoolean(in, true);
927   }
928
929   /**
930    * Method declaration
931    *
932    *
933    * @param b
934    */

935   public void setDeployStartupRun(boolean b) {
936     setProperty(DEPLOY_STARTUP_RUN, PropUtil.booleanToString(b));
937   }
938
939   public boolean isDeployStartupJavaReadOnly() {
940     return false;
941   }
942
943   /**
944    * Method declaration
945    *
946    *
947    * @return
948    */

949   public boolean isDeployStartupJava() {
950     boolean javaStartup = false;
951     String JavaDoc in = getProperty(DEPLOY_STARTUP_JAVA);
952
953     javaStartup = PropUtil.stringToBoolean(in, !isOpenBuild());
954     return javaStartup;
955   }
956
957   /**
958    * Method declaration
959    *
960    *
961    * @param b
962    */

963   public void setDeployStartupJava(boolean b) {
964     setProperty(DEPLOY_STARTUP_JAVA, PropUtil.booleanToString(b));
965   }
966
967   /**
968    * Method declaration
969    *
970    *
971    * @return
972    */

973   public String JavaDoc getDeployBootstrapPath() {
974     PathHandle ph = null;
975     File JavaDoc file = null;
976
977     file = PathUtil.getFileRelativeToProject(this, DEPLOY_PATH_BOOTSTRAP);
978     ph = PathHandle.createPathHandle(file);
979     if (ph.isEmpty()) {
980       ph =
981           PathHandle.createPathHandle(PathUtil.getDefaultDeployBootstrapPath(this));
982     }
983     return ph.getPath();
984   }
985
986   /**
987    * Method declaration
988    *
989    *
990    * @param conf
991    */

992   public void setDeployBootstrapPath(String JavaDoc path) {
993     PathUtil.putFileRelativeToProject(this, DEPLOY_PATH_BOOTSTRAP, path);
994   }
995
996   /**
997    * Method declaration
998    *
999    *
1000   * @param conf
1001   */

1002  public void setDodsBootstrapPath(String JavaDoc path) {
1003    PathUtil.putFileRelativeToProject(this, DODS_PATH_BOOTSTRAP, 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 JavaDoc 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 JavaDoc getAutoDeployFilePath() {
1034    String JavaDoc path = new String JavaDoc();
1035    StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
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 JavaDoc path) {
1062    setProperty(PropertyKeys.AUTO_DEPLOY_FILE,
1063                PathHandle.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 JavaDoc getSourcePathOf(OtterFileNode node) {
1124    String JavaDoc out = new String JavaDoc();
1125    String JavaDoc 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 JavaDoc property, boolean b) {
1139    String JavaDoc flag = b ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
1140
1141    setProperty(property, flag);
1142  }
1143
1144  /**
1145   * Method declaration
1146   *
1147   * @param property
1148   * @param def
1149   *
1150   * @return
1151   */

1152  protected boolean readBooleanProperty(String JavaDoc property, boolean def) {
1153    boolean flag = def;
1154    String JavaDoc in = getProperty(property);
1155
1156    return PropUtil.stringToBoolean(in, def);
1157  }
1158
1159  public boolean isSelected() {
1160    return false;
1161  }
1162
1163  public void setSelected(boolean b) {}
1164
1165  public void setException(Throwable JavaDoc e) {}
1166
1167  public Throwable JavaDoc getException() {
1168    return null;
1169  }
1170
1171  private PathHandle getArchivePH() {
1172    PathHandle ph = null;
1173    StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
1174
1175    buf.append(getRootPath());
1176    buf.append(File.separator);
1177    buf.append("archive.properties");
1178    ph = PathHandle.createPathHandle(buf.toString());
1179    return ph;
1180  }
1181
1182  private Properties JavaDoc defaultArchiveProperties() {
1183    Descriptor[] dd = new Descriptor[0];
1184    JarPlan plan = null;
1185    PropertyWriter writer = null;
1186    Properties JavaDoc props = new Properties JavaDoc();
1187    int type = getDeployType();
1188
1189    try {
1190      switch (type) {
1191        case TYPE_WEBAPP:
1192          WarPlan wp = new WarPlan();
1193
1194          wp.setValidate(false);
1195          wp.setContentRoot(PathUtil.getDeployContentPath(this));
1196          dd = new Descriptor[1];
1197          dd[0] = new Descriptor(true, Descriptor.WEB);
1198          dd[0].setPath(getSourcePathArray()[0] + "/WEB-INF/web.xml");
1199          plan = wp;
1200          break;
1201        case TYPE_EN3APP:
1202          plan = new JarPlan();
1203          plan.setValidate(false);
1204          break;
1205//Dusan
1206
/* case TYPE_SERVICE:
1207                plan = new JarPlan();
1208                plan.setValidate(false);
1209                dd = new Descriptor[1];
1210                dd[0] = new Descriptor(true, Descriptor.ENHYDRA_SERVICE);
1211                dd[0].setPath(getSourcePathArray()[0]
1212                              + "/META-INF/enhydra-service.xml");
1213                break; */

1214      }
1215      if (plan != null) {
1216        plan.setDescriptors(dd);
1217        plan.setClassRoot(getClassOutputPath());
1218        plan.setArchivePath(PathUtil.getDefaultDeployArchivePath(this));
1219        writer = new PropertyWriter();
1220        props = writer.write(plan);
1221      }
1222    } catch (ArchiveException e) {
1223      e.printStackTrace(System.err);
1224      if (props == null) {
1225        props = new Properties JavaDoc();
1226      }
1227    }
1228    return props;
1229  }
1230
1231  /**
1232   * Method declaration
1233   *
1234   * @param p
1235   */

1236  public void setDodsParameters(String JavaDoc p) {
1237    setProperty(NAME_DODS_PARAMETERS, p);
1238  }
1239
1240  /**
1241   * Method declaration
1242   *
1243   *
1244   * @return
1245   */

1246  public String JavaDoc getDodsParameters() {
1247    return getProperty(NAME_DODS_PARAMETERS);
1248  }
1249
1250  /**
1251   * Method declaration
1252   *
1253   *
1254   * @return
1255   */

1256  public void setDomlFilePath(String JavaDoc path) {
1257    setProperty(NAME_DOML_FILEPATH, path);
1258  }
1259
1260  /**
1261   * Method declaration
1262   *
1263   *
1264   * @return
1265   */

1266  public String JavaDoc getDomlFilePath() {
1267    return getProperty(NAME_DOML_FILEPATH);
1268  }
1269
1270  /**
1271   * Method declaration
1272   *
1273   *
1274   * @return
1275   */

1276  public String JavaDoc getEnhydraPath() {
1277    return getProperty(DODS_ENHYDRA_PATH);
1278  }
1279
1280  /**
1281   * Method declaration
1282   *
1283   *
1284   * @return
1285   */

1286  public String JavaDoc getProjectJavaPath() {
1287    return getProperty(DODS_PROJECT_JAVA_PATH);
1288  }
1289
1290  /**
1291   * Method declaration
1292   *
1293   *
1294   * @return
1295   */

1296  public void setDodsRootPath(String JavaDoc path) {
1297    setProperty(NAME_DODS_ROOTPATH, path);
1298  }
1299
1300  /**
1301   * Method declaration
1302   *
1303   *
1304   * @return
1305   */

1306  public String JavaDoc getDodsRootPath() {
1307    return getProperty(NAME_DODS_ROOTPATH);
1308  }
1309
1310  /**
1311   * Method declaration
1312   *
1313   *
1314   * @return
1315   */

1316/* public void setExstensionParameter(String ext) {
1317        setProperty(NAME_DODS_EXTENSION, ext);
1318    } */

1319
1320   /**
1321    * Method declaration
1322    *
1323    *
1324    * @return
1325    */

1326/* public String getExstensionParameter() {
1327        return getProperty(NAME_DODS_EXTENSION);
1328    } */

1329
1330   /**
1331    * Method declaration
1332    *
1333    *
1334    * @return
1335    */

1336  public void setDODSGenerator(DODSGenerator gen) {
1337    generator = gen;
1338  }
1339  /**
1340   * Method declaration
1341   *
1342   *
1343   * @return
1344   */

1345  public DODSGenerator getDODSGenerator() {
1346    return generator;
1347  }
1348
1349  /**
1350   * Method declaration
1351   *
1352   *
1353   * @return
1354   */

1355  public void setDocumentationHtml(String JavaDoc html) {
1356    setProperty(NAME_DODS_DOCUMENTATION_HTML, html);
1357  }
1358  /**
1359   * Method declaration
1360   *
1361   *
1362   * @return
1363   */

1364  public String JavaDoc getDocumentationHtml() {
1365    return getProperty(NAME_DODS_DOCUMENTATION_HTML);
1366  }
1367
1368  /**
1369   * Method declaration
1370   *
1371   *
1372   * @return
1373   */

1374  public void setDocumentationPdf(String JavaDoc pdf) {
1375    setProperty(NAME_DODS_DOCUMENTATION_PDF, pdf);
1376  }
1377  /**
1378   * Method declaration
1379   *
1380   *
1381   * @return
1382   */

1383  public String JavaDoc getDocumentationPdf() {
1384    return getProperty(NAME_DODS_DOCUMENTATION_PDF);
1385  }
1386
1387  /**
1388   * Method declaration
1389   *
1390   *
1391   * @return
1392   */

1393  public void setDocumentationXmi(String JavaDoc xmi) {
1394    setProperty(NAME_DODS_DOCUMENTATION_XMI, xmi);
1395  }
1396  /**
1397   * Method declaration
1398   *
1399   *
1400   * @return
1401   */

1402  public String JavaDoc getDocumentationXmi() {
1403    return getProperty(NAME_DODS_DOCUMENTATION_XMI);
1404  }
1405
1406  /**
1407   * Method declaration
1408   *
1409   *
1410   * @return
1411   */

1412  public void setDocumentationPtl(String JavaDoc ptl) {
1413    setProperty(NAME_DODS_DOCUMENTATION_PTL, ptl);
1414  }
1415  /**
1416   * Method declaration
1417   *
1418   *
1419   * @return
1420   */

1421  public String JavaDoc getDocumentationPtl() {
1422    return getProperty(NAME_DODS_DOCUMENTATION_PTL);
1423  }
1424
1425  /**
1426   * Method declaration
1427   *
1428   *
1429   * @return
1430   */

1431  public void setTemplateSet(String JavaDoc temp) {
1432    setProperty(NAME_DODS_TEMPLATE_SET, temp);
1433  }
1434  /**
1435   * Method declaration
1436   *
1437   *
1438   * @return
1439   */

1440  public String JavaDoc getTemplateSet() {
1441    return getProperty(NAME_DODS_TEMPLATE_SET);
1442  }
1443
1444}
Popular Tags