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

Quick Search    Search Deep

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