View Javadoc

1   /*
2    * Copyright (c) 2005, The K-Wf Grid Consortium
3    * Fraunhofer Institute for Computer Architecture and Software Technology
4    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
5    */
6   package net.kwfgrid.gworkflowdl.protocol.calls;
7   
8   import net.kwfgrid.gworkflowdl.protocol.*;
9   import net.kwfgrid.gworkflowdl.protocol.structure.*;
10  
11  import java.io.IOException;
12  
13  import org.xmlpull.v1.XmlSerializer;
14  
15  /***
16     Modification that removes an owl from a set of Owls.
17   */
18  public class OwlsRemoveOwl extends AbstractMethodCall {
19      protected int _i;
20      protected ProtocolOwls _owls;
21      
22      public OwlsRemoveOwl(ProtocolOwls owls, String owl) throws IllegalArgumentException {
23  	super(owls.getRoot());
24  	_owls = owls;
25  	_i = -1;
26  	String[] os = owls.getOwls();
27  	for (int i=0; i<os.length; i++) {
28  	    if (os[i].equals(owl)) {
29  		_i = i;
30  		break;
31  	    }
32  	}
33  	if (_i == -1)
34  	    throw new IllegalArgumentException("Owl string "+owl+" not included in specified Owls.");
35      }
36  
37      public OwlsRemoveOwl(ProtocolOwls owls, int i) {
38  	super(owls.getRoot());
39  	_owls = owls;
40  	_i = i;
41      }
42      
43      public void marshal(IMethodCallMarshaller encoder, XmlSerializer serializer) throws IOException {
44  	encoder.marshalOwlsRemoveOwl(serializer, _owls, _i);
45      }
46  
47      public Object execute() {
48  	Object ret = _owls.__removeOwl(_i);
49  	setExecuted();
50  	return ret;
51      }
52  }