Changeset 5148
- Timestamp:
- 2003-08-18T13:50:54+12:00 (21 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/build/CollectionConstructor.java
r4852 r5148 11 11 12 12 /** the site in which building is to take place */ 13 protected String site_home _= null;13 protected String site_home = null; 14 14 /** the name of the collection */ 15 protected String collection_name _= null;15 protected String collection_name = null; 16 16 /** the stage of construction */ 17 protected int process_type _= -1;17 protected int process_type = -1; 18 18 /** other arguments/parameters for the construction process - in a paramList */ 19 protected Element process_params _= null;19 protected Element process_params = null; 20 20 /** the list of listeners for the process */ 21 protected EventListenerList listeners _= null;21 protected EventListenerList listeners = null; 22 22 /** A flag used to determine if this process has been asked to cancel. */ 23 protected boolean cancel _= false;23 protected boolean cancel = false; 24 24 25 25 public CollectionConstructor(String name) { 26 26 super(name); 27 listeners_= new EventListenerList();27 this.listeners = new EventListenerList(); 28 28 } 29 29 … … 34 34 } 35 35 public void stopAction() { 36 cancel_= true;36 this.cancel = true; 37 37 } 38 38 39 39 public void setActionType(int type) { 40 process_type_= type;40 this.process_type = type; 41 41 } 42 42 public void setSiteHome(String site_home) { 43 site_home_= site_home;43 this.site_home = site_home; 44 44 } 45 45 public void setCollectionName(String coll_name) { 46 collection_name_= coll_name;46 this.collection_name = coll_name; 47 47 } 48 48 public void setProcessParams(Element params) { 49 process_params_= params;49 this.process_params = params; 50 50 } 51 51 public boolean addListener(ConstructionListener listener) { 52 listeners_.add(ConstructionListener.class, listener);52 this.listeners.add(ConstructionListener.class, listener); 53 53 return true; 54 54 } 55 55 public boolean removeListener(ConstructionListener listener) { 56 listeners_.remove(ConstructionListener.class, listener);56 this.listeners.remove(ConstructionListener.class, listener); 57 57 return true; 58 58 } 59 59 60 60 protected void sendProcessBegun(ConstructionEvent evt) { 61 Object[] concerned = listeners_.getListenerList();61 Object[] concerned = this.listeners.getListenerList(); 62 62 for(int i = 0; i < concerned.length ; i+=2) { 63 63 if(concerned[i] == ConstructionListener.class) { … … 67 67 } 68 68 protected void sendProcessComplete(ConstructionEvent evt) { 69 Object[] concerned = listeners_.getListenerList();69 Object[] concerned = this.listeners.getListenerList(); 70 70 for(int i = 0; i < concerned.length ; i+=2) { 71 71 if(concerned[i] == ConstructionListener.class) { … … 77 77 protected void sendProcessStatus(ConstructionEvent evt) { 78 78 79 Object[] concerned = listeners_.getListenerList();79 Object[] concerned = this.listeners.getListenerList(); 80 80 for(int i = 0; i < concerned.length ; i+=2) { 81 81 if(concerned[i] == ConstructionListener.class) { … … 86 86 protected void sendMessage(ConstructionEvent evt) { 87 87 88 Object[] concerned = listeners_.getListenerList();88 Object[] concerned = this.listeners.getListenerList(); 89 89 for(int i = 0; i < concerned.length ; i+=2) { 90 90 if(concerned[i] == ConstructionListener.class) { -
trunk/gsdl3/src/java/org/greenstone/gsdl3/build/ConstructionEvent.java
r3661 r5148 8 8 /** the event id for these events - use a random number thats 9 9 not reserved*/ 10 private static int event_id_= RESERVED_ID_MAX+77;10 private static final int EVENT_ID = RESERVED_ID_MAX+77; 11 11 /** The status associated with the event. */ 12 private int status _= -1;12 private int status = -1; 13 13 /** Any message associated with this event. */ 14 private String message _= null;14 private String message = null; 15 15 /* Constructor. 16 16 * @param source The <strong>CollectionConstructor</strong> that fired this message. … … 19 19 */ 20 20 public ConstructionEvent(Object source, int status, String message) { 21 super(source, event_id_);22 message_= message;23 status_= status;21 super(source, EVENT_ID); 22 this.message = message; 23 this.status = status; 24 24 } 25 25 /** Gets the message associated with this event. … … 27 27 */ 28 28 public String getMessage() { 29 return message_;29 return this.message; 30 30 } 31 31 /** Gets the status associated with this event. This status can then be matched back to the constants in <strong>GShell</strong>. … … 33 33 */ 34 34 public int getStatus() { 35 return status_;35 return this.status; 36 36 } 37 37 /** returns a String representation of the event */ 38 38 public String toString() { 39 return "org.greenstone.gsdl3.build.ConstructionEvent[" + message_40 + "," + status_+ "]";39 return "org.greenstone.gsdl3.build.ConstructionEvent[" + this.message 40 + "," + this.status + "]"; 41 41 } 42 42 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r4970 r5148 27 27 /** gsdlhome for greenstone 2 - we use the perl modules and building 28 28 * scripts from there */ 29 protected String gsdl2home _= null;29 protected String gsdl2home = null; 30 30 /** gsdlhome for gsdl3 - shouldn't need this eventually ??*/ 31 protected String gsdl3home _= null;31 protected String gsdl3home = null; 32 32 /** gsdlos for greenstone 2 */ 33 protected String gsdlos _= null;33 protected String gsdlos = null; 34 34 /** the path environment variable */ 35 protected String path _= null;35 protected String path = null; 36 36 37 37 public GS2PerlConstructor(String name) { … … 42 42 public boolean configure() { 43 43 // try to get the environment variables 44 gsdl2home_= System.getProperty("GSDLHOME");45 gsdl3home_= System.getProperty("GSDL3HOME");46 gsdlos_= System.getProperty("GSDLOS");47 path_= System.getProperty("PATH");48 if ( gsdl2home_==null ) {44 this.gsdl2home = System.getProperty("GSDLHOME"); 45 this.gsdl3home = System.getProperty("GSDL3HOME"); 46 this.gsdlos = System.getProperty("GSDLOS"); 47 this.path = System.getProperty("PATH"); 48 if (this.gsdl2home ==null ) { 49 49 System.err.println("You must have greenstone2 installed, and GSDLHOME set for GS2Perl building to work!!"); 50 50 return false; 51 51 } 52 if ( gsdl3home_ == null|| gsdlos_==null) {52 if (this.gsdl3home == null|| this.gsdlos == null) { 53 53 System.err.println("You must have GSDL3HOME and GSDLOS set for GS2Perl building to work!!"); 54 54 return false; 55 55 } 56 if ( path_==null) {56 if (this.path==null) { 57 57 System.err.println("You must have the PATH set for GS2Perl building to work!!"); 58 58 return false; … … 64 64 String msg; 65 65 ConstructionEvent evt; 66 if ( process_type_== -1) {66 if (this.process_type == -1) { 67 67 msg = "Error: you must set the action type"; 68 68 evt = new ConstructionEvent(this, GSStatus.ERROR, msg); … … 70 70 return; 71 71 } 72 if ( site_home_==null) {72 if (this.site_home==null) { 73 73 msg = "Error: you must set site_home"; 74 74 evt = new ConstructionEvent(this, GSStatus.ERROR, msg); … … 76 76 return; 77 77 } 78 if ( process_type_ != NEW && collection_name_==null) {78 if (this.process_type != NEW && this.collection_name ==null) { 79 79 msg = "Error: you must set collection_name"; 80 80 evt = new ConstructionEvent(this, GSStatus.ERROR, msg); … … 83 83 } 84 84 85 switch ( process_type_) {85 switch (this.process_type) { 86 86 case NEW: 87 87 newCollection(); … … 110 110 command.add("gs2_mkcol.pl"); 111 111 command.add("-site"); 112 command.add( site_home_);113 command.add("-collectdir"); 114 command.add(GSFile.collectDir( site_home_));115 command.addAll(extractParameters( process_params_));116 command.add( collection_name_);112 command.add(this.site_home); 113 command.add("-collectdir"); 114 command.add(GSFile.collectDir(this.site_home)); 115 command.addAll(extractParameters(this.process_params)); 116 command.add(this.collection_name); 117 117 String [] command_str = {}; 118 118 command_str = (String [])command.toArray(command_str); … … 129 129 command.add("import.pl"); 130 130 command.add("-collectdir"); 131 command.add(GSFile.collectDir( site_home_));132 command.addAll(extractParameters( process_params_));133 command.add( collection_name_);131 command.add(GSFile.collectDir(this.site_home)); 132 command.addAll(extractParameters(this.process_params)); 133 command.add(this.collection_name); 134 134 String [] command_str = {}; 135 135 command_str = (String [])command.toArray(command_str); … … 146 146 command.add("buildcol.pl"); 147 147 command.add("-collectdir"); 148 command.add(GSFile.collectDir( site_home_));149 command.addAll(extractParameters( process_params_));150 command.add( collection_name_);148 command.add(GSFile.collectDir(this.site_home)); 149 command.addAll(extractParameters(this.process_params)); 150 command.add(this.collection_name); 151 151 String [] command_str = {}; 152 152 command_str = (String [])command.toArray(command_str); … … 163 163 164 164 // first check that we have a building directory 165 File build_dir = new File(GSFile.collectionBuildDir( site_home_, collection_name_));165 File build_dir = new File(GSFile.collectionBuildDir(this.site_home, this.collection_name)); 166 166 if (!build_dir.exists()) { 167 167 sendMessage(new ConstructionEvent(this, GSStatus.ERROR, "build dir doesn't exist!")); … … 170 170 171 171 // move building to index 172 File index_dir = new File(GSFile.collectionIndexDir( site_home_, collection_name_));172 File index_dir = new File(GSFile.collectionIndexDir(this.site_home, this.collection_name)); 173 173 if (index_dir.exists()) { 174 174 sendMessage(new ConstructionEvent(this, GSStatus.INFO, "deleting index directory")); … … 188 188 command.add("convert_coll_from_gs2.pl"); 189 189 command.add("-collectdir"); 190 command.add(GSFile.collectDir( site_home_));191 command.addAll(extractParameters( process_params_));192 command.add( collection_name_);190 command.add(GSFile.collectDir(this.site_home)); 191 command.addAll(extractParameters(this.process_params)); 192 command.add(this.collection_name); 193 193 String [] command_str = {}; 194 194 command_str = (String [])command.toArray(command_str); … … 231 231 ConstructionEvent evt; 232 232 233 String args[] = {"GSDLHOME="+ gsdl2home_, "GSDLOS="+gsdlos_, "PATH="+path_};233 String args[] = {"GSDLHOME="+this.gsdl2home, "GSDLOS="+this.gsdlos, "PATH="+this.path}; 234 234 String command_str = ""; 235 235 for(int i = 0; i < command.length; i++) { … … 250 250 String eline = null; 251 251 String stdinline = null; 252 while (((eline = ebr.readLine()) != null || (stdinline = stdinbr.readLine()) != null) && ! cancel_) {252 while (((eline = ebr.readLine()) != null || (stdinline = stdinbr.readLine()) != null) && !this.cancel) { 253 253 if(eline != null) { 254 254 sendProcessStatus(new ConstructionEvent(this, GSStatus.CONTINUING, eline)); … … 258 258 } 259 259 } 260 if(! cancel_) {260 if(!this.cancel) { 261 261 // Now display final message based on exit value 262 262 prcs.waitFor(); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/build/GS2PerlListener.java
r3684 r5148 5 5 6 6 /** a buffer holding all the messages */ 7 protected StringBuffer log _=null;7 protected StringBuffer log=null; 8 8 /** a buffer holding only the latest update */ 9 protected StringBuffer update _= null;9 protected StringBuffer update = null; 10 10 11 11 /** a status code */ 12 protected int status _= -1;12 protected int status = -1; 13 13 /** whether the process this is listeneing to is finshed */ 14 protected boolean finished _= false;14 protected boolean finished = false; 15 15 16 16 public GS2PerlListener() { 17 log_= new StringBuffer();18 update_= new StringBuffer();17 this.log = new StringBuffer(); 18 this.update = new StringBuffer(); 19 19 } 20 20 21 21 public boolean isFinished() { 22 return finished_;22 return this.finished; 23 23 } 24 24 public String getLog() { 25 return log_.toString();25 return this.log.toString(); 26 26 } 27 27 public int getStatus() { 28 return status_;28 return this.status; 29 29 } 30 30 synchronized public String getUpdate() { 31 log_.append(update_);32 String tmp = update_.toString();33 update_.delete(0, update_.length());31 this.log.append(this.update); 32 String tmp = this.update.toString(); 33 this.update.delete(0, this.update.length()); 34 34 return tmp; 35 35 } … … 39 39 /** This event handler used to signify that a task has been started */ 40 40 synchronized public void processBegun(ConstructionEvent evt) { 41 status_= evt.getStatus();42 update_.append(evt.getMessage()+"\n");41 this.status = evt.getStatus(); 42 this.update.append(evt.getMessage()+"\n"); 43 43 44 44 } 45 45 /** This event handler used to signify that a task has been completed */ 46 46 synchronized public void processComplete(ConstructionEvent evt){ 47 status_= evt.getStatus();48 update_.append(evt.getMessage()+"\n");47 this.status = evt.getStatus(); 48 this.update.append(evt.getMessage()+"\n"); 49 49 } 50 50 /** This event handler used to send status updates as the task is progressing */ 51 51 synchronized public void processStatus(ConstructionEvent evt){ 52 status_= evt.getStatus();53 update_.append(evt.getMessage()+"\n");52 this.status = evt.getStatus(); 53 this.update.append(evt.getMessage()+"\n"); 54 54 } 55 55 /** This event handler used to send any other messages to the listeners */ 56 56 synchronized public void message(ConstructionEvent evt){ 57 status_= evt.getStatus();58 update_.append(evt.getMessage()+"\n");57 this.status = evt.getStatus(); 58 this.update.append(evt.getMessage()+"\n"); 59 59 } 60 60 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/build/StatusDisplay.java
r3694 r5148 26 26 27 27 /** the display area for the status messages */ 28 protected TextArea display _;28 protected TextArea display; 29 29 /** how long to delay between requests */ 30 protected int delay _=3000; // 3 secs30 protected int delay=3000; // 3 secs 31 31 /** the thread used */ 32 protected Thread updator Thread_;32 protected Thread updator_thread; 33 33 /** the url for the requests */ 34 protected URL status_cgi _= null;34 protected URL status_cgi = null; 35 35 /** if true, stops sending requests, and cant be unset */ 36 protected boolean completed _= false;36 protected boolean completed = false; 37 37 // init is called if you leave the page and go back - need to somehow retrieve all the previous messages that have been obtained cos we may have left the page and gone back to it during an import or something. dont want to lose all the info. 38 38 public void init() { 39 39 //Create the text field and make it uneditable. 40 display_= new TextArea();41 display_.setEditable(false);42 display_.setBackground(Color.white);40 this.display = new TextArea(); 41 this.display.setEditable(false); 42 this.display.setBackground(Color.white); 43 43 //Set the layout manager so that the text field will be 44 44 //as wide as possible. … … 46 46 47 47 //Add the text field to the applet. 48 add( display_);48 add(this.display); 49 49 validate(); 50 50 … … 54 54 55 55 // check the initial error state - there may be no more messages to come 56 completed_= GSStatus.isCompleted(Integer.parseInt(parameterValue("initial_code")));56 this.completed = GSStatus.isCompleted(Integer.parseInt(parameterValue("initial_code"))); 57 57 58 58 // we always do the same query … … 60 60 library = tidy_URL(library); 61 61 try { 62 status_cgi_= new URL(library);62 this.status_cgi = new URL(library); 63 63 } catch (Exception e) { 64 64 System.out.println("Error creating URL for "+library+": "+e.getMessage()); … … 67 67 68 68 public void start() { 69 if ( completed_) {69 if (this.completed) { 70 70 // do nothing 71 71 } else { 72 if ( updatorThread_== null) {73 updatorThread_= new Thread(this);72 if (this.updator_thread == null) { 73 this.updator_thread = new Thread(this); 74 74 } 75 updatorThread_.start();75 this.updator_thread.start(); 76 76 } 77 77 } 78 78 public void stop() { 79 updatorThread_= null;79 this.updator_thread = null; 80 80 } 81 81 public void run() { 82 82 83 if ( completed_) { // do nothing. dont know if we need this here83 if (this.completed) { // do nothing. dont know if we need this here 84 84 return; 85 85 } … … 89 89 90 90 //Remember which thread we are. 91 Thread current Thread = Thread.currentThread();91 Thread current_thread = Thread.currentThread(); 92 92 93 93 //This is the loop. 94 while (current Thread == updatorThread_ && !completed_) {94 while (current_thread == this.updator_thread && !this.completed) { 95 95 queryServer(); 96 display_.repaint();96 this.display.repaint(); 97 97 98 98 //Delay for the specified time 99 99 try { 100 Thread.sleep( delay_);100 Thread.sleep(this.delay); 101 101 } catch (InterruptedException e) { 102 102 break; … … 107 107 /** add some more text to the display */ 108 108 void addItem(String new_text) { 109 String t = display_.getText()+"\n"+new_text;110 display_.setText(t);111 display_.setCaretPosition(t.length()); // so that you always see the109 String t = this.display.getText()+"\n"+new_text; 110 this.display.setText(t); 111 this.display.setCaretPosition(t.length()); // so that you always see the 112 112 // most recent entries - ie so that it scrolls down automatically 113 113 repaint(); … … 117 117 118 118 // Send the query 119 System.out.println("sending query: " + status_cgi_); // this appears in the java console119 System.out.println("sending query: " + this.status_cgi); // this appears in the java console 120 120 try { 121 DataInputStream in = new DataInputStream( status_cgi_.openStream());121 DataInputStream in = new DataInputStream(this.status_cgi.openStream()); 122 122 DOMParser parser = new DOMParser(); 123 123 parser.parse(new InputSource(in)); … … 128 128 String status = status_elem.getAttribute(GSXML.STATUS_ERROR_CODE_ATT); 129 129 System.out.println("received status "+status); 130 completed_= GSStatus.isCompleted(Integer.parseInt(status));130 this.completed = GSStatus.isCompleted(Integer.parseInt(status)); 131 131 addItem(GSXML.getNodeText(status_elem)); 132 132 } else { 133 133 System.out.println("Error - no status receieved"); 134 completed_=true;134 this.completed=true; 135 135 } 136 136 in.close(); 137 137 } catch (Exception e) { 138 System.err.println( "Error sending query ("+ status_cgi_+"): " + e);138 System.err.println( "Error sending query ("+this.status_cgi+"): " + e); 139 139 } 140 140 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Construct.java
r5147 r5148 218 218 // at the moment, delete is synchronous. but it may take ages so should do the command in another thread maybe? in which case we will want to ask for status 219 219 System.err.println("had a status request for delete - this shouldn't happen!!"); 220 //t = doc_.createTextNode("");220 //t = this.doc.createTextNode(""); 221 221 //status.appendChild(t); 222 222 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR)); … … 268 268 // reload is synchronous - this makes no sense 269 269 System.err.println("had a status request for reload - this shouldn't happen!!"); 270 //t = doc_.createTextNode("");270 //t = this.doc.createTextNode(""); 271 271 //status.appendChild(t); 272 272 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR)); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/service/XSLTServices.java
r5126 r5148 187 187 // something funny with the doc - 188 188 Element new_doc = this.doc.createElement(GSXML.DOCUMENT_ELEM); 189 new_doc.setAttribute(GSXML.NAME_ATT, ids[j]); //GSXML.createDocumentElement( doc_, ids[j]);189 new_doc.setAttribute(GSXML.NAME_ATT, ids[j]); //GSXML.createDocumentElement(this.doc, ids[j]); 190 190 GSXML.addDocText(this.doc, new_doc, document); 191 191 response.appendChild(new_doc); … … 249 249 Element e = this.doc.createElement(GSXML.DOCUMENT_ELEM); 250 250 e.setAttribute(GSXML.NAME_ATT, id); 251 //Node no = GSXML.createDocumentElement( doc_, id);251 //Node no = GSXML.createDocumentElement(this.doc, id); 252 252 resource_list.appendChild(e); 253 253 } catch (Throwable t) {
Note:
See TracChangeset
for help on using the changeset viewer.