KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > repository > ISolutionRepository


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * 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  * @created Jun 21, 2005
14  * @author James Dixon
15  *
16  */

17
18 package org.pentaho.core.repository;
19
20 import java.io.File JavaDoc;
21 import java.io.FileNotFoundException JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.io.Reader JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Locale JavaDoc;
27 import javax.activation.DataSource JavaDoc;
28 import org.apache.commons.fileupload.FileItem;
29 import org.dom4j.Document;
30 import org.pentaho.core.session.IPentahoSession;
31 import org.pentaho.core.solution.IActionResource;
32 import org.pentaho.core.solution.IActionSequence;
33 import org.pentaho.util.logging.ILogger;
34
35 /**
36  * Defines methods for getting information out of a location holding the Pentaho
37  * solutions.
38  *
39  * @author jdixon
40  *
41  */

42
43 public interface ISolutionRepository extends ILogger {
44   
45     /**
46      * Document being requested for execution
47      */

48     public static final int ACTION_EXECUTE = 1;
49     /**
50      * Document being requested for administration
51      */

52     public static final int ACTION_ADMIN = 2;
53
54     public static final int FILE_EXISTS = 1;
55     public static final int FILE_ADD_FAILED = 2;
56     public static final int FILE_ADD_SUCCESSFUL = 3;
57     public static final int FILE_ADD_INVALID_PUBLISH_PASSWORD = 4;
58     public static final int FILE_ADD_INVALID_USER_CREDENTIALS = 5;
59     
60     /**
61      * Retrieves the action sequence from the repository. Should return <code>null</code> if the
62      * requested action seqeuence is not found.
63      * @param solutionName The name of the solution - like the root folder
64      * @param actionPath The relative path (from the solution) of where the file is stored
65      * @param actionName The name of the action sequence
66      * @param loggingLevel The level at which to log messages
67      * @param actionOperation Whether the action sequence is being retrieved for administration or execution
68      * @return
69      */

70     public IActionSequence getActionSequence(String JavaDoc solutionName, String JavaDoc actionPath, String JavaDoc actionName, int loggingLevel, int actionOperation);
71
72     /**
73      * Gets the contents of a file from the repository.
74      * @param repositoryRoot Root location of the file
75      * @param solutionName Name of the solution
76      * @param filePath Path to the file within the solution
77      * @param fileName File name to get data from
78      * @return InputStream containing data
79      */

80     public InputStream JavaDoc getSolutionFileData(String JavaDoc repositoryRoot, String JavaDoc solutionName, String JavaDoc filePath, String JavaDoc fileName);
81
82     /**
83      * Initializes the solution repository with the user session
84      * @param session The current user session
85      */

86     public void init(IPentahoSession session);
87
88     /**
89      * Gets an XML <tt>Document</tt> representing all the solutions and all the files within all the solutions
90      * @param actionOperation Indicates what the list will be used for - execution or administration
91      * @return Document
92      */

93     public Document getSolutions(int actionOperation);
94     
95     /**
96      * Gets an XML <tt>Document</tt> representing all the files within a certain path within a solution
97      * @param solutionName The name of the solution to get
98      * @param pathName The path from which to retrieve
99      * @param actionOperation Indicates what the list will be used for - execution or administration
100      * @return Document
101      */

102     public Document getSolutions(String JavaDoc solutionName, String JavaDoc pathName, int actionOperation);
103    
104     /**
105      * Returns an XML document that represents the parent/child relationship of the current solution repository
106      *
107      * @param actionOperation
108      * @return an XML document
109      */

110     public Document getSolutionStructure(int actionOperation);
111
112     
113     /**
114      * Returns a list of documents located in the solution and path.
115      *
116      * @param solution - The solution to use
117      * @param path - The path within the solution
118      * @param subDirectories - Should this recursively process sub-directories?
119      * @param visibleOnly - Only include action sequences marked as visible
120      * @param actionOperation - Type of action operation to be performed
121      *
122      * @return - An XML document that represents the documents
123      */

124     public Document getActionSequences(String JavaDoc solution, String JavaDoc path, boolean subDirectories, boolean visibleOnly, int actionOperation);
125
126     /**
127      * Loads or reloads a solution repository after a structure change.
128      *
129      * @param session - The session associated with this solution repository
130      * @param loggingLevel - The requested level of logging
131      */

132     public void publish(IPentahoSession session, int loggingLevel);
133
134     
135     /**
136      * Set the locale to so that the solution repository is rendered in a localized manner.
137      * @param locale
138      */

139     public void setLocale(Locale JavaDoc locale);
140
141     /**
142      * Removes the file (fileName) from the path defined by the solution and path.
143      *
144      * @param solution
145      * @param path
146      * @param fileName
147      * @return - boolean indicating success
148      */

149     public boolean removeSolutionFile(String JavaDoc solution, String JavaDoc path, String JavaDoc fileName);
150
151     /**
152      * Adds a solution to the solution repository defined by the url that is built by
153      * concatenating baseUrl, path, and fileName. The fileName that is added has its
154      * data populated by the data from File (on disk).
155      *
156      * @param baseUrl
157      * @param path
158      * @param fileName
159      * @param fi
160      * @param overwrite
161      * @return - int indicating status of return
162      */

163     public int addSolutionFile(String JavaDoc baseUrl, String JavaDoc path, String JavaDoc fileName, File JavaDoc f, boolean overwrite);
164     
165     
166     /**
167      * Adds a solution to the solution repository defined by the url that is built by
168      * concatenating baseUrl, path, and fileName. The fileName that is added has its
169      * data populated by the data.
170      *
171      * @param baseUrl
172      * @param path
173      * @param fileName
174      * @param data
175      * @param overwrite
176      * @return - int indicating status of return
177      */

178     public int addSolutionFile(String JavaDoc baseUrl, String JavaDoc path, String JavaDoc fileName, byte[] data, boolean overwrite);
179     
180     
181     /**
182      * Returns a long that represents the last time this file was modified
183      *
184      * @param path
185      */

186     public long getSolutionFileLastModified(String JavaDoc path);
187     
188     /**
189      * Returns an appropriate class loader for a specific path
190      *
191      * @param path
192      * @return - A ClassLoader
193      */

194     public ClassLoader JavaDoc getClassLoader(String JavaDoc path);
195
196     
197     /**
198      * Returns an XML document that defines the entire solution tree. This general purpose method
199      * return all files/folders in the solution in an easily understood XML document.
200      *
201      * @param actionOperation
202      * @return
203      */

204     public Document getSolutionTree(int actionOperation);
205
206     /*
207      * The following method do not use the solution, path, action model for resolving resource location.
208      * Instead where indicated a complete path should be provided.
209      */

210     
211     /**
212      * Returns a true if the specified resource exists.
213      *
214      * @param solutionPath - path to the resource
215      * @return - boolean true if resource exists
216      */

217     public boolean resourceExists(String JavaDoc solutionPath);
218
219     /**
220      * Returns the size of the specfied resource. If resource doesn't exit
221      * a -1 is returned
222      *
223      * @param solutionPath - path to the resource
224      * @return - long value of the size
225      */

226     public long resourceSize(String JavaDoc solutionPath);
227
228     /**
229      * Given a IActionResource this method returns a InputStream that references the
230      * content of the actionResource.
231      *
232      * @param actionResource - resource to create a stream for.
233      * @return - InputStream that contains the data of the actionResource
234      */

235     public InputStream JavaDoc getResourceInputStream(IActionResource actionResource);
236
237     /**
238      * Returns an InputStream that contains the data of the resource defined by the
239      * solutionPath.
240      *
241      * @param solutionPath - location of a resource.
242      * @return - InputStream that represents the data of the resource.
243      */

244     public InputStream JavaDoc getResourceInputStream(String JavaDoc solutionPath);
245
246     /**
247      * See getResourceInputStream(IActionResource actionResource). Identical method
248      * except returns results as a Reader. Exceptions are thrown if io error or file is not
249      * found.
250      *
251      * @param actionResource
252      * @return
253      * @throws FileNotFoundException
254      * @throws IOException
255      */

256     public Reader JavaDoc getResourceReader(IActionResource actionResource) throws FileNotFoundException JavaDoc, IOException JavaDoc;
257
258     /**
259      * See getResourceInputStream(String solutionPath). Identical method
260      * except returns results as a Reader. Exceptions are thrown if io error or file is not
261      * found.
262      *
263      * @param solutionPath
264      * @return
265      * @throws FileNotFoundException
266      * @throws IOException
267      */

268     public Reader JavaDoc getResourceReader(String JavaDoc solutionPath) throws FileNotFoundException JavaDoc, IOException JavaDoc;
269
270     /**
271      * See getResourceInputStream(IActionResource actionResource). Identical method
272      * except returns results as a String. Exception is thrown if io error.
273      *
274      * @param actionResource
275      * @return
276      * @throws IOException
277      */

278     public String JavaDoc getResourceAsString(IActionResource actionResource) throws IOException JavaDoc;
279
280     /**
281      * See getResourceInputStream(String solutionPath). Identical method
282      * except returns results as a String. Exception is thrown if io error.
283      *
284      * @param solutionPath
285      * @return
286      * @throws IOException
287      */

288     public String JavaDoc getResourceAsString(String JavaDoc solutionPath) throws IOException JavaDoc;
289
290     /**
291      * See getResourceInputStream(String solutionPath). Identical method
292      * except returns results as a DataSource.
293      *
294      * @param solutionPath
295      * @return
296      */

297     public DataSource JavaDoc getResourceDataSource(String JavaDoc solutionPath);
298
299     /**
300      * See getResourceInputStream(IActionResource actionResource). Identical method
301      * except returns results as a DataSource.
302      *
303      * @param solutionPath
304      * @return
305      */

306     public DataSource JavaDoc getResourceDataSource(IActionResource actionResource);
307
308     /**
309      * See getResourceInputStream(String solutionPath). Identical method
310      * except returns results as a Document.
311      *
312      * @param solutionPath
313      * @return
314      */

315     public Document getResourceAsDocument(String JavaDoc solutionPath) throws IOException JavaDoc;
316
317     /**
318      * See getResourceInputStream(IActionResource actionResource). Identical method
319      * except returns results as a Document.
320      *
321      * @param solutionPath
322      * @return
323      */

324     public Document getResourceAsDocument(IActionResource actionResource) throws IOException JavaDoc;
325     
326     /**
327      *
328      * @return
329      * An array of Strings where each string is the fully qualified path of
330      * every *.xaction contained in the repository.
331      */

332     
333     public String JavaDoc[] getAllActionSequences();
334     
335     /**
336      * Allows the caller to provide a List that will contain all log messages generated by the Solution Repository
337      * represented by this interface
338      *
339      * @param messages a List that String messages will be appended to
340      */

341     public void setMessages(List JavaDoc messages);
342
343     /**
344      * Return the message list, if any, that all log messages generated by this Solution Repository
345      * are being appended to
346      *
347      * @return List of String messages
348      */

349     public List JavaDoc getMessages();
350
351     
352 }
353
Popular Tags