Source Code Cross Referenced for SolutionRepositoryVfsFileObject.java in  » Report » pentaho-report » org » pentaho » repository » filebased » solution » 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 » Report » pentaho report » org.pentaho.repository.filebased.solution 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms 
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use 
005:         * this file except in compliance with the license. If you need a copy of the license, 
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho 
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS" 
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
011:         * the license for the specific language governing your rights and limitations.
012:         */
013:        package org.pentaho.repository.filebased.solution;
014:
015:        import java.net.URL;
016:        import java.util.ArrayList;
017:        import java.util.List;
018:
019:        import org.apache.commons.vfs.FileContent;
020:        import org.apache.commons.vfs.FileName;
021:        import org.apache.commons.vfs.FileObject;
022:        import org.apache.commons.vfs.FileSelector;
023:        import org.apache.commons.vfs.FileSystem;
024:        import org.apache.commons.vfs.FileSystemException;
025:        import org.apache.commons.vfs.FileType;
026:        import org.apache.commons.vfs.NameScope;
027:        import org.apache.commons.vfs.operations.FileOperations;
028:        import org.pentaho.core.repository.ISolutionRepository;
029:        import org.pentaho.core.solution.ISolutionFile;
030:        import org.pentaho.core.system.PentahoSystem;
031:        import org.pentaho.core.system.PentahoSystem.ActionInfo;
032:
033:        public class SolutionRepositoryVfsFileObject implements  FileObject {
034:
035:            private String solution;
036:
037:            private String path;
038:
039:            private String action;
040:
041:            private String fileRef;
042:
043:            private ISolutionRepository repository;
044:
045:            private FileContent content = null;
046:
047:            private FileName name;
048:
049:            private FileType type;
050:
051:            public SolutionRepositoryVfsFileObject(String fileRef,
052:                    ISolutionRepository repository) {
053:                super ();
054:                this .repository = repository;
055:                this .fileRef = fileRef;
056:                // try to guess the file type
057:                ActionInfo info = PentahoSystem.parseActionString(fileRef,
058:                        false);
059:                if (info != null) {
060:                    solution = info.getSolutionName();
061:                    path = info.getPath();
062:                    action = info.getActionName();
063:                    if (action == null) {
064:                        type = FileType.FOLDER;
065:                    } else {
066:                        type = FileType.FILE;
067:                    }
068:                } else {
069:                    type = FileType.FOLDER;
070:                }
071:                name = new SolutionRepositoryFileName(fileRef, type);
072:
073:            }
074:
075:            public SolutionRepositoryVfsFileObject(String fileRef,
076:                    ISolutionRepository repository, FileType type) {
077:                super ();
078:                this .repository = repository;
079:                this .fileRef = fileRef;
080:                ActionInfo info = PentahoSystem.parseActionString(fileRef,
081:                        false);
082:                if (info != null) {
083:                    solution = info.getSolutionName();
084:                    path = info.getPath();
085:                    action = info.getActionName();
086:                } else {
087:                    solution = null;
088:                    path = null;
089:                    action = null;
090:                }
091:                this .type = type;
092:                name = new SolutionRepositoryFileName(fileRef, type);
093:
094:            }
095:
096:            public ISolutionRepository getRepository() {
097:                return repository;
098:            }
099:
100:            public String getFileRef() {
101:                return fileRef;
102:            }
103:
104:            public FileName getName() {
105:                return name;
106:            }
107:
108:            public URL getURL() throws FileSystemException {
109:                URL url = null;
110:                try {
111:                    url = new URL(
112:                            "solution:/" + solution + "/" + path + "/" + action); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
113:                } catch (Exception e) {
114:
115:                }
116:                return url;
117:            }
118:
119:            public boolean exists() throws FileSystemException {
120:                return repository.resourceExists(fileRef);
121:            }
122:
123:            public boolean isHidden() throws FileSystemException {
124:                // not needed for our usage
125:                return false;
126:            }
127:
128:            public boolean isReadable() throws FileSystemException {
129:                // not needed for our usage
130:                return exists();
131:            }
132:
133:            public boolean isWriteable() throws FileSystemException {
134:                // not needed for our usage
135:                return false;
136:            }
137:
138:            public FileType getType() throws FileSystemException {
139:                return type;
140:            }
141:
142:            public FileObject getParent() throws FileSystemException {
143:                // not needed for our usage
144:                return null;
145:            }
146:
147:            public FileSystem getFileSystem() {
148:                // not needed for our usage
149:                return null;
150:            }
151:
152:            public FileObject[] getChildren() throws FileSystemException {
153:
154:                List fileList = new ArrayList();
155:                if (solution == null) {
156:                    // return a list of solutions
157:                    ISolutionFile files[] = repository.getRootFolder()
158:                            .listFiles();
159:                    for (int i = 0; i < files.length; i++) {
160:                        if (files[i].isDirectory()) {
161:                            System.out
162:                                    .println("solution: " + files[i].getFileName());//$NON-NLS-1$
163:                            SolutionRepositoryVfsFileObject fileInfo = new SolutionRepositoryVfsFileObject(
164:                                    "/" + files[i].getFileName(), repository, FileType.FOLDER);//$NON-NLS-1$
165:                            fileList.add(fileInfo);
166:                        }
167:                    }
168:                } else {
169:                    ISolutionFile file = repository.getFileByPath(fileRef);
170:                    ISolutionFile files[] = file.listFiles();
171:                    for (int i = 0; i < files.length; i++) {
172:                        if (files[i].isDirectory()) {
173:                            System.out
174:                                    .println("folder: " + files[i].getFileName());//$NON-NLS-1$
175:                            SolutionRepositoryVfsFileObject fileInfo = new SolutionRepositoryVfsFileObject(
176:                                    "/" + files[i].getFileName(), repository, FileType.FOLDER);//$NON-NLS-1$
177:                            fileList.add(fileInfo);
178:                        } else {
179:                            System.out
180:                                    .println("file: " + files[i].getFileName());//$NON-NLS-1$
181:                            SolutionRepositoryVfsFileObject fileInfo = new SolutionRepositoryVfsFileObject(
182:                                    fileRef + "/" + files[i].getFileName(), repository, FileType.FILE);//$NON-NLS-1$
183:                            fileList.add(fileInfo);
184:                        }
185:                    }
186:
187:                }
188:                FileObject fileObjects[] = new FileObject[fileList.size()];
189:                fileList.toArray(fileObjects);
190:                return fileObjects;
191:            }
192:
193:            public FileObject getChild(String arg0) throws FileSystemException {
194:                // not needed for our usage
195:                return null;
196:            }
197:
198:            public FileObject resolveFile(String arg0, NameScope arg1)
199:                    throws FileSystemException {
200:                // not needed for our usage
201:                return null;
202:            }
203:
204:            public FileObject resolveFile(String arg0)
205:                    throws FileSystemException {
206:                // not needed for our usage
207:                return null;
208:            }
209:
210:            public FileObject[] findFiles(FileSelector arg0)
211:                    throws FileSystemException {
212:                // not needed for our usage
213:                return null;
214:            }
215:
216:            public void findFiles(FileSelector arg0, boolean arg1, List arg2)
217:                    throws FileSystemException {
218:                // not needed for our usage
219:            }
220:
221:            public boolean delete() throws FileSystemException {
222:                // not needed for our usage
223:                return false;
224:            }
225:
226:            public int delete(FileSelector arg0) throws FileSystemException {
227:                // not needed for our usage
228:                return 0;
229:            }
230:
231:            public void createFolder() throws FileSystemException {
232:                // not needed for our usage
233:
234:            }
235:
236:            public void createFile() throws FileSystemException {
237:                // not needed for our usage
238:
239:            }
240:
241:            public void copyFrom(FileObject arg0, FileSelector arg1)
242:                    throws FileSystemException {
243:                // not needed for our usage
244:
245:            }
246:
247:            public void moveTo(FileObject arg0) throws FileSystemException {
248:                // not needed for our usage
249:            }
250:
251:            public boolean canRenameTo(FileObject arg0) {
252:                // not needed for our usage
253:                return false;
254:            }
255:
256:            public FileContent getContent() throws FileSystemException {
257:                content = new SolutionRepositoryVfsFileContent(this );
258:                return content;
259:            }
260:
261:            public void close() throws FileSystemException {
262:                if (content != null) {
263:                    content.close();
264:                    content = null;
265:                }
266:            }
267:
268:            public void refresh() throws FileSystemException {
269:                // not needed for our usage
270:            }
271:
272:            public boolean isAttached() {
273:                // not needed for our usage
274:                return false;
275:            }
276:
277:            public boolean isContentOpen() {
278:                return content != null && content.isOpen();
279:            }
280:
281:            public FileOperations getFileOperations()
282:                    throws FileSystemException {
283:                // not needed for our usage
284:                return null;
285:            }
286:
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.