1 package com.ontotext.ordi.wsmo4rdf.remote.server;
2
3 import javax.jws.WebService;
4
5 import com.ontotext.ordi.wsmo4rdf.WsmoConnection;
6 import com.ontotext.ordi.wsmo4rdf.WsmoSource;
7 import com.ontotext.ordi.wsmo4rdf.remote.exception.AuthenticationFailedException;
8 import com.ontotext.ordi.wsmo4rdf.remote.exception.NonExistingEntryException;
9 import com.ontotext.ordi.wsmo4rdf.remote.exception.ServiceLimitExceededException;
10 import com.ontotext.ordi.wsmo4rdf.remote.server.exception.RegistryFullException;
11
12 @WebService(endpointInterface = "com.ontotext.ordi.wsmo4rdf.remote.server.WsmoSourceService",
13 serviceName = "WsmoSourceService")
14 public class WsmoSourceServiceImpl implements WsmoSourceService {
15 public WsmoSourceServiceImpl() {
16 super();
17 }
18
19 public int getConnection(final int wsmoSourceId) throws NonExistingEntryException, ServiceLimitExceededException {
20 WsmoSource source = getValidWsmoSource(wsmoSourceId);
21 WsmoConnection wsmoConnection = source.getConnection();
22 int connectionId = Integer.MIN_VALUE;
23 try {
24 connectionId = RegistryManager.getInstance().getWsmoConnectionRegistry().register(wsmoConnection);
25 } catch (RegistryFullException rfe) {
26 throw new ServiceLimitExceededException(rfe);
27 }
28 assert(connectionId != Integer.MIN_VALUE);
29 return connectionId;
30 }
31
32 public int getConnectionAuth(final int wsmoSourceId, String user,String pass)
33 throws NonExistingEntryException, ServiceLimitExceededException, AuthenticationFailedException {
34 if (true) {
35 return getConnection(wsmoSourceId);
36 }
37 throw new AuthenticationFailedException();
38 }
39
40 public void clearWarnings(final int wsmoSourceId)
41 throws NonExistingEntryException {
42 WsmoSource source = getValidWsmoSource(wsmoSourceId);
43 source.clearWarnings();
44 }
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 private WsmoSource getValidWsmoSource(final int sourceId)
77 throws NonExistingEntryException {
78 WsmoSource source = null;
79 if (!Registry.isValid(sourceId)) {
80 return null;
81 }
82 source = RegistryManager.getInstance().getWsmoSourceRegistry().getById(sourceId);
83 if (source == null) {
84 throw new NonExistingEntryException("No such WsmoSource (id = " + sourceId + ")");
85 }
86 return source;
87 }
88
89 public void shutdown(final int wsmoSourceId) throws NonExistingEntryException {
90 WsmoSource source = getValidWsmoSource(wsmoSourceId);
91 source.shutdown();
92 }
93 }