1
package org.hisp.dhis.external.location;
4
* Copyright (c) 2004-2007, University of Oslo
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright notice, this
10
* list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright notice,
12
* this list of conditions and the following disclaimer in the documentation
13
* and/or other materials provided with the distribution.
14
* * Neither the name of the HISP project nor the names of its contributors may
15
* be used to endorse or promote products derived from this software without
16
* specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
import java.io.InputStream;
32
import java.io.OutputStream;
35
* @author Lars Helge Overland
38
public interface LocationManager
40
String ID = LocationManager.class.getName();
43
* Gets an inputstream from a file relative to the external configuration directory
44
* location, which is set through an environment variable. A LocationManagerException
45
* is thrown if the external directory location is not set, if the file
46
* does not exists, or cannot be read by the application. The inputstream should
47
* be closed by the client code after use.
49
* @param fileName the name of the file to be read.
51
InputStream getInputStream( String fileName )
52
throws LocationManagerException;
55
* Gets an inputstream from a file relative to the external configuration directory
56
* location, which is set through an environment variable. A LocationManagerException
57
* is thrown if the external directory location is not set, if the file
58
* does not exists, or cannot be read by the application. The inputstream should
59
* be closed by the client code after use.
61
* @param fileName the name of the file to be read.
63
InputStream getInputStream( String fileName, String... directories )
64
throws LocationManagerException;
67
* Gets a file relative to the external configuration directory location,
68
* which is set through an environment variable. A LocationManagerException
69
* is thrown if the external directory location is not set, if the file
70
* does not exists, or cannot be read by the application.
72
* @param fileName the name of the file to be read.
73
* @param directories the directories in the path relative to the external
74
* configuration directory in descending order.
76
File getFileForReading( String fileName )
77
throws LocationManagerException;
80
* Gets a file relative to the external configuration directory location,
81
* which is set through an environment variable. A LocationManagerException
82
* is thrown if the external directory location is not set, if the file
83
* does not exists, or cannot be read by the appliation.
85
* @param fileName the name of the file to be read.
86
* @param directories the directories in the path relative to the external
87
* configuration directory in descending order.
89
File getFileForReading( String fileName, String... directories )
90
throws LocationManagerException;
93
* Gets a file relative to the external configuration directory location,
94
* which is set through an environment variable. A LocationManagerException
95
* is thrown if the external directory location is not set.
97
* @param fileName the name of the file to be written.
99
File getFileForWriting( String fileName )
100
throws LocationManagerException;
103
* Gets a file relative to the external configuration directory location,
104
* which is set through an environment variable. A LocationManagerException
105
* is thrown if the external directory location is not set. The method tries
106
* to construct the directories passed as arguments if they do not already
107
* exist, and trows a LocationManagerException if the process was unsuccessful.
109
* @param fileName the name of the file to be written.
110
* @param directories the directories in the path relative to the external
111
* configuration directory.
113
File getFileForWriting( String fileName, String... directories )
114
throws LocationManagerException;
118
* Gets an outputstream from a file relative to the external configuration directory
119
* location, which is set through an environment variable. A LocationManagerException
120
* is thrown if the external directory location is not set. The outputstream
121
* should be closed by the client code after use.
123
* @param fileName the name of the file to be written.
125
OutputStream getOutputStream( String fileName )
126
throws LocationManagerException;
129
* Gets an outputstream from a file relative to the external configuration directory
130
* location, which is set through an environment variable. A LocationManagerException
131
* is thrown if the external directory location is not set. The method tries
132
* to construct the directories passed as arguments if they do not already
133
* exist, and trows a LocationManagerException if the process was unsuccessful. The
134
* outputstream should be closed by the client code after use.
136
* @param fileName the name of the file to be written.
137
* @param directories the directories in the path relative to the external
138
* configuration directory.
140
OutputStream getOutputStream( String fileName, String... directories )
141
throws LocationManagerException;
144
* Gets the external configuration directory. A LocationManagerException is
145
* thrown if the external directory location is not set.
147
File getExternalDirectory()
148
throws LocationManagerException;
151
* Indicates whether the external configuration directory is set, valid,
154
boolean externalDirectorySet();
157
* Gets the name of the environment variable used for defining the external
158
* configuration directory.
160
String getEnvironmentVariable();