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/AddProcessor.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 org.embl.ebi.escience.scufl.DuplicateProcessorNameException;
11  import org.embl.ebi.escience.scufl.ProcessorCreationException;
12  import org.embl.ebi.escience.scuflworkers.soaplab.SoaplabProcessor;
13  import org.embl.ebi.escience.talisman.*;
14  
15  
16  
17  
18  /**
19   * Adds a new Processor to a ScuflModel within a Talisman BeanField.
20   * Requires 'model' to point to the ScuflModel, 'type' to be the
21   * category of processor to create (only soaplabwsdl is supported at the
22   * moment), 'spec' to be the category specific extra information such
23   * as a SOAP endpoint, and 'name' is the name of the new processor
24   * within the ScuflModel.
25   * @author Tom Oinn
26   */
27  public class AddProcessor extends AbstractScuflAction implements ActionWorker {
28      
29      public void process(HttpServletRequest request , HttpServletResponse response, Action action) 
30    throws AbortActionException, NodeResolutionException, UnknownResolutionProtocolException {
31    super.process(request, response, action);
32    
33    Trigger trigger = (Trigger)action.getParent();
34    
35    // Require the following parameters (model is redundant here,
36    // retained for clarity. The superclass has already checked it)
37    action.requireParameters("model,type,spec,name");
38  
39    String processorType = Resolver.getFieldValue(action.props.getProperty("type"),action).toLowerCase();
40    String processorSpec = Resolver.getFieldValue(action.props.getProperty("spec"),action);
41    String processorName = Resolver.getFieldValue(action.props.getProperty("name"),action);
42  
43    // Complain if the type is not 'soaplabwsdl'
44    if (processorType.equals("soaplabwsdl")==false) {
45        trigger.addError("Only the 'soaplabwsdl' processor type is currently supported, sorry.");
46        throw new AbortActionException();
47    }
48    
49    // Create a new processor and add it to the model.
50    try {
51        model.addProcessor(new SoaplabProcessor(model,processorName,processorSpec));
52    }
53    catch (ProcessorCreationException pce) {
54        trigger.addError(pce.getMessage());
55        throw new AbortActionException();
56    }
57    catch (DuplicateProcessorNameException dpne) {
58        trigger.addError(dpne.getMessage());
59        throw new AbortActionException();
60    }
61      }
62  
63  }