mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'cloud-3.1.0' of https://github.com/wso2/carbon-device-mgt into cloud-3.1.0
This commit is contained in:
commit
aba4ceaf76
@ -63,7 +63,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
|
|||||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
|
||||||
APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService();
|
APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService();
|
||||||
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
||||||
applicationName, APIUtil.getAllowedApisTags().toArray(new String[APIUtil.getAllowedApisTags().size()]),
|
applicationName, APIUtil.getDefaultTags(),
|
||||||
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false,
|
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false,
|
||||||
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD);
|
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD);
|
||||||
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
|
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import org.wso2.carbon.registry.core.exceptions.RegistryException;
|
|||||||
import org.wso2.carbon.registry.core.service.RegistryService;
|
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||||
import org.wso2.carbon.user.core.service.RealmService;
|
import org.wso2.carbon.user.core.service.RealmService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
@ -95,8 +96,13 @@ public class APIUtil {
|
|||||||
return deviceManagementProviderService;
|
return deviceManagementProviderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] getDefaultTags() throws DeviceManagementException {
|
||||||
|
String[] allowedApisTags = new String[1];
|
||||||
|
allowedApisTags[0] = DEFAULT_CDMF_API_TAG;
|
||||||
|
return allowedApisTags;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> getAllowedApisTags() throws DeviceManagementException {
|
public static List<String> getAllowedApisTags() throws DeviceManagementException {
|
||||||
//Todo get allowed cdmf service tags from config.
|
|
||||||
List<String> allowedApisTags = getDeviceManagementProviderService().getAvailableDeviceTypes();
|
List<String> allowedApisTags = getDeviceManagementProviderService().getAvailableDeviceTypes();
|
||||||
allowedApisTags.add(DEFAULT_CDMF_API_TAG);
|
allowedApisTags.add(DEFAULT_CDMF_API_TAG);
|
||||||
allowedApisTags.add(DEFAULT_CERT_API_TAG);
|
allowedApisTags.add(DEFAULT_CERT_API_TAG);
|
||||||
|
|||||||
@ -87,6 +87,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|||||||
throw new APIManagerException (
|
throw new APIManagerException (
|
||||||
"Api application creation failed for " + applicationName + " to the user " + username);
|
"Api application creation failed for " + applicationName + " to the user " + username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet
|
||||||
|
(null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null);
|
||||||
|
List<Subscription> needToSubscribe = new ArrayList<>();
|
||||||
// subscribe to apis.
|
// subscribe to apis.
|
||||||
if (tags != null && tags.length > 0) {
|
if (tags != null && tags.length > 0) {
|
||||||
for (String tag: tags) {
|
for (String tag: tags) {
|
||||||
@ -100,32 +104,33 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|||||||
|
|
||||||
if (apiList.getList() != null && apiList.getList().size() > 0) {
|
if (apiList.getList() != null && apiList.getList().size() > 0) {
|
||||||
for (APIInfo apiInfo : apiList.getList()) {
|
for (APIInfo apiInfo : apiList.getList()) {
|
||||||
Subscription subscription = new Subscription();
|
|
||||||
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0
|
|
||||||
String id = apiInfo.getProvider().replace("@", "-AT-")
|
String id = apiInfo.getProvider().replace("@", "-AT-")
|
||||||
+ "-" + apiInfo.getName()+ "-" + apiInfo.getVersion();
|
+ "-" + apiInfo.getName()+ "-" + apiInfo.getVersion();
|
||||||
subscription.setApiIdentifier(id);
|
|
||||||
subscription.setApplicationId(application.getApplicationId());
|
|
||||||
subscription.tier(ApiApplicationConstants.DEFAULT_TIER);
|
|
||||||
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet
|
|
||||||
(id, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null);
|
|
||||||
boolean subscriptionExist = false;
|
boolean subscriptionExist = false;
|
||||||
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) {
|
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) {
|
||||||
for (Subscription subs : subscriptionList.getList()) {
|
for (Subscription subs : subscriptionList.getList()) {
|
||||||
if (subs.getApiIdentifier().equals(id) && subs.getApplicationId().equals(
|
if (subs.getApiIdentifier().equals(id)) {
|
||||||
application.getApplicationId())) {
|
|
||||||
subscriptionExist = true;
|
subscriptionExist = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!subscriptionExist) {
|
if (!subscriptionExist) {
|
||||||
storeClient.getIndividualSubscription().subscriptionsPost(subscription, CONTENT_TYPE);
|
Subscription subscription = new Subscription();
|
||||||
|
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0
|
||||||
|
|
||||||
|
subscription.setApiIdentifier(id);
|
||||||
|
subscription.setApplicationId(application.getApplicationId());
|
||||||
|
subscription.tier(ApiApplicationConstants.DEFAULT_TIER);
|
||||||
|
needToSubscribe.add(subscription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!needToSubscribe.isEmpty()) {
|
||||||
|
storeClient.getIndividualSubscription().subscriptionsPost(needToSubscribe, CONTENT_TYPE);
|
||||||
|
}
|
||||||
//end of subscription
|
//end of subscription
|
||||||
|
|
||||||
List<ApplicationKey> applicationKeys = application.getKeys();
|
List<ApplicationKey> applicationKeys = application.getKeys();
|
||||||
|
|||||||
@ -22,6 +22,8 @@ import feign.Param;
|
|||||||
import feign.RequestLine;
|
import feign.RequestLine;
|
||||||
import org.wso2.carbon.apimgt.integration.client.store.model.Subscription;
|
import org.wso2.carbon.apimgt.integration.client.store.model.Subscription;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2017-01-24T00:03:54.991+05:30")
|
||||||
public interface SubscriptionindividualApi {
|
public interface SubscriptionindividualApi {
|
||||||
@ -42,6 +44,21 @@ public interface SubscriptionindividualApi {
|
|||||||
})
|
})
|
||||||
Subscription subscriptionsPost(Subscription body, @Param("contentType") String contentType);
|
Subscription subscriptionsPost(Subscription body, @Param("contentType") String contentType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new subscriptions
|
||||||
|
* Add new subscriptions
|
||||||
|
* @param body Subscription objects that should to be added (required)
|
||||||
|
* @param contentType Media type of the entity in the body. Default is JSON. (required)
|
||||||
|
* @return Subscription
|
||||||
|
*/
|
||||||
|
@RequestLine("POST /subscriptions/multiple")
|
||||||
|
@Headers({
|
||||||
|
"Content-type: application/json",
|
||||||
|
"Accept: application/json",
|
||||||
|
"Content-Type: {contentType}"
|
||||||
|
})
|
||||||
|
List<Subscription> subscriptionsPost(List<Subscription> body, @Param("contentType") String contentType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove subscription
|
* Remove subscription
|
||||||
* Remove subscription
|
* Remove subscription
|
||||||
|
|||||||
@ -152,6 +152,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<!-- /content/body -->
|
<!-- /content/body -->
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user