1
|
package eu.dnetlib.enabling.is.sn.resourcestate;
|
2
|
|
3
|
import org.apache.commons.lang.StringUtils;
|
4
|
import org.apache.commons.logging.Log;
|
5
|
import org.apache.commons.logging.LogFactory;
|
6
|
import org.springframework.beans.factory.annotation.Value;
|
7
|
|
8
|
public class SubscriptionRequestFilter {
|
9
|
|
10
|
/**
|
11
|
* logger.
|
12
|
*/
|
13
|
private static final Log log = LogFactory.getLog(SubscriptionRequestFilter.class); // NOPMD by marko on 11/24/08 5:02 PM
|
14
|
|
15
|
/**
|
16
|
* resource wildcard
|
17
|
*/
|
18
|
private static final String ANY_RESOURCE = "*";
|
19
|
|
20
|
@Value("${services.issn.subscription.filter.active}")
|
21
|
private boolean active = false;
|
22
|
|
23
|
public boolean accept(final ResourceStateSubscription rss) {
|
24
|
|
25
|
if (!isActive()) return true;
|
26
|
|
27
|
if (StringUtils.isBlank(rss.getXpath()) & StringUtils.equals(rss.getResourceId(), ANY_RESOURCE)) {
|
28
|
log.debug(String.format("rejected subscription request, resourceId: '%s', xpath: '%s', from: %s", rss.getResourceId(), rss.getXpath(),
|
29
|
rss.getSubscriber()));
|
30
|
return false; // we reject wide subscriptions
|
31
|
}
|
32
|
|
33
|
return true;
|
34
|
}
|
35
|
|
36
|
public boolean isActive() {
|
37
|
return active;
|
38
|
}
|
39
|
|
40
|
public void setActive(boolean active) {
|
41
|
this.active = active;
|
42
|
}
|
43
|
}
|