01: /*
02: * Copyright 2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.repository.filebased.solution;
14:
15: import java.util.Collection;
16:
17: import org.apache.commons.vfs.FileName;
18: import org.apache.commons.vfs.FileObject;
19: import org.apache.commons.vfs.FileSystemConfigBuilder;
20: import org.apache.commons.vfs.FileSystemException;
21: import org.apache.commons.vfs.FileSystemOptions;
22: import org.apache.commons.vfs.provider.FileProvider;
23: import org.pentaho.core.repository.ISolutionRepository;
24:
25: public class SolutionRepositoryVfs implements FileProvider {
26:
27: private static final ThreadLocal threadSolutionRepositories = new ThreadLocal();
28:
29: public SolutionRepositoryVfs() {
30: super ();
31: }
32:
33: public static final void setSolutionRepository(
34: ISolutionRepository repository) {
35: threadSolutionRepositories.set(repository);
36: }
37:
38: private static final ISolutionRepository getSolutionRepository() {
39: return (ISolutionRepository) threadSolutionRepositories.get();
40: }
41:
42: public FileObject findFile(FileObject baseFile, String uri,
43: FileSystemOptions arg2) throws FileSystemException {
44:
45: // for now assume that all URIs are absolute and we don't handle compound URIs
46: if (uri != null) {
47: // this is a fully qualified file path
48: int pos = uri.indexOf(':');
49: String solutionPath = uri.substring(pos + 1);
50: ISolutionRepository repository = getSolutionRepository();
51: if (repository != null) {
52: SolutionRepositoryVfsFileObject fileInfo = new SolutionRepositoryVfsFileObject(
53: solutionPath, repository);
54: return fileInfo;
55: }
56:
57: }
58: return null;
59: }
60:
61: public FileObject createFileSystem(String arg0, FileObject arg1,
62: FileSystemOptions arg2) throws FileSystemException {
63: // not needed for our usage
64: return null;
65: }
66:
67: public FileSystemConfigBuilder getConfigBuilder() {
68: // not needed for our usage
69: return null;
70: }
71:
72: public Collection getCapabilities() {
73: // not needed for our usage
74: return null;
75: }
76:
77: public FileName parseUri(FileName arg0, String arg1)
78: throws FileSystemException {
79: // not needed for our usage
80: return null;
81: }
82:
83: }
|