KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > packaging > providerhandlers > BasicProvider


1 /*
2  * This software is OSI Certified Open Source Software.
3  * OSI Certified is a certification mark of the Open Source Initiative.
4  * The license (Mozilla version 1.0) can be read at the MMBase site.
5  * See http://www.MMBase.org/license
6  */

7 package org.mmbase.applications.packaging.providerhandlers;
8
9 import java.io.BufferedInputStream JavaDoc;
10 import java.util.jar.JarFile JavaDoc;
11
12 import org.mmbase.applications.packaging.bundlehandlers.BundleInterface;
13 import org.mmbase.applications.packaging.installhandlers.installStep;
14 import org.mmbase.applications.packaging.packagehandlers.PackageInterface;
15 import org.mmbase.applications.packaging.projects.packageStep;
16 import org.mmbase.applications.packaging.projects.creators.CreatorInterface;
17 import org.mmbase.util.logging.Logger;
18 import org.mmbase.util.logging.Logging;
19
20 /**
21  * BasicProvider, Basic Handler for Providers. gets packages and bundles from
22  * the provider and feeds them to the package and bundle managers.
23  *
24  * @author Daniel Ockeloen (MMBased)
25  */

26 public class BasicProvider implements ProviderInterface {
27     private static Logger log = Logging.getLoggerInstance(BasicProvider.class);
28
29     private long lastupdate;
30   
31     private installStep step;
32     private packageStep packagestep;
33
34     String JavaDoc name;
35     String JavaDoc method;
36     String JavaDoc maintainer;
37     String JavaDoc account;
38     String JavaDoc password;
39     String JavaDoc path = "";
40     String JavaDoc description = "";
41     String JavaDoc state = "down";
42
43     org.w3c.dom.Node JavaDoc xmlnode;
44     int baseScore = 0;
45
46
47     /**
48      * Description of the Method
49      *
50      * @param n Description of the Parameter
51      * @param name Description of the Parameter
52      * @param method Description of the Parameter
53      * @param maintainer Description of the Parameter
54      */

55     public void init(org.w3c.dom.Node JavaDoc n, String JavaDoc name, String JavaDoc method, String JavaDoc maintainer) {
56         this.name = name;
57         this.method = method;
58         this.maintainer = maintainer;
59         this.xmlnode = n;
60     }
61
62
63     /**
64      * Description of the Method
65      *
66      * @param name Description of the Parameter
67      * @param method Description of the Parameter
68      * @param maintainer Description of the Parameter
69      * @param path Description of the Parameter
70      */

71     public void init(String JavaDoc name, String JavaDoc method, String JavaDoc maintainer, String JavaDoc path) {
72         this.name = name;
73         this.method = method;
74         this.maintainer = maintainer;
75         this.path = path;
76     }
77
78
79     /**
80      * Gets the name attribute of the BasicProvider object
81      *
82      * @return The name value
83      */

84     public String JavaDoc getName() {
85         return (name);
86     }
87
88
89     /**
90      * Gets the method attribute of the BasicProvider object
91      *
92      * @return The method value
93      */

94     public String JavaDoc getMethod() {
95         return (method);
96     }
97
98
99     /**
100      * Sets the account attribute of the BasicProvider object
101      *
102      * @param account The new account value
103      */

104     public void setAccount(String JavaDoc account) {
105         this.account = account;
106     }
107
108
109     /**
110      * Sets the password attribute of the BasicProvider object
111      *
112      * @param password The new password value
113      */

114     public void setPassword(String JavaDoc password) {
115         this.password = password;
116     }
117
118
119     /**
120      * Sets the maintainer attribute of the BasicProvider object
121      *
122      * @param maintainer The new maintainer value
123      */

124     public void setMaintainer(String JavaDoc maintainer) {
125         this.maintainer = maintainer;
126     }
127
128
129     /**
130      * Gets the maintainer attribute of the BasicProvider object
131      *
132      * @return The maintainer value
133      */

134     public String JavaDoc getMaintainer() {
135         return maintainer;
136     }
137
138
139     /**
140      * Sets the path attribute of the BasicProvider object
141      *
142      * @param path The new path value
143      */

144     public void setPath(String JavaDoc path) {
145         this.path = path;
146     }
147
148
149     /**
150      * Gets the path attribute of the BasicProvider object
151      *
152      * @return The path value
153      */

154     public String JavaDoc getPath() {
155         return path;
156     }
157
158
159     /**
160      * Gets the description attribute of the BasicProvider object
161      *
162      * @return The description value
163      */

164     public String JavaDoc getDescription() {
165         return description;
166     }
167
168
169     /**
170      * Sets the description attribute of the BasicProvider object
171      *
172      * @param description The new description value
173      */

174     public void setDescription(String JavaDoc description) {
175         this.description = description;
176     }
177
178
179     /**
180      * Gets the packages attribute of the BasicProvider object
181      */

182     public void getPackages() {
183         log.error("getPackages called should be overridden");
184     }
185
186
187     /**
188      * Gets the jarFile attribute of the BasicProvider object
189      *
190      * @param path Description of the Parameter
191      * @param id Description of the Parameter
192      * @param version Description of the Parameter
193      * @return The jarFile value
194      */

195     public JarFile JavaDoc getJarFile(String JavaDoc path, String JavaDoc id, String JavaDoc version) {
196         log.error("Provider not implementing call : getJarFile " + this);
197         return null;
198     }
199
200
201     /**
202      * Gets the includedPackageJarFile attribute of the BasicProvider object
203      *
204      * @param path Description of the Parameter
205      * @param id Description of the Parameter
206      * @param version Description of the Parameter
207      * @param packageid Description of the Parameter
208      * @param packageversion Description of the Parameter
209      * @return The includedPackageJarFile value
210      */

211     public JarFile JavaDoc getIncludedPackageJarFile(String JavaDoc path, String JavaDoc id, String JavaDoc version, String JavaDoc packageid, String JavaDoc packageversion) {
212         log.error("Provider not implementing call : getIncludedPackageJarFile " + this);
213         return null;
214     }
215
216
217     /**
218      * Gets the jarStream attribute of the BasicProvider object
219      *
220      * @param path Description of the Parameter
221      * @return The jarStream value
222      */

223     public BufferedInputStream JavaDoc getJarStream(String JavaDoc path) {
224         return null;
225     }
226
227
228     /**
229      * Gets the baseScore attribute of the BasicProvider object
230      *
231      * @return The baseScore value
232      */

233     public int getBaseScore() {
234         return baseScore;
235     }
236
237
238     /**
239      * Description of the Method
240      */

241     public void signalUpdate() {
242         lastupdate = System.currentTimeMillis();
243     }
244
245
246     /**
247      * Description of the Method
248      *
249      * @return Description of the Return Value
250      */

251     public long lastSeen() {
252         return lastupdate;
253     }
254
255
256     /**
257      * Gets the state attribute of the BasicProvider object
258      *
259      * @return The state value
260      */

261     public String JavaDoc getState() {
262         return state;
263     }
264
265
266     /**
267      * Sets the state attribute of the BasicProvider object
268      *
269      * @param state The new state value
270      */

271     public void setState(String JavaDoc state) {
272         this.state = state;
273     }
274
275
276     /**
277      * Description of the Method
278      *
279      * @return Description of the Return Value
280      */

281     public boolean close() {
282         return true;
283     }
284
285     public boolean publish(CreatorInterface creator,BundleInterface bundle,String JavaDoc sharepassword) {
286     log.error("Publish (bundle) call not supported in this provider type : "+getName());
287     return false;
288     }
289
290     public boolean publish(CreatorInterface creator,PackageInterface bundle,String JavaDoc sharepassword) {
291     log.error("Publish (package) call not supported in this provider type : "+getName());
292     return false;
293     }
294
295     public void setInstallStep(installStep step) {
296     this.step = step;
297     }
298
299     public void setPackageStep(packageStep packagestep) {
300     this.packagestep = packagestep;
301     }
302
303     public installStep getInstallStep() {
304     return step;
305     }
306
307     public packageStep getPackageStep() {
308     return packagestep;
309     }
310
311 }
312
313
Popular Tags