01: // PropertyFeeder.java
02: // $Id: HttpServerResourceFeeder.java,v 1.6 2000/08/16 21:37:27 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1997.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigadm.editors;
07:
08: import org.w3c.jigadm.RemoteResourceWrapper;
09:
10: import org.w3c.jigsaw.admin.RemoteAccessException;
11: import org.w3c.jigsaw.admin.RemoteResource;
12:
13: import java.util.Properties;
14:
15: /**
16: * HttpServerResourceFeeder :
17: * @author Benoit Mahe <bmahe@sophia.inria.fr>
18: */
19: public class HttpServerResourceFeeder implements EditorFeeder {
20:
21: public static final String RESOURCE_P = "feeder.resource";
22:
23: String[] s = null;
24:
25: public String[] getDefaultItems() {
26: return s;
27: }
28:
29: protected String[] getStringArray(RemoteResourceWrapper rrw,
30: Properties p) {
31: String name = (String) p.get(RESOURCE_P);
32: if (name == null)
33: return new String[0];
34: RemoteResourceWrapper w = rrw;
35: RemoteResource rm = w.getResource();
36: RemoteResource target = null;
37:
38: do {
39: w = w.getFatherWrapper();
40: if (w != null) {
41: rm = w.getResource();
42: try {
43: if ((rm.getClassHierarchy())[0]
44: .equals("org.w3c.jigsaw.http.ConfigResource"))
45: target = rm.loadResource(name);
46: } catch (RemoteAccessException ex) {
47: ex.printStackTrace();
48: }
49: } else
50: return new String[0];
51: } while (target == null);
52: try {
53: return target.enumerateResourceIdentifiers();
54: } catch (RemoteAccessException ex) {
55: ex.printStackTrace();
56: return new String[0];
57: }
58: }
59:
60: public void initialize(RemoteResourceWrapper rrw, Properties p) {
61: s = getStringArray(rrw, p);
62: }
63:
64: }
|