1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.ginp.setup;
21
22 import java.io.FileNotFoundException;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.UnsupportedEncodingException;
26 import java.net.MalformedURLException;
27 import java.net.URL;
28 import java.util.List;
29
30 import javax.xml.transform.TransformerException;
31
32 import net.sf.ginp.setup.data.SetupVisit;
33
34 import org.dom4j.Document;
35 import org.dom4j.DocumentException;
36
37 /**
38 * Utilities for doing the initital configuration of ginp
39 * @author Justin Sher
40 *
41 */
42 public interface SetupManager {
43
44 /**
45 * Is there an existing valid config on this machine?
46 * @param configUrl the config to check
47 * @return true or false.
48 */
49 boolean configExists(URL configUrl);
50
51 /**
52 * Delete the configuration entry for this host
53 * @param configUrl the url that the config is for
54 * @throws SetupException
55 */
56 void deleteConfiguration(URL configUrl) throws SetupException;
57
58 /**
59 * Create a configuration
60 * @param configUrl the url to configure for
61 * @param configuration the configuration value
62 * @throws SetupException
63 */
64 void createConfiguration(URL configUrl, String configuration) throws SetupException;
65
66 /**
67 * Retrieve a configuration
68 * @param configUrl the url the config is for
69 * @return the configuration parameter
70 */
71
72
73 /**
74 * Check if this is a valid location for a config file
75 * that means usually is this directory writable
76 * @param path the path
77 * @return valid or invalid boolean
78 */
79 Boolean validConfigLoc(String path);
80
81 /**
82 * Tests if a configuration passes validation
83 * @param stream an input stream containing the file
84 * @return the config as a document
85 * @throws SetupException if there's an error with the document
86 * @throws IOException
87 */
88 Document testValidConfig(InputStream stream) throws SetupException, IOException;
89
90 /**
91 * Test for valid picture location. That means writable and readable
92 * @param path the file system path
93 * @return true or false if its a valid location
94 */
95 Boolean validPicturesLoc(String path);
96
97 /**
98 * Build and write config file for Ginp from the Tapestry Setup Visit Object
99 * @param visit the visit object
100 * @return the config file as a document obj
101 * @throws SetupException
102 */
103 Document writeConfigFromVisit(SetupVisit visit) throws SetupException;
104
105 /**
106 * Transform the visit for the file page
107 * @param sampleConfig the config file.
108 * @return the HTML fragment that goes in the document
109 * @throws DocumentException
110 * @throws TransformerException
111 */
112 String finalPageTransform(SetupVisit sampleConfig) throws TransformerException, DocumentException;
113
114 /**
115 * Parses a setup visit out of a command line
116 * @param argv the command line args
117 * @return the setup visit
118 * @throws TransformerException if problem generating config from sample visit
119 * @throws DocumentException if problem generating config from sample visit
120 * @throws SetupException if some exception while initializing
121 */
122 SetupVisit getSetupVisitForCommandLine(String[] argv) throws SetupException, DocumentException, TransformerException;
123
124 /**
125 * Generates a command line from a setup visit
126 * @param visit the setup visit
127 * @return the command line
128 */
129 String getCommandLineForSetupVisit(SetupVisit visit);
130
131 /**
132 * Write a config file to disk
133 * @param visit the Setup Visit object containing the config file path
134 * @param stream the document to read the data to write from
135 * @return success
136 * @throws IOException read/write error
137 * @throws UnsupportedEncodingException read/write error
138 * @throws FileNotFoundException file to write to not found
139 */
140 boolean writeConfig(SetupVisit visit, Document stream) throws FileNotFoundException, UnsupportedEncodingException, IOException;
141
142 /**
143 * Find the available directories to configure in the sample configuration
144 * @param sampleConfig the sample configuration setup object
145 * @return the list of picture directories
146 */
147 List getDirectoriesInPictureDirectory(SetupVisit sampleConfig);
148
149 /**
150 * Write the configuration into the preferences API
151 * @param visit the Setup Visit
152 * @throws SetupException
153 * @throws MalformedURLException
154 */
155 void setConfiguration(SetupVisit visit) throws MalformedURLException, SetupException;
156
157
158 }