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