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.server;
7   
8   import net.kwfgrid.gworkflowdl.protocol.service.IStructureService;
9   import net.kwfgrid.gworkflowdl.protocol.*;
10  import net.kwfgrid.gworkflowdl.structure.*;
11  
12  import java.util.*;
13  
14  /***
15     Support class for client test.
16   */
17  public class StructureService implements IStructureService {
18      private HashMap _servers;
19      private Creator _creator;
20      private IServerDelegate _delegate;
21  
22      public StructureService() {
23  	_servers = new HashMap();
24  	_creator = new DefaultCreator();
25  	_delegate = new DefaultServerDelegate();
26      }
27      
28      public String instantiate() {
29  	ServerWorkflow wf = new ServerWorkflow(_creator.newWorkflow(), _delegate);
30  	_servers.put(wf.getID(), wf);
31  	return wf.getID();
32      }
33      
34      public int commitModification(String structureid, int clientversion, String modification, String userID) throws IllegalModificationException, IncompatibleVersionsException {
35  	ServerWorkflow wf = (ServerWorkflow)_servers.get(structureid);
36  	return wf.commitModification(clientversion, modification);
37      }
38      
39      public String[][] getModificationsForUpdate(String structureid, int clientversion, String userID) {
40  	ServerWorkflow wf = (ServerWorkflow)_servers.get(structureid);
41  	return wf.getModificationsForUpdate(clientversion);
42      }
43  }