~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/location/LocationManager.java

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.hisp.dhis.external.location;
 
2
 
 
3
/*
 
4
 * Copyright (c) 2004-2007, University of Oslo
 
5
 * All rights reserved.
 
6
 *
 
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.
 
17
 *
 
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.
 
28
 */
 
29
 
 
30
import java.io.File;
 
31
import java.io.InputStream;
 
32
import java.io.OutputStream;
 
33
 
 
34
/**
 
35
 * @author Lars Helge Overland
 
36
 * @version $Id$
 
37
 */
 
38
public interface LocationManager
 
39
{
 
40
    String ID = LocationManager.class.getName();
 
41
    
 
42
    /**
 
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.
 
48
     * 
 
49
     * @param fileName the name of the file to be read.
 
50
     */
 
51
    InputStream getInputStream( String fileName )
 
52
        throws LocationManagerException;
 
53
    
 
54
    /**
 
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.
 
60
     * 
 
61
     * @param fileName the name of the file to be read.
 
62
     */
 
63
    InputStream getInputStream( String fileName, String... directories )
 
64
        throws LocationManagerException;
 
65
    
 
66
    /**
 
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.
 
71
     * 
 
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.
 
75
     */
 
76
    File getFileForReading( String fileName )
 
77
        throws LocationManagerException;
 
78
 
 
79
    /**
 
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.
 
84
     * 
 
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.
 
88
     */
 
89
    File getFileForReading( String fileName, String... directories )
 
90
        throws LocationManagerException;
 
91
    
 
92
    /**
 
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.
 
96
     * 
 
97
     * @param fileName the name of the file to be written.
 
98
     */
 
99
    File getFileForWriting( String fileName )
 
100
        throws LocationManagerException;
 
101
 
 
102
    /**
 
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.
 
108
     * 
 
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.
 
112
     */
 
113
    File getFileForWriting( String fileName, String... directories )
 
114
        throws LocationManagerException;
 
115
    
 
116
 
 
117
    /**
 
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.
 
122
     * 
 
123
     * @param fileName the name of the file to be written.
 
124
     */
 
125
    OutputStream getOutputStream( String fileName )
 
126
        throws LocationManagerException;
 
127
    
 
128
    /**
 
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.
 
135
     * 
 
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.
 
139
     */
 
140
    OutputStream getOutputStream( String fileName, String... directories )
 
141
        throws LocationManagerException;
 
142
    
 
143
    /**
 
144
     * Gets the external configuration directory. A LocationManagerException is 
 
145
     * thrown if the external directory location is not set.
 
146
     */
 
147
    File getExternalDirectory()
 
148
        throws LocationManagerException;
 
149
    
 
150
    /**
 
151
     * Indicates whether the external configuration directory is set, valid,
 
152
     * and writeable.
 
153
     */
 
154
    boolean externalDirectorySet();
 
155
    
 
156
    /**
 
157
     * Gets the name of the environment variable used for defining the external
 
158
     * configuration directory.
 
159
     */
 
160
    String getEnvironmentVariable();
 
161
}