Source Code Cross Referenced for GenericFileProjectApplication.java in  » Workflow-Engines » JFolder » org » jfolder » workflow » lifecycle » 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 » Workflow Engines » JFolder » org.jfolder.workflow.lifecycle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


        /*
         * JFolder, Copyright 2001-2006 Gary Steinmetz
         *
         * Distributable under LGPL license.
         * See terms of license at gnu.org.
         */

        package org.jfolder.workflow.lifecycle;

        //base classes
        import java.io.File;
        import java.io.FileInputStream;
        import java.io.FileNotFoundException;
        import java.io.FileOutputStream;
        import java.io.IOException;
        import java.util.ArrayList;
        import java.util.Enumeration;
        import java.util.Properties;

        //project specific classes
        import org.jfolder.common.UnexpectedSystemException;
        import org.jfolder.common.utils.misc.MiscHelper;
        import org.jfolder.project.model.ProjectApplication;
        import org.jfolder.project.model.ProjectScript;
        import org.jfolder.project.model.ProjectWebFile;
        import org.jfolder.project.model.ProjectWebPage;

        //other classes

        /*public class GenericFileProjectApplication implements ProjectApplication {
        
         private final static String DEFAULT_DESCRIPTION =
         "Put your description here for application ";
         private File file = null;
         private String description = null;
         private File descriptionFile = null;
         private Properties properties = null;
         private File propertiesFile = null;
         private GenericFileProjectScript script = null;
         private ArrayList webPages = null;
         private ArrayList webFiles = null;
        
         protected GenericFileProjectApplication(File inFile) {
        
         try {
         //initialization
         this.file = inFile;
         this.webPages = new ArrayList();
         this.webFiles = new ArrayList();
        
         //script
         this.script = new GenericFileProjectScript(
         new File(this.file, "script.xml"), this.file.getName());
        
         //description
         this.description = DEFAULT_DESCRIPTION + this.file.getName();
         this.descriptionFile = new File(this.file, "description.txt");
         if (this.descriptionFile.exists()) {
         this.description =
         MiscHelper.readTextFile(this.descriptionFile);
         }
        
         //properties
         this.properties = new Properties();
         //this.properties.setProperty("PF_VERSION",
         //VersionHelper.PF_VERSION);
         this.propertiesFile = new File(this.file, "application.properties");
         if (this.propertiesFile.exists()) {
         this.properties = new Properties();
         this.properties.load(new FileInputStream(this.propertiesFile));
         }
        
         //web pages
         File webPagesDir = getWebPagesDirectory(this.file);
         //MiscHelper.println("webPagesDir = "
         //+ webPagesDir.getAbsolutePath());
         File webPages[] = webPagesDir.listFiles();
         for (int i = 0; i < webPages.length; i++) {
         File nextWebPage = webPages[i];
         if (nextWebPage.isFile()) {
         //&& nextWebPage.getName().endsWith(".jsp")) {
         this.webPages.add(
         new GenericFileProjectWebPage(nextWebPage));
         }
         }
        
         //web files
         File webFilesDir = getWebFilesDirectory(this.file);
         //MiscHelper.println("webFilesDir = "
         //+ webFilesDir.getAbsolutePath());
         File webFiles[] = webFilesDir.listFiles();
         for (int i = 0; i < webFiles.length; i++) {
         File nextWebFile = webFiles[i];
         if (nextWebFile.isFile()) {
         this.webFiles.add(
         new GenericFileProjectWebFile(nextWebFile));
         }
         }
         }
         catch (FileNotFoundException fnfe) {
         throw new UnexpectedSystemException(fnfe);
         }
         catch (IOException ioe) {
         throw new UnexpectedSystemException(ioe);
         }
        
         }
        
         protected void load() {
        
         try {
        
         if (!this.file.exists()) {
         this.file.mkdirs();
         }
        
         this.script.load();
        
         this.description = MiscHelper.readTextFile(this.descriptionFile);
         if (this.propertiesFile.exists()) {
         this.properties = new Properties();
         this.properties.load(new FileInputStream(this.propertiesFile));
         }
        
         for (int i = 0; i < this.webPages.size(); i++) {
         GenericFileProjectWebPage gfwwp =
         (GenericFileProjectWebPage)this.webPages.get(i);
         gfwwp.load();
         }
        
         for (int i = 0; i < this.webFiles.size(); i++) {
         GenericFileProjectWebFile gfwwf =
         (GenericFileProjectWebFile)this.webFiles.get(i);
         gfwwf.load();
         }
         }
         catch (IOException ioe) {
         throw new UnexpectedSystemException(ioe);
         }
         }
        
         protected void store() {
        
         try {
         //MiscHelper.println("Storing application at - "
         //    + this.file.getAbsolutePath());
        
         if (!this.file.exists()) {
         this.file.mkdirs();
         }
        
         this.script.store();
        
         this.properties.store(new FileOutputStream(this.propertiesFile),
         "Properties for application '" + getName() + "'");
        
         MiscHelper.writeTextFile(this.descriptionFile, this.description);
        
         //create pages and files directories
         getWebPagesDirectory(this.file);
         getWebFilesDirectory(this.file);
        
         for (int i = 0; i < this.webPages.size(); i++) {
         GenericFileProjectWebPage gfwwp =
         (GenericFileProjectWebPage)this.webPages.get(i);
         gfwwp.store();
         }
        
         for (int i = 0; i < this.webFiles.size(); i++) {
         GenericFileProjectWebFile gfwwf =
         (GenericFileProjectWebFile)this.webFiles.get(i);
         gfwwf.store();
         }
         }
         catch (IOException ioe) {
         throw new UnexpectedSystemException(ioe);
         }
         }
        
         private File getWebPagesDirectory(File inFile) {
         File outValue = null;
         outValue = new File(inFile, "pages");
         if (!outValue.exists()) {
         outValue.mkdirs();
         }
         return outValue;
         }
        
         private File getWebFilesDirectory(File inFile) {
         File outValue = null;
         outValue = new File(inFile, "files");
         if (!outValue.exists()) {
         outValue.mkdirs();
         }
         return outValue;
         }
        
         public String getName() {
         return this.file.getName();
         }
        
         public String getDescription() {
        
         String outValue = null;
        
         //if (this.description != null) {
         //}
         //else {
         //    File d = new File(this.file, "description.txt");
         //    String text = MiscHelper.readTextFile(d);
         //    this.description = text;
         //}
         outValue = this.description;
        
         return outValue;
         }
        
         public void setDescription(String inDescription) {
         this.description = inDescription;
         //File d = new File(this.file, "description.txt");
         //MiscHelper.writeTextFile(d, inDescription);
         }
        
         public ProjectScript getScript() {
        
         ProjectScript outValue = null;
        
         //if (this.script != null) {
         //}
         //else {
         //    File d = new File(this.file, "script.xml");
         //    String text = MiscHelper.readTextFile(d);
         //    this.script = text;
         //}
         outValue = this.script;
        
         return outValue;
         }
        
         //public void setScript(String inScript) {
         //    this.script = inScript;
         //    File d = new File(this.file, "script.xml");
         //    MiscHelper.writeTextFile(d, inScript);
         //}
        
         public String getFormattedDate() {
         return MiscHelper.formatTime(this.file.lastModified());
         }
        
         public int getWebPageCount() {
         return this.webPages.size();
         }
        
         public ProjectWebPage getWebPage(int inIndex) {
         return (ProjectWebPage)this.webPages.get(inIndex);
         }
        
         public ProjectWebPage getWebPage(String inPage) {
        
         ProjectWebPage outValue = null;
        
         for (int i = 0; i < this.webPages.size(); i++) {
         ProjectWebPage wwp = (ProjectWebPage)this.webPages.get(i);
         if (wwp.getName().equalsIgnoreCase(inPage)) {
         outValue = wwp;
         break;
         }
         }
        
         return outValue;
         }
        
         public int getWebFileCount() {
         return this.webFiles.size();
         }
        
         public ProjectWebFile getWebFile(int inIndex) {
         return (ProjectWebFile)this.webFiles.get(inIndex);
         }
        
         public ProjectWebFile getWebFile(String inFile) {
        
         ProjectWebFile outValue = null;
        
         for (int i = 0; i < this.webFiles.size(); i++) {
         ProjectWebFile wwf = (ProjectWebFile)this.webFiles.get(i);
         if (wwf.getName().equalsIgnoreCase(inFile)) {
         outValue = wwf;
         break;
         }
         }
        
         return outValue;
         }
        
         public void removeWebPage(String inPage) {
        
         //File webPagesDir = getWebPagesDirectory(this.file);
         //String webPageName = getWebPage(inPage).getName();
         //File webPage = new File(webPagesDir, webPageName);
         //MiscHelper.println("webPage = " + webPage.getAbsolutePath());
         //MiscHelper.println("this.webPages.size() = " + this.webPages.size());
         //MiscHelper.deleteFileOrDirectory(webPage);
        
         for (int i = 0; i < this.webPages.size(); i++) {
         ProjectWebPage wwp = (ProjectWebPage)this.webPages.get(i);
         if (wwp.getName().equalsIgnoreCase(inPage)) {
         this.webPages.remove(i);
         break;
         }
         }
         }
        
         public void removeWebFile(String inFile) {
        
         //File webFilesDir = getWebFilesDirectory(this.file);
         //String webFileName = getWebFile(inFile).getName();
         //File webFile = new File(webFilesDir, webFileName);
         //MiscHelper.println("webPage = " + webPage.getAbsolutePath());
         //MiscHelper.println("this.webPages.size() = " + this.webPages.size());
         //MiscHelper.deleteFileOrDirectory(webFile);
        
         for (int i = 0; i < this.webFiles.size(); i++) {
         ProjectWebFile wwf = (ProjectWebFile)this.webFiles.get(i);
         if (wwf.getName().equalsIgnoreCase(inFile)) {
         this.webFiles.remove(i);
         break;
         }
         }
         }
        
         public void addWebFile(String inName, byte inContent[]) {
         //try {
         ProjectWebFile wwf = getWebFile(inName);
         if (wwf != null) {
         removeWebFile(wwf.getName());
         }
         File webFilesDir = getWebFilesDirectory(this.file);
         File webFile = new File(webFilesDir, inName);
         //
         //FileOutputStream fos = new FileOutputStream(webFile);
         //fos.write(inContent);
         //fos.flush();
         //fos.close();
        
         GenericFileProjectWebFile gfwwf =
         new GenericFileProjectWebFile(webFile);
         gfwwf.setContent(inContent);
         this.webFiles.add(gfwwf);
         //}
         //catch (IOException ioe) {
         //    throw new UnexpectedSystemException(ioe);
         //}
         }
        
         public void addWebPage(String inName) {
         //try {
         ProjectWebPage wwp = getWebPage(inName);
         if (wwp == null) {
         File webPagesDir = getWebPagesDirectory(this.file);
         File webPage = new File(webPagesDir, inName);
         //
         //FileWriter fw = new FileWriter(webPage);
         //fw.write(DEFAULT_WEB_PAGE);
         //fw.flush();
         //fw.close();
        
         this.webPages.add(
         new GenericFileProjectWebPage(webPage));
         }
         //}
         //catch (IOException ioe) {
         //    throw new UnexpectedSystemException(ioe);
         //}
         }
        
        
         public String[] getPropertyNames() {
        
         String outValue[] = null;
        
         Enumeration enum = this.properties.propertyNames();
        
         ArrayList propNames = new ArrayList();
        
         while (enum.hasMoreElements()) {
         propNames.add((String)enum.nextElement());
         }
        
         outValue = new String[propNames.size()];
         for (int i = 0; i < propNames.size(); i++) {
         outValue[i] = (String)propNames.get(i);
         }
        
         return outValue;
         }
        
         public String getPropertyValue(String inName) {
        
         String outValue = "";
        
         //if (this.properties.getProperty(inName.toUpperCase()) != null) {
         if (this.properties.getProperty(inName) != null) {
         //outValue = this.properties.getProperty(inName.toUpperCase());
         outValue = this.properties.getProperty(inName);
         }
        
         return outValue;
         }
        
         public Properties getProperties() {
         return this.properties;
         }
        
         public void setPropertyValue(String inName, String inValue) {
         //this.properties.setProperty(inName.toUpperCase(), inValue);
         this.properties.setProperty(inName, inValue);
         }
        
         public boolean isPropertyPresent(String inName) {
         //return (this.properties.getProperty(inName.toUpperCase()) != null);
         return (this.properties.getProperty(inName) != null);
         }
        
         public void removeProperty(String inName) {
         //this.properties.setProperty(inName.toUpperCase(), null);
         //this.properties.remove(inName.toUpperCase());
         this.properties.remove(inName);
         }
         }*/
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.