Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/embl/ebi/escience/talisman/scuflsupport/PopulateServiceList.java


1   /**
2    * This file is a component of the Taverna project,
3    * and is licensed under the GNU LGPL.
4    * Copyright Tom Oinn, EMBL-EBI
5    */
6   package org.embl.ebi.escience.talisman.scuflsupport;
7   
8   import javax.servlet.http.HttpServletRequest;
9   import javax.servlet.http.HttpServletResponse;
10  import javax.xml.namespace.QName;
11  import javax.xml.rpc.ServiceException;
12  import org.apache.axis.client.Call; // ambiguous with: javax.xml.rpc.Call 
13  import org.apache.axis.client.Service; // ambiguous with: javax.xml.rpc.Service 
14  import org.embl.ebi.escience.talisman.*;
15  
16  // RMI Imports
17  import java.rmi.RemoteException;
18  
19  
20  
21  
22  /**
23   * Talisman action to populate a SelectionList with the 
24   * service list returned by the Soaplab analysis factory.
25   * This will create a selection list where the values are
26   * the full endpoint URLs and the display names are the
27   * application names with categories. The name of the list
28   * to populate is given in the 'list' parameter and the 
29   * root URL for the Soaplab service (not including the AnalysisFactory bit)
30   * in the 'soaplab' parameter.
31   */
32  public class PopulateServiceList implements ActionWorker {
33  
34      public void process(HttpServletRequest request , HttpServletResponse response, Action action) 
35    throws AbortActionException, NodeResolutionException, UnknownResolutionProtocolException {
36    
37    Trigger trigger = (Trigger)action.getParent();
38  
39    // Require the following parameters
40    action.requireParameters("list,soaplab");
41    
42    SelectionList theList = Resolver.getSelection(action.props.getProperty("list"),action);
43    String soaplabRoot = Resolver.getFieldValue(action.props.getProperty("soaplab"),action);
44    
45    Call call = null;
46    try {
47        // Invoke the AnalysisFactory service to get the list of extant applications
48        call = (Call) new Service().createCall();
49    }
50    catch (ServiceException se) {
51        trigger.addError("Unable to create XML RPC call object during population of list : "+se.getMessage());
52        throw new AbortActionException();
53    }
54    // Endpoint i.e. http://industry.ebi.ac.uk/soap/soaplab/
55    call.setTargetEndpointAddress(soaplabRoot+"AnalysisFactory");
56    call.setOperationName(new QName("getAvailableAnalyses"));
57    String[] results = null;
58    try {
59        results = (String[])(call.invoke(new Object[0]));
60    }
61    catch (RemoteException re) {
62        trigger.addError("Unable to call the Soaplab service to get the list of applications : "+re.getMessage());
63        throw new AbortActionException();
64    }
65    // Clear the current set of options in the selection list
66    theList.clearOptions();
67  
68    // Iterate over results, which will look something like class::application
69    // and add the entries to the selection list. The values in the list will
70    // be the real SOAP endpoints. These values are the same as should be used
71    // in the constructor of the SoaplabProcessor. How handy...
72    for (int i = 0; i < results.length; i++) {
73        String application = results[i];
74        String applicationEndpoint = soaplabRoot+application;
75        theList.addOption(application,applicationEndpoint);
76    }
77  
78      }
79  
80  }