source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java@ 29869

Last change on this file since 29869 was 29869, checked in by ak19, 9 years ago

First part of commit for ensuring the user is authenticated when running the scripts used by the online metadata editor. Running metaserver, BuildAndActivate and other GS2Construct.java commands should not be possible from a web browser.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1package org.greenstone.gsdl3.build;
2
3import java.io.File;
4
5import org.greenstone.gsdl3.util.*;
6//import java.util.Thread
7import javax.swing.event.EventListenerList;
8import org.w3c.dom.Element;
9
10/** base class for collection construction */
11public abstract class CollectionConstructor extends Thread
12{
13
14 /** the site in which building is to take place */
15 protected String site_home = null;
16 /** the name of the site */
17 protected String site_name = null;
18 /** the name of the collection */
19 protected String collection_name = null;
20 /** the stage of construction */
21 protected int process_type = -1;
22 /** other arguments/parameters for the construction process - in a paramList */
23 protected Element process_params = null;
24 /** the list of listeners for the process */
25 protected EventListenerList listeners = null;
26 /** A flag used to determine if this process has been asked to cancel. */
27 protected boolean cancel = false;
28 /** Stores the name of the manifest file (if one is needed) */
29 protected String manifest_file = null;
30 /** The URL params constructed as a query string, representing the CGI QUERY_STRING to */
31 protected String query_string = null;
32
33 public CollectionConstructor(String name)
34 {
35 super(name);
36 this.listeners = new EventListenerList();
37 }
38
39 /**
40 * carry out any set up stuff - returns false if couldn't set up properly
41 */
42 public boolean configure()
43 {
44 return true;
45 }
46
47 public void stopAction()
48 {
49 this.cancel = true;
50 }
51
52 public void setActionType(int type)
53 {
54 this.process_type = type;
55 }
56
57 public void setSiteHome(String site_home)
58 {
59 this.site_home = site_home;
60
61 File siteHomeFile = new File(site_home);
62 this.site_name = siteHomeFile.getName();
63 }
64
65 public void setCollectionName(String coll_name)
66 {
67 this.collection_name = coll_name;
68 }
69
70 public void setQueryString(String querystring)
71 {
72 this.query_string = querystring;
73 }
74
75 public void setProcessParams(Element params)
76 {
77 this.process_params = params;
78 }
79
80 public void setManifestFile(String manifestFile)
81 {
82 this.manifest_file = manifestFile;
83 }
84
85 public boolean addListener(ConstructionListener listener)
86 {
87 this.listeners.add(ConstructionListener.class, listener);
88 return true;
89 }
90
91 public boolean removeListener(ConstructionListener listener)
92 {
93 this.listeners.remove(ConstructionListener.class, listener);
94 return true;
95 }
96
97 protected void sendProcessBegun(ConstructionEvent evt)
98 {
99 Object[] concerned = this.listeners.getListenerList();
100 for (int i = 0; i < concerned.length; i += 2)
101 {
102 if (concerned[i] == ConstructionListener.class)
103 {
104 ((ConstructionListener) concerned[i + 1]).processBegun(evt);
105 }
106 }
107 }
108
109 protected void sendProcessComplete(ConstructionEvent evt)
110 {
111 Object[] concerned = this.listeners.getListenerList();
112 for (int i = 0; i < concerned.length; i += 2)
113 {
114 if (concerned[i] == ConstructionListener.class)
115 {
116 ((ConstructionListener) concerned[i + 1]).processComplete(evt);
117 }
118 }
119 }
120
121 protected void sendProcessStatus(ConstructionEvent evt)
122 {
123
124 Object[] concerned = this.listeners.getListenerList();
125 for (int i = 0; i < concerned.length; i += 2)
126 {
127 if (concerned[i] == ConstructionListener.class)
128 {
129 ((ConstructionListener) concerned[i + 1]).processStatus(evt);
130 }
131 }
132 }
133
134 protected void sendMessage(ConstructionEvent evt)
135 {
136
137 Object[] concerned = this.listeners.getListenerList();
138 for (int i = 0; i < concerned.length; i += 2)
139 {
140 if (concerned[i] == ConstructionListener.class)
141 {
142 ((ConstructionListener) concerned[i + 1]).message(evt);
143 }
144 }
145 }
146
147 abstract public void run();
148}
Note: See TracBrowser for help on using the repository browser.