1
|
package eu.dnetlib.enabling.is.sn;
|
2
|
|
3
|
import java.util.Calendar;
|
4
|
import java.util.List;
|
5
|
|
6
|
import javax.annotation.Resource;
|
7
|
import javax.xml.ws.Endpoint;
|
8
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
9
|
|
10
|
import org.apache.commons.logging.Log;
|
11
|
import org.apache.commons.logging.LogFactory;
|
12
|
|
13
|
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
|
14
|
import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
|
15
|
import eu.dnetlib.enabling.is.sn.rmi.SubscriptionRequestRejectedException;
|
16
|
import eu.dnetlib.enabling.tools.AbstractBaseService;
|
17
|
import eu.dnetlib.soap.EndpointReferenceBuilder;
|
18
|
|
19
|
/**
|
20
|
* implementation of ISSNService.
|
21
|
*
|
22
|
* @author marko
|
23
|
*
|
24
|
*/
|
25
|
public class ISSNServiceImpl extends AbstractBaseService implements ISSNService {
|
26
|
|
27
|
/**
|
28
|
* logger.
|
29
|
*/
|
30
|
private static final Log log = LogFactory.getLog(ISSNServiceImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
|
31
|
|
32
|
/**
|
33
|
* obvious constant.
|
34
|
*/
|
35
|
private static final int MILLIS_IN_SECOND = 1000;
|
36
|
|
37
|
/**
|
38
|
* service endpoint.
|
39
|
*/
|
40
|
private Endpoint endpoint;
|
41
|
|
42
|
/**
|
43
|
* core business logic.
|
44
|
*/
|
45
|
private ISSNServiceCore core;
|
46
|
|
47
|
/**
|
48
|
* injected EPR builder.
|
49
|
*/
|
50
|
@Resource(name = "jaxwsEndpointReferenceBuilder")
|
51
|
private EndpointReferenceBuilder<Endpoint> eprBuilder;
|
52
|
|
53
|
/**
|
54
|
* {@inheritDoc}
|
55
|
*
|
56
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#actionCreatePerformed(java.lang.String, java.lang.String, java.lang.String)
|
57
|
*/
|
58
|
@Override
|
59
|
public boolean actionCreatePerformed(final String resourceType, final String profileId, final String profile) throws ISSNException {
|
60
|
log.fatal("actionCreatePerformed(String, String, String) not implemented");
|
61
|
return false;
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* {@inheritDoc}
|
66
|
*
|
67
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#actionDeletePerformed(java.lang.String, java.lang.String)
|
68
|
*/
|
69
|
@Override
|
70
|
public boolean actionDeletePerformed(final String resourceType, final String profileId) throws ISSNException {
|
71
|
log.fatal("actionDeletePerformed(String, String) not implemented");
|
72
|
return false;
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* {@inheritDoc}
|
77
|
*
|
78
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#actionUpdatePerformed(java.lang.String, java.lang.String, java.lang.String,
|
79
|
* java.lang.String)
|
80
|
*/
|
81
|
@Override
|
82
|
public boolean actionUpdatePerformed(final String resourceType, final String profileId, final String profileBefore, final String profileAfter)
|
83
|
throws ISSNException {
|
84
|
log.fatal("actionUpdatePerformed(String, String, String, String) not implemented");
|
85
|
return false;
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* {@inheritDoc}
|
90
|
*
|
91
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#getCurrentMessage(java.lang.String)
|
92
|
*/
|
93
|
@Override
|
94
|
public String getCurrentMessage(final String topic) throws ISSNException {
|
95
|
log.fatal("getCurrentMessage(String) not implemented");
|
96
|
return null;
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* {@inheritDoc}
|
101
|
*
|
102
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#listSubscriptions()
|
103
|
*/
|
104
|
@Override
|
105
|
public List<String> listSubscriptions() {
|
106
|
log.fatal("listSubscriptions() not implemented");
|
107
|
return null;
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* {@inheritDoc}
|
112
|
*
|
113
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#pauseSubscription(java.lang.String)
|
114
|
*/
|
115
|
@Override
|
116
|
public boolean pauseSubscription(final String subscrId) throws ISSNException {
|
117
|
log.fatal("pauseSubscription(String) not implemented");
|
118
|
return false;
|
119
|
}
|
120
|
|
121
|
/**
|
122
|
* {@inheritDoc}
|
123
|
*
|
124
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#renew(java.lang.String, int)
|
125
|
*/
|
126
|
@Override
|
127
|
public boolean renew(final String subscrId, final int terminationTime) throws ISSNException {
|
128
|
log.fatal("renew(String, int) not implemented");
|
129
|
return false;
|
130
|
}
|
131
|
|
132
|
/**
|
133
|
* {@inheritDoc}
|
134
|
*
|
135
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#resumeSubscription(java.lang.String)
|
136
|
*/
|
137
|
@Override
|
138
|
public boolean resumeSubscription(final String subscrId) throws ISSNException {
|
139
|
log.fatal("resumeSubscription(String) not implemented");
|
140
|
return false;
|
141
|
}
|
142
|
|
143
|
/**
|
144
|
* {@inheritDoc}
|
145
|
*
|
146
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#subscribe(javax.xml.ws.wsaddressing.W3CEndpointReference, java.lang.String, int)
|
147
|
*/
|
148
|
@Override
|
149
|
public String subscribe(final W3CEndpointReference consumerReference, final String topicExpression, final int termTime) throws ISSNException, SubscriptionRequestRejectedException {
|
150
|
|
151
|
log.debug("subscribe request from: " + consumerReference.toString() + " topic: " + topicExpression);
|
152
|
|
153
|
int ttl;
|
154
|
if (termTime == 0) {
|
155
|
ttl = 0;
|
156
|
} else {
|
157
|
ttl = (int) (termTime - (Calendar.getInstance().getTimeInMillis() / MILLIS_IN_SECOND));
|
158
|
}
|
159
|
|
160
|
final String res = core.subscribe(consumerReference, topicExpression, ttl);
|
161
|
if (res == null) throw new ISSNException("couldn't find a subscription registry for the given topic: " + topicExpression);
|
162
|
|
163
|
log.debug("subscribe success, subscriptionId: " + res);
|
164
|
|
165
|
return res;
|
166
|
}
|
167
|
|
168
|
/**
|
169
|
* {@inheritDoc}
|
170
|
*
|
171
|
* @see eu.dnetlib.enabling.is.sn.rmi.ISSNService#unsubscribe(java.lang.String)
|
172
|
*/
|
173
|
@Override
|
174
|
public boolean unsubscribe(final String subscrId) throws ISSNException {
|
175
|
log.debug("unsubscribe request for: " + subscrId);
|
176
|
return core.unsubscribe(subscrId);
|
177
|
}
|
178
|
|
179
|
public Endpoint getEndpoint() {
|
180
|
return endpoint;
|
181
|
}
|
182
|
|
183
|
public void setEndpoint(final Endpoint endpoint) {
|
184
|
this.endpoint = endpoint;
|
185
|
}
|
186
|
|
187
|
public ISSNServiceCore getCore() {
|
188
|
return core;
|
189
|
}
|
190
|
|
191
|
public void setCore(final ISSNServiceCore core) {
|
192
|
this.core = core;
|
193
|
}
|
194
|
|
195
|
public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
|
196
|
return eprBuilder;
|
197
|
}
|
198
|
|
199
|
public void setEprBuilder(final EndpointReferenceBuilder<Endpoint> eprBuilder) {
|
200
|
this.eprBuilder = eprBuilder;
|
201
|
}
|
202
|
|
203
|
}
|