mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
check whether the subscriber exist before creating
This commit is contained in:
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…
Reference in New Issue
Block a user