check whether the subscriber exist before creating

revert-70aa11f8
ayyoob 9 years ago
parent afe965e787
commit 9d4defaa01

@ -77,7 +77,18 @@
<artifactId>commons-httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.base</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple.wso2</groupId>
<artifactId>json-simple</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>

@ -286,14 +286,18 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
try {
APIConsumer consumer = APIManagerFactory.getInstance().getAPIConsumer(subscriberName);
if (consumer != null) {
Subscriber subscriber = new Subscriber(subscriberName);
subscriber.setSubscribedDate(new Date());
subscriber.setEmail(subscriberEmail);
subscriber.setTenantId(tenantId);
consumer.addSubscriber(subscriber, groupId);
if (log.isDebugEnabled()) {
log.debug("Successfully created subscriber with name : " + subscriberName + " with groupID : " +
groupId);
synchronized (consumer) {
if (consumer.getSubscriber(subscriberName) == null) {
Subscriber subscriber = new Subscriber(subscriberName);
subscriber.setSubscribedDate(new Date());
subscriber.setEmail(subscriberEmail);
subscriber.setTenantId(tenantId);
consumer.addSubscriber(subscriber, groupId);
if (log.isDebugEnabled()) {
log.debug("Successfully created subscriber with name : " + subscriberName +
" with groupID : " + groupId);
}
}
}
} else {
throw new APIManagerException("API provider configured for the given API configuration is null. " +

Loading…
Cancel
Save