updating to kernel 4.6.1

This commit is contained in:
Amalka Subasinghe 2021-05-10 09:41:45 +05:30
parent 853ee700b8
commit c33e13b04c
96 changed files with 13684 additions and 5135 deletions

View File

@ -73,8 +73,8 @@
org.wso2.carbon.apimgt.annotations.* org.wso2.carbon.apimgt.annotations.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.servlet, javax.servlet,
javax.xml.*, javax.xml.*,

View File

@ -34,42 +34,56 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<dependencies> <dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<!--CXF --> <!--CXF -->
<dependency> <!--<dependency>-->
<groupId>org.apache.cxf</groupId> <!--<groupId>org.apache.cxf</groupId>-->
<artifactId>cxf-rt-frontend-jaxws</artifactId> <!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.apache.cxf</groupId> <!--<groupId>org.apache.cxf</groupId>-->
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.apache.cxf</groupId> <!--<groupId>org.apache.cxf</groupId>-->
<artifactId>cxf-rt-transports-http</artifactId> <!--<artifactId>cxf-rt-transports-http</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<!--JAX-RS --> <!--JAX-RS -->
<dependency> <!--<dependency>-->
<groupId>org.codehaus.jackson</groupId> <!--<groupId>org.codehaus.jackson</groupId>-->
<artifactId>jackson-core-asl</artifactId> <!--<artifactId>jackson-core-asl</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.codehaus.jackson</groupId> <groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId> <artifactId>jackson-jaxrs</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>javax</groupId> <!--<groupId>javax</groupId>-->
<artifactId>javaee-web-api</artifactId> <!--<artifactId>javaee-web-api</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>javax.ws.rs</groupId> <!--<groupId>javax.ws.rs</groupId>-->
<artifactId>jsr311-api</artifactId> <!--<artifactId>jsr311-api</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>commons-httpclient.wso2</groupId> <groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>

View File

@ -27,8 +27,8 @@ import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; //import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient; //import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
@ -110,12 +110,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
if (username.equals(registrationProfile.getUsername())) { if (username.equals(registrationProfile.getUsername())) {
synchronized (ApiApplicationRegistrationServiceImpl.class) { synchronized (ApiApplicationRegistrationServiceImpl.class) {
StoreClient storeClient = new StoreClient(new OAuthRequestInterceptor(registrationProfile.getUsername(),
registrationProfile.getPassword()));
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
applicationName, registrationProfile.getTags(), applicationName, registrationProfile.getTags(),
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username,
registrationProfile.isAllowedToAllDomains(), validityPeriod, storeClient); registrationProfile.isAllowedToAllDomains(), validityPeriod);
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
} }
} }

View File

@ -25,7 +25,12 @@ import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.servlet.*; import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -51,14 +51,25 @@
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <!--<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <!--<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>-->
</dependency> <!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
<version>9.0.5</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
<version>9.0.5</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>com.googlecode.json-simple.wso2</groupId> <groupId>com.googlecode.json-simple.wso2</groupId>
<artifactId>json-simple</artifactId> <artifactId>json-simple</artifactId>
@ -72,6 +83,11 @@
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId> <artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -100,24 +116,26 @@
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version> <Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>API Management Application Bundle</Bundle-Description> <Bundle-Description>API Management Application Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package> <Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package>
<Import-Package> <Import-Packages>
org.osgi.framework, org.apache.commons.lang;version="[2.6,3)",org.apache.c
org.osgi.service.component, ommons.logging;version="[1.2,2)",org.json.simple,org.osgi.framework;v
org.apache.commons.logging.*, ersion="${imp.package.version.osgi.framework}",org.osgi.service.component;version="${imp.package.version.osgi.service}",org.wso
org.wso2.carbon.user.core.*, 2.carbon.apimgt.api;version="[9.0,10)",org.wso2.carbon.apimgt.api.dto
org.wso2.carbon.user.api, ;version="[9.0,10)",org.wso2.carbon.apimgt.api.model;version="[9.0,10
org.wso2.carbon.utils.multitenancy, )",org.wso2.carbon.apimgt.application.extension.bean,org.wso2.carbon.
org.json.simple, apimgt.application.extension.dto,org.wso2.carbon.apimgt.application.e
org.wso2.carbon.context, xtension.exception,org.wso2.carbon.apimgt.impl;version="[9.0,10)",org
org.wso2.carbon.base, .wso2.carbon.apimgt.impl.utils;version="[9.0,10)",org.wso2.carbon.con
org.wso2.carbon.registry.core.*;resolution:=optional, text;version="[4.6,5)",org.wso2.carbon.device.mgt.core.config.ui;vers
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", ion="[4.1,5)",org.wso2.carbon.identity.jwt.client.extension,org.wso2.
org.wso2.carbon.apimgt.integration.client.*, carbon.identity.jwt.client.extension.dto,org.wso2.carbon.identity.jwt
org.wso2.carbon.apimgt.integration.generated.client.store.api, .client.extension.exception,org.wso2.carbon.identity.jwt.client.exten
org.wso2.carbon.apimgt.integration.generated.client.store.model, sion.service,org.wso2.carbon.registry.core.exceptions;version="[1.0,2
org.wso2.carbon.identity.jwt.client.extension.*, )",org.wso2.carbon.registry.core.service;version="[1.0,2)",org.wso2.c
feign arbon.registry.indexing.service;version="[4.7,5)",org.wso2.carbon.use
</Import-Package> r.api;version="[1.0,2)",org.wso2.carbon.user.core.service;version="[4
.6,5)",org.wso2.carbon.user.core.tenant;version="[4.6,5)"
</Import-Packages>
<Export-Package> <Export-Package>
!org.wso2.carbon.apimgt.application.extension.internal, !org.wso2.carbon.apimgt.application.extension.internal,
org.wso2.carbon.apimgt.application.extension.* org.wso2.carbon.apimgt.application.extension.*

View File

@ -20,8 +20,9 @@ package org.wso2.carbon.apimgt.application.extension;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
//import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
//import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
/** /**
* This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM. * This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM.
@ -61,17 +62,17 @@ public interface APIManagementProviderService {
* @param username to whom the application is created * @param username to whom the application is created
* @param isAllowedAllDomains application is allowed to all the tenants * @param isAllowedAllDomains application is allowed to all the tenants
* @param validityTime validity period of the application * @param validityTime validity period of the application
* @param storeClient Specified store client // * @param storeClient Specified store client
* @return consumerkey and secrete of the created application. * @return consumerkey and secrete of the created application.
* @throws APIManagerException * @throws APIManagerException
*/ */
ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName,
String tags[], String tags[],
String keyType, String keyType,
String username, String username,
boolean isAllowedAllDomains, boolean isAllowedAllDomains,
String validityTime, String validityTime, String scopes) throws APIManagerException;
StoreClient storeClient) throws APIManagerException;
/** /**
* Remove APIM Application. * Remove APIM Application.

View File

@ -18,19 +18,46 @@
package org.wso2.carbon.apimgt.application.extension; package org.wso2.carbon.apimgt.application.extension;
import feign.FeignException; //import feign.FeignException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.APIAdmin;
import org.wso2.carbon.apimgt.api.APIConsumer;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.model.APIKey;
import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper;
import org.wso2.carbon.apimgt.api.model.Application;
import org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration;
import org.wso2.carbon.apimgt.api.model.SubscribedAPI;
import org.wso2.carbon.apimgt.api.model.Subscriber;
import org.wso2.carbon.apimgt.application.extension.bean.APIRegistrationProfile; import org.wso2.carbon.apimgt.application.extension.bean.APIRegistrationProfile;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import org.wso2.carbon.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder;
import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil; import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil;
import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor; import org.wso2.carbon.apimgt.impl.APIAdminImpl;
import org.wso2.carbon.apimgt.integration.client.store.StoreClient; import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.integration.generated.client.store.model.*; import org.wso2.carbon.apimgt.impl.APIManagerFactory;
//import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor;
//import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIInfo;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.APIList;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Application;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationInfo;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKey;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationKeyGenerateRequest;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.ApplicationList;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.Subscription;
//import org.wso2.carbon.apimgt.integration.generated.client.store.model.SubscriptionList;
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration;
import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient; import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
@ -39,7 +66,11 @@ import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* This class represents an implementation of APIManagementProviderService. * This class represents an implementation of APIManagementProviderService.
@ -50,48 +81,66 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
private static final String CONTENT_TYPE = "application/json"; private static final String CONTENT_TYPE = "application/json";
private static final int MAX_API_PER_TAG = 200; private static final int MAX_API_PER_TAG = 200;
private static final String APP_TIER_TYPE = "application"; private static final String APP_TIER_TYPE = "application";
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
@Override
public boolean isTierLoaded() { public boolean isTierLoaded() {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() // StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient(); // .getStoreClient();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain(); .getTenantDomain();
// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
// try {
try { try {
storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, tenantDomain);
APP_TIER_TYPE, } catch (APIManagementException e) {
tenantDomain, CONTENT_TYPE, null, null);
return true;
} catch (FeignException e) {
log.error("Feign Exception", e);
if (e.status() == 401) {
OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor();
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
oAuthRequestInterceptor.removeToken(username, tenantDomain);
try {
storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null);
} catch (FeignException ex) {
log.error("Invalid Attempt : " + ex);
}
}
} catch (Exception e) {
log.error("APIs not ready", e); log.error("APIs not ready", e);
} }
return false; // storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
// APP_TIER_TYPE,
// tenantDomain, CONTENT_TYPE, null, null);
return true;
// } catch (FeignException e) {
// log.error("Feign Exception", e);
// if (e.status() == 401) {
// OAuthRequestInterceptor oAuthRequestInterceptor = new OAuthRequestInterceptor();
// String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
// oAuthRequestInterceptor.removeToken(username, tenantDomain);
// try {
// storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
// APP_TIER_TYPE, tenantDomain, CONTENT_TYPE, null, null);
// } catch (FeignException ex) {
// log.error("Invalid Attempt : " + ex);
// }
// }
// } catch (Exception e) {
// log.error("APIs not ready", e);
// }
// return false;
} }
@Override @Override
public void removeAPIApplication(String applicationName, String username) throws APIManagerException { public void removeAPIApplication(String applicationName, String username) throws APIManagerException {
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService() // StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient(); // .getStoreClient();
ApplicationList applicationList = storeClient.getApplications() // ApplicationList applicationList = storeClient.getApplications()
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); // .applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
if (applicationList.getList() != null && applicationList.getList().size() > 0) { try {
ApplicationInfo applicationInfo = applicationList.getList().get(0); APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(), Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
null, null); if (application != null) {
// ApplicationInfo applicationInfo = applicationList.getList().get(0);
// storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(),
// null, null);
apiConsumer.removeApplication(application, username);
}
} catch (APIManagementException e) {
//todo:amalka
e.printStackTrace();
} }
} }
/** /**
@ -100,94 +149,80 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
@Override @Override
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
String keyType, String username, String keyType, String username,
boolean isAllowedAllDomains, String validityTime, boolean isAllowedAllDomains,
StoreClient sClient) throws APIManagerException { String validityTime, String scopes) throws APIManagerException {
StoreClient storeClient; String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
if (StringUtils.isEmpty(username)) {
if (sClient == null) { username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
.getStoreClient();
} else {
storeClient = sClient;
} }
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain();
try { try {
ApplicationList applicationList = storeClient.getApplications() APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null); Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
Application application;
if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) { int applicationId = 0;
//create application; Subscriber subscriber = null;
application = new Application();
application.setName(applicationName);
application.setSubscriber(username);
application.setDescription("");
application.setThrottlingTier(ApiApplicationConstants.DEFAULT_TIER);
application.setGroupId("");
application = storeClient.getIndividualApplication().applicationsPost(application, CONTENT_TYPE);
} else {
ApplicationInfo applicationInfo = applicationList.getList().get(0);
application = storeClient.getIndividualApplication()
.applicationsApplicationIdGet(applicationInfo.getApplicationId(), CONTENT_TYPE, null, null);
}
if (application == null) { if (application == null) {
throw new APIManagerException( subscriber = apiConsumer.getSubscriber(username);
"Api application creation failed for " + applicationName + " to the user " + username); if (subscriber == null) {
// create subscriber
apiConsumer.addSubscriber(username, "");
subscriber = apiConsumer.getSubscriber(username);
}
//create application
application = new Application(applicationName, subscriber);
application.setTier(ApiApplicationConstants.DEFAULT_TIER);
application.setGroupId("");
applicationId = apiConsumer.addApplication(application, username);
} else {
applicationId = application.getId();
subscriber = apiConsumer.getSubscriber(username);
} }
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet Set<SubscribedAPI> subscribedAPIs =
(null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null); apiConsumer.getSubscribedAPIsByApplicationId(subscriber, applicationId, "");
List<Subscription> needToSubscribe = new ArrayList<>();
log.info("Already subscribed API count: " + subscribedAPIs.size());
// subscribe to apis. // subscribe to apis.
Set<String> tempApiIds = new HashSet<>();
if (tags != null && tags.length > 0) { if (tags != null && tags.length > 0) {
for (String tag : tags) { for (String tag : tags) {
APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag Set<API> apisWithTag = apiConsumer.getAPIsWithTag(tag, tenantDomain);
, CONTENT_TYPE, null); if (apisWithTag == null || apisWithTag.size() == 0) {
if (apiList.getList() == null || apiList.getList().size() == 0) { apisWithTag = apiConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0
, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null);
} }
if (apiList.getList() != null && apiList.getList().size() > 0) { if (apisWithTag != null && apisWithTag.size() > 0) {
for (APIInfo apiInfo : apiList.getList()) { for (API apiInfo : apisWithTag) {
String id = apiInfo.getProvider().replace("@", "-AT-") String id = apiInfo.getId().getProviderName().replace("@", "-AT-")
+ "-" + apiInfo.getName() + "-" + apiInfo.getVersion(); + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion();
id = id.replace(" ", "+"); // todo: amalka will this break old apis?
boolean subscriptionExist = false; boolean subscriptionExist = false;
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) { if (subscribedAPIs.size() > 0) {
for (Subscription subs : subscriptionList.getList()) { for (SubscribedAPI subscribedAPI : subscribedAPIs) {
if (subs.getApiIdentifier().equals(id)) { if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) {
subscriptionExist = true; subscriptionExist = true;
break; break;
} }
} }
} }
if (!subscriptionExist) { if (!subscriptionExist && !tempApiIds.contains(id)) {
Subscription subscription = new Subscription(); ApiTypeWrapper apiTypeWrapper = new ApiTypeWrapper(apiInfo);
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0 apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER);
apiConsumer.addSubscription(apiTypeWrapper, username, applicationId, "");
subscription.setApiIdentifier(id); tempApiIds.add(id);
subscription.setApplicationId(application.getApplicationId());
subscription.tier(ApiApplicationConstants.DEFAULT_TIER);
if (!needToSubscribe.contains(subscription)) {
needToSubscribe.add(subscription);
}
} }
} }
} }
} }
} }
if (!needToSubscribe.isEmpty()) {
storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE);
}
//end of subscription //end of subscription
List<ApplicationKey> applicationKeys = application.getKeys(); List<APIKey> applicationKeys = application.getKeys();
if (applicationKeys != null) { if (applicationKeys != null) {
for (ApplicationKey applicationKey : applicationKeys) { for (APIKey applicationKey : applicationKeys) {
if (keyType.equals(applicationKey.getKeyType().toString())) { if (keyType.equals(applicationKey.getType())) {
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
@ -198,33 +233,74 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
} }
} }
ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest();
List<String> allowedDomains = new ArrayList<>(); List<String> allowedDomains = new ArrayList<>();
if (isAllowedAllDomains) { if (isAllowedAllDomains) {
allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS);
} else { } else {
allowedDomains.add(APIManagerUtil.getTenantDomain()); allowedDomains.add(APIManagerUtil.getTenantDomain());
} }
applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains);
applicationKeyGenerateRequest.setCallbackUrl("");
applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION);
applicationKeyGenerateRequest.setValidityTime(validityTime);
ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost( APIAdmin apiAdmin = new APIAdminImpl();
application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null); String keyManagerId = null;
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { try {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); List<KeyManagerConfigurationDTO> keyManagerConfigurations = apiAdmin
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); .getKeyManagerConfigurationsByTenant(tenantDomain);
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); if (keyManagerConfigurations != null) {
return apiApplicationKey; for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) {
keyManagerId = keyManagerConfigurationDTO.getUuid();
}
}
String jsonString = "{\"grant_types\":\"refresh_token,urn:ietf:params:oauth:grant-type:saml2-bearer," +
"password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," +
"\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," +
"\"username\":\"" + username + "\"}";
// if scopes not defined
if (StringUtils.isEmpty(scopes)) {
UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance();
UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig();
List<String> scopeList = uiConfiguration.getScopes();
if (scopeList != null && scopeList.size() > 0) {
StringBuilder builder = new StringBuilder();
for (String scope : scopeList) {
String tmpScope = scope + " ";
builder.append(tmpScope);
}
scopes = builder.toString();
}
if (StringUtils.isEmpty(scopes)) {
scopes = scopes.trim();
} else {
scopes = "default";
}
}
Map<String, Object> keyDetails = apiConsumer
.requestApprovalForApplicationRegistration(username, applicationName, keyType, "",
allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, scopes, "",
jsonString, keyManagerId, tenantDomain);
if (keyDetails != null) {
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey"));
apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret"));
return apiApplicationKey;
}
throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain);
} catch (APIManagementException e) {
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
} }
throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); } catch (APIManagementException e) {
} catch (FeignException e) {
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
@ -311,7 +387,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) { if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) {
info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
registrationProfile.getTags(), tokenType, registrationProfile.getApplicationName(), registrationProfile.getTags(), tokenType, null,
registrationProfile.isAllowedToAllDomains(), validityPeriod); registrationProfile.isAllowedToAllDomains(), validityPeriod);
} }
} finally { } finally {

View File

@ -18,7 +18,7 @@
package org.wso2.carbon.apimgt.application.extension.internal; package org.wso2.carbon.apimgt.application.extension.internal;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; //import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
@ -35,7 +35,7 @@ public class APIApplicationManagerExtensionDataHolder {
private TenantManager tenantManager; private TenantManager tenantManager;
private TenantRegistryLoader tenantRegistryLoader; private TenantRegistryLoader tenantRegistryLoader;
private TenantIndexingLoader indexLoader; private TenantIndexingLoader indexLoader;
private IntegrationClientService integrationClientService; // private IntegrationClientService integrationClientService;
private JWTClientManagerService jwtClientManagerService; private JWTClientManagerService jwtClientManagerService;
private APIApplicationManagerExtensionDataHolder() { private APIApplicationManagerExtensionDataHolder() {
@ -94,14 +94,14 @@ public class APIApplicationManagerExtensionDataHolder {
return indexLoader; return indexLoader;
} }
public IntegrationClientService getIntegrationClientService() { // public IntegrationClientService getIntegrationClientService() {
return integrationClientService; // return integrationClientService;
} // }
//
public void setIntegrationClientService( // public void setIntegrationClientService(
IntegrationClientService integrationClientService) { // IntegrationClientService integrationClientService) {
this.integrationClientService = integrationClientService; // this.integrationClientService = integrationClientService;
} // }
public JWTClientManagerService getJwtClientManagerService() { public JWTClientManagerService getJwtClientManagerService() {
if (jwtClientManagerService == null) { if (jwtClientManagerService == null) {

View File

@ -23,7 +23,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;; import org.osgi.service.component.ComponentContext;;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; //import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
@ -49,12 +49,6 @@ import org.wso2.carbon.user.core.service.RealmService;
* policy="dynamic" * policy="dynamic"
* bind="setRealmService" * bind="setRealmService"
* unbind="unsetRealmService" * unbind="unsetRealmService"
* @scr.reference name="integration.client.service"
* interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService"
* cardinality="1..1"
* policy="dynamic"
* bind="setIntegrationClientService"
* unbind="unsetIntegrationClientService"
*/ */
public class APIApplicationManagerExtensionServiceComponent { public class APIApplicationManagerExtensionServiceComponent {
@ -97,16 +91,16 @@ public class APIApplicationManagerExtensionServiceComponent {
APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null); APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null);
} }
protected void setIntegrationClientService(IntegrationClientService integrationClientService) { // protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
if (integrationClientService != null && log.isDebugEnabled()) { // if (integrationClientService != null && log.isDebugEnabled()) {
log.debug("integrationClientService initialized"); // log.debug("integrationClientService initialized");
} // }
APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService); // APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService);
} // }
//
protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { // protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null); // APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null);
} // }
/** /**
* Sets Realm Service. * Sets Realm Service.

View File

@ -47,46 +47,39 @@
org.wso2.carbon.apimgt.integration.client.*, org.wso2.carbon.apimgt.integration.client.*,
!org.wso2.carbon.apimgt.integration.client.internal !org.wso2.carbon.apimgt.integration.client.internal
</Export-Package> </Export-Package>
<Import-Package> <!--<Import-Package>-->
org.osgi.framework, <!--feign;version="9.3",feign.auth;version="9.3",feign.cod-->
org.osgi.service.component, <!--ec;version="9.3",feign.gson;version="9.3",feign.jaxrs;version="9.3",f-->
feign, <!--eign.okhttp;version="9.3",feign.slf4j;version="10.7",javax.net.ssl,ja-->
feign.codec, <!--vax.ws.rs,javax.xml,javax.xml.bind;version="2.3",javax.xml.bind.annot-->
feign.auth, <!--ation;version="2.3",javax.xml.parsers,okhttp3,org.apache.commons.lang-->
feign.gson, <!--;version="2.4",org.apache.commons.logging;version="1.2",org.osgi.fram-->
feign.slf4j, <!--ework;version="1.7",org.osgi.service.component;version="1.2",org.w3c.-->
org.wso2.carbon.apimgt.integration.generated.client.publisher.api, <!--dom,org.wso2.carbon.apimgt.integration.client,org.wso2.carbon.apimgt.-->
org.wso2.carbon.apimgt.integration.generated.client.store.api, <!--integration.client.configs,org.wso2.carbon.apimgt.integration.client.-->
javax.xml.bind, <!--exception,org.wso2.carbon.apimgt.integration.client.internal,org.wso2-->
javax.xml.bind.annotation, <!--.carbon.apimgt.integration.client.model,org.wso2.carbon.apimgt.integr-->
javax.xml.parsers;resolution:=optional, <!--ation.client.publisher,org.wso2.carbon.apimgt.integration.client.serv-->
org.apache.commons.logging, <!--ice,org.wso2.carbon.apimgt.integration.client.store,org.wso2.carbon.a-->
org.w3c.dom, <!--pimgt.integration.client.util,org.wso2.carbon.base;version="1.0",org.-->
org.wso2.carbon.context, <!--wso2.carbon.context;version="4.6",org.wso2.carbon.core.util;version="-->
org.wso2.carbon.identity.jwt.client.*, <!--4.6",org.wso2.carbon.identity.jwt.client.extension,org.wso2.carbon.id-->
org.wso2.carbon.user.api, <!--entity.jwt.client.extension.dto,org.wso2.carbon.identity.jwt.client.e-->
org.wso2.carbon.utils, <!--xtension.exception,org.wso2.carbon.identity.jwt.client.extension.serv-->
com.fasterxml.jackson.annotation, <!--ice,org.wso2.carbon.utils;version="4.6"-->
io.swagger.annotations,
org.wso2.carbon.core.util,
javax.xml, <!--org.osgi.framework.*;version="${imp.package.version.osgi.framework}",-->
org.wso2.carbon.base, <!--org.osgi.service.*;version="${imp.package.version.osgi.service}",-->
javax.net.ssl,
org.apache.commons.lang, <!--</Import-Package>-->
android.util;resolution:=optional, <!--<Embed-Dependency>-->
javax.annotation;resolution:=optional, <!--jsr311-api,-->
javax.net;resolution:=optional, <!--feign-jaxrs,-->
javax.security.auth.x500;resolution:=optional, <!--feign-okhttp,-->
javax.crypto;resolution:=optional, <!--okhttp,-->
javax.crypto.spec;resolution:=optional <!--okio-->
</Import-Package> <!--</Embed-Dependency>-->
<Embed-Dependency>
jsr311-api,
feign-jaxrs,
feign-okhttp,
okhttp,
okio
</Embed-Dependency>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
@ -120,55 +113,60 @@
</build> </build>
<dependencies> <dependencies>
<dependency> <!--<dependency>-->
<groupId>com.squareup.okhttp3</groupId> <!--<groupId>com.squareup.okhttp3</groupId>-->
<artifactId>okhttp</artifactId> <!--<artifactId>okhttp</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>com.squareup.okio</groupId> <!--<groupId>com.squareup.okio</groupId>-->
<artifactId>okio</artifactId> <!--<artifactId>okio</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId> <artifactId>feign-okhttp</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>io.github.openfeign</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>feign-slf4j</artifactId>
</dependency> <version>10.7.2</version>
<dependency> </dependency>
<groupId>org.eclipse.osgi</groupId> <!--<dependency>-->
<artifactId>org.eclipse.osgi</artifactId> <!--<groupId>org.wso2.carbon</groupId>-->
</dependency> <!--<artifactId>org.wso2.carbon.logging</artifactId>-->
<dependency> <!--</dependency>-->
<groupId>org.eclipse.osgi</groupId> <!--<dependency>-->
<artifactId>org.eclipse.osgi.services</artifactId> <!--<groupId>org.eclipse.osgi</groupId>-->
</dependency> <!--<artifactId>org.eclipse.osgi</artifactId>-->
<dependency> <!--</dependency>-->
<groupId>com.google.code.gson</groupId> <!--<dependency>-->
<artifactId>gson</artifactId> <!--<groupId>org.eclipse.osgi</groupId>-->
</dependency> <!--<artifactId>org.eclipse.osgi.services</artifactId>-->
<dependency> <!--</dependency>-->
<groupId>javax.ws.rs</groupId> <!--<dependency>-->
<artifactId>jsr311-api</artifactId> <!--<groupId>com.google.code.gson</groupId>-->
</dependency> <!--<artifactId>gson</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>javax.ws.rs</groupId>-->
<!--<artifactId>jsr311-api</artifactId>-->
<!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>io.swagger</groupId> <!--<groupId>io.swagger</groupId>-->
<artifactId>swagger-annotations</artifactId> <!--<artifactId>swagger-annotations</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>junit</groupId> <!--<groupId>junit</groupId>-->
<artifactId>junit</artifactId> <!--<artifactId>junit</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId> <artifactId>feign-core</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>io.github.openfeign</groupId> <!--<groupId>io.github.openfeign</groupId>-->
<artifactId>feign-jackson</artifactId> <!--<artifactId>feign-jackson</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
<artifactId>feign-jaxrs</artifactId> <artifactId>feign-jaxrs</artifactId>
@ -178,10 +176,10 @@
<artifactId>feign-gson</artifactId> <artifactId>feign-gson</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.testng</groupId> <!--<groupId>org.testng</groupId>-->
<artifactId>testng</artifactId> <!--<artifactId>testng</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId> <artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>

View File

@ -27,7 +27,8 @@ import feign.slf4j.Slf4jLogger;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.*; import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApIsApi;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.ApiLifecycleApi;
import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.core.util.Utils;
/** /**
@ -36,13 +37,15 @@ import org.wso2.carbon.core.util.Utils;
public class PublisherClient { public class PublisherClient {
private static final Log log = LogFactory.getLog(PublisherClient.class); private static final Log log = LogFactory.getLog(PublisherClient.class);
private APIIndividualApi api = null; private ApIsApi apIsApi = null;
private APICollectionApi apis = null; private ApiLifecycleApi apiLifecycleApi = null;
private DocumentIndividualApi document = null; // private APIIndividualApi api = null;
private ApplicationIndividualApi application = null; // private APICollectionApi apis = null;
private EnvironmentCollectionApi environments = null; // private DocumentIndividualApi document = null;
private SubscriptionCollectionApi subscriptions = null; // private ApplicationIndividualApi application = null;
private ThrottlingTierCollectionApi tiers = null; // private EnvironmentCollectionApi environments = null;
// private SubscriptionApi subscriptions = null;
// private ThrottlingTierCollectionApi tiers = null;
/** /**
@ -57,40 +60,50 @@ public class PublisherClient {
.requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder());
String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint());
api = builder.target(APIIndividualApi.class, basePath); apIsApi = builder.target(ApIsApi.class, basePath);
apis = builder.target(APICollectionApi.class, basePath); apiLifecycleApi = builder.target(ApiLifecycleApi.class, basePath);
document = builder.target(DocumentIndividualApi.class, basePath); // api = builder.target(APIIndividualApi.class, basePath);
application = builder.target(ApplicationIndividualApi.class, basePath); // apis = builder.target(APICollectionApi.class, basePath);
environments = builder.target(EnvironmentCollectionApi.class, basePath); // document = builder.target(DocumentIndividualApi.class, basePath);
subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); // application = builder.target(ApplicationIndividualApi.class, basePath);
tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); // environments = builder.target(EnvironmentCollectionApi.class, basePath);
// subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
// tiers = builder.target(ThrottlingTierCollectionApi.class, basePath);
} }
public APIIndividualApi getApi() { public ApIsApi getApIsApi() {
return api; return apIsApi;
} }
public APICollectionApi getApis() { public ApiLifecycleApi getApiLifecycleApi() {
return apis; return apiLifecycleApi;
} }
public DocumentIndividualApi getDocument() { // public APIIndividualApi getApi() {
return document; // return api;
} // }
//
public ApplicationIndividualApi getApplication() { // public APICollectionApi getApis() {
return application; // return apis;
} // }
//
public EnvironmentCollectionApi getEnvironments() { // public DocumentIndividualApi getDocument() {
return environments; // return document;
} // }
//
public SubscriptionCollectionApi getSubscriptions() { // public ApplicationIndividualApi getApplication() {
return subscriptions; // return application;
} // }
//
public ThrottlingTierCollectionApi getTiers() { // public EnvironmentCollectionApi getEnvironments() {
return tiers; // return environments;
} // }
//
// public SubscriptionCollectionApi getSubscriptions() {
// return subscriptions;
// }
//
// public ThrottlingTierCollectionApi getTiers() {
// return tiers;
// }
} }

View File

@ -39,16 +39,17 @@ import java.util.concurrent.TimeUnit;
public class StoreClient { public class StoreClient {
private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class); private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class);
private APICollectionApi apis = null; private ApplicationsApi applicationsApi = null;
private APIIndividualApi individualApi = null; // private APICollectionApi apis = null;
private ApplicationCollectionApi applications = null; // private ApIsApi individualApi = null;
private ApplicationIndividualApi individualApplication = null; // private ApplicationsApi applications = null;
private SubscriptionCollectionApi subscriptions = null; // private ApplicationIndividualApi individualApplication = null;
private SubscriptionIndividualApi individualSubscription = null; // private SubscriptionCollectionApi subscriptions = null;
private SubscriptionMultitpleApi subscriptionMultitpleApi = null; // private SubscriptionIndividualApi individualSubscription = null;
private ThrottlingTierIndividualApi individualTier = null; // private SubscriptionMultitpleApi subscriptionMultitpleApi = null;
private TagCollectionApi tags = null; // private ThrottlingTierIndividualApi individualTier = null;
private ThrottlingTierCollectionApi tiers = null; // private TagsApi tags = null;
// private ThrottlingTierCollectionApi tiers = null;
public StoreClient(RequestInterceptor requestInterceptor) { public StoreClient(RequestInterceptor requestInterceptor) {
@ -60,58 +61,59 @@ public class StoreClient {
.requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder());
String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint());
apis = builder.target(APICollectionApi.class, basePath); applicationsApi = builder.target(ApplicationsApi.class, basePath);
individualApi = builder.target(APIIndividualApi.class, basePath); // apis = builder.target(APICollectionApi.class, basePath);
applications = builder.target(ApplicationCollectionApi.class, basePath); // individualApi = builder.target(ApIsApi.class, basePath);
individualApplication = builder.target(ApplicationIndividualApi.class, basePath); // applications = builder.target(ApplicationCollectionApi.class, basePath);
subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); // individualApplication = builder.target(ApplicationIndividualApi.class, basePath);
individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); // subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); // individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath);
tags = builder.target(TagCollectionApi.class, basePath); // subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath);
individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); // tags = builder.target(TagCollectionApi.class, basePath);
tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) // individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath);
.options(new Request.Options(10000, 5000)) // tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1))
.target(ThrottlingTierCollectionApi.class, basePath); // .options(new Request.Options(10000, 5000))
// .target(ThrottlingTierCollectionApi.class, basePath);
} }
public APICollectionApi getApis() { // public APICollectionApi getApis() {
return apis; // return apis;
} // }
//
public APIIndividualApi getIndividualApi() { // public APIIndividualApi getIndividualApi() {
return individualApi; // return individualApi;
} // }
//
public ApplicationCollectionApi getApplications() { // public ApplicationCollectionApi getApplications() {
return applications; // return applications;
} // }
//
public ApplicationIndividualApi getIndividualApplication() { // public ApplicationIndividualApi getIndividualApplication() {
return individualApplication; // return individualApplication;
} // }
//
public SubscriptionCollectionApi getSubscriptions() { // public SubscriptionCollectionApi getSubscriptions() {
return subscriptions; // return subscriptions;
} // }
//
public SubscriptionIndividualApi getIndividualSubscription() { // public SubscriptionIndividualApi getIndividualSubscription() {
return individualSubscription; // return individualSubscription;
} // }
//
public ThrottlingTierIndividualApi getIndividualTier() { // public ThrottlingTierIndividualApi getIndividualTier() {
return individualTier; // return individualTier;
} // }
//
public TagCollectionApi getTags() { // public TagCollectionApi getTags() {
return tags; // return tags;
} // }
//
public ThrottlingTierCollectionApi getTiers() { // public ThrottlingTierCollectionApi getTiers() {
return tiers; // return tiers;
} // }
//
public SubscriptionMultitpleApi getSubscriptionMultitpleApi() { // public SubscriptionMultitpleApi getSubscriptionMultitpleApi() {
return subscriptionMultitpleApi; // return subscriptionMultitpleApi;
} // }
} }

View File

@ -26,61 +26,59 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<build> <build>
<plugins> <plugins>
<!--swagger yaml is used to generate code--> <plugin>
<plugin> <groupId>org.openapitools</groupId>
<groupId>io.swagger</groupId> <artifactId>openapi-generator-maven-plugin</artifactId>
<artifactId>swagger-codegen-maven-plugin</artifactId> <version>5.0.0</version>
<version>2.2.1</version> <executions>
<executions> <execution>
<execution> <phase>process-resources</phase>
<phase>process-resources</phase> <id>publisher</id>
<id>publisher</id> <goals>
<goals> <goal>generate</goal>
<goal>generate</goal> </goals>
</goals> <configuration>
<configuration> <inputSpec>${project.basedir}/src/main/resources/publisher-api.yaml</inputSpec>
<inputSpec>${project.basedir}/src/main/resources/publisher-api.yaml</inputSpec> <generatorName>java</generatorName>
<language>java</language> <configOptions>
<configOptions> <apiPackage>${project.artifactId}.publisher.api</apiPackage>
<apiPackage>${project.artifactId}.publisher.api</apiPackage> <modelPackage>${project.artifactId}.publisher.model</modelPackage>
<modelPackage>${project.artifactId}.publisher.model</modelPackage> </configOptions>
</configOptions> </configuration>
<library>feign</library> </execution>
</configuration> <execution>
</execution> <phase>process-resources</phase>
<execution> <id>store</id>
<phase>process-resources</phase> <goals>
<id>store</id> <goal>generate</goal>
<goals> </goals>
<goal>generate</goal> <configuration>
</goals> <inputSpec>${project.basedir}/src/main/resources/devportal-api.yaml</inputSpec>
<configuration> <generatorName>java</generatorName>
<inputSpec>${project.basedir}/src/main/resources/store-api.yaml</inputSpec> <configOptions>
<language>java</language> <apiPackage>${project.artifactId}.store.api</apiPackage>
<configOptions> <modelPackage>${project.artifactId}.store.model</modelPackage>
<apiPackage>${project.artifactId}.store.api</apiPackage> </configOptions>
<modelPackage>${project.artifactId}.store.model</modelPackage> </configuration>
</configOptions> </execution>
<library>feign</library> </executions>
</configuration> </plugin>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId> <groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId> <artifactId>replacer</artifactId>
<version>1.5.2</version> <version>1.5.2</version>
<executions> <executions>
<!-- Replace java code that is generated from swagger to fix swagger client generation issues. --> <!--Replace java code that is generated from swagger to fix swagger client generation issues.-->
<execution> <execution>
<phase>process-resources</phase> <phase>process-resources</phase>
<id>replace-for-swagger-genenerated-code-publisher</id> <id>replace-for-openapi-genenerated-code-publisher</id>
<goals> <goals>
<goal>replace</goal> <goal>replace</goal>
</goals> </goals>
<configuration> <configuration>
<file>${project.basedir}/target/generated-sources/swagger/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java</file> <file>${project.basedir}/target/generated-sources/openapi/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java</file>
<replacements> <replacements>
<replacement> <replacement>
<token>CURRENT_TENANT</token> <token>CURRENT_TENANT</token>
@ -115,28 +113,33 @@
org.wso2.carbon.apimgt.integration.generated.client.store.api.*, org.wso2.carbon.apimgt.integration.generated.client.store.api.*,
org.wso2.carbon.apimgt.integration.generated.client.store.model.* org.wso2.carbon.apimgt.integration.generated.client.store.model.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
feign;version="${io.github.openfeign.version.range}", com.google.gson;version="[2.8,3)",
feign.jackson;version="${io.github.openfeign.version.range}", com.google.gson.annotations;version="[2.8,3)",
feign.codec;version="${io.github.openfeign.version.range}", com.google.gson.internal.bind.util,
feign.auth;version="${io.github.openfeign.version.range}", com.google.gson.reflect;version="[2.8,3)",
feign.gson;version="${io.github.openfeign.version.range}", com.google.gson.stream;version="[2.8,3)",
feign.slf4j;version="${io.github.openfeign.version.range}", io.gsonfire;version="[1.8,2)",
com.google.gson, io.swagger.annotations;version="[1.5,2)",
com.fasterxml.jackson.core;resolution:=optional, javax.annotation;version="[3.0,4)",
com.fasterxml.jackson.annotation, javax.net.ssl,
com.fasterxml.jackson.databind;resolution:=optional, okhttp3,
io.swagger.annotations, okhttp3.internal.http,
javax.net.ssl, okhttp3.internal.tls,
com.fasterxml.jackson.datatype.joda;resolution:=optional, okhttp3.logging,
org.apache.oltu.oauth2.client.*;resolution:=optional, okio,
org.apache.oltu.oauth2.common.*;resolution:=optional, org.apache.oltu.oauth2.client;version="[1.0,2)",
org.junit;resolution:=optional, org.apache.oltu.oauth2.client.request;version="[1.0,2)",
</Import-Package> org.apache.oltu.oauth2.client.response;version="[1.0,2)",
<Embed-Dependency> org.apache.oltu.oauth2.common.exception;version="[1.0,2)",
jsr311-api, org.apache.oltu.oauth2.common.message.types;version="[1.0,2)",
feign-jaxrs org.threeten.bp;version="[1.5,2)",
</Embed-Dependency> org.threeten.bp.format;version="[1.5,2)",
org.threeten.bp.temporal;version="[1.5,2)",
org.wso2.carbon.apimgt.integration.generated.client.publisher.model,
org.wso2.carbon.apimgt.integration.generated.client.store.model
</Import-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
@ -145,60 +148,105 @@
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.1.7</version>
</dependency>
<!---->
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>javax.ws.rs</groupId> <!--<groupId>javax.ws.rs</groupId>-->
<artifactId>jsr311-api</artifactId> <!--<artifactId>jsr311-api</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>com.squareup.okhttp3</groupId>
<artifactId>junit</artifactId> <artifactId>okhttp</artifactId>
</dependency> <version>4.9.1</version>
<dependency> </dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId> <dependency>
</dependency> <groupId>org.apache.oltu.oauth2</groupId>
<dependency> <artifactId>org.apache.oltu.oauth2.client</artifactId>
<groupId>io.github.openfeign</groupId> <version>1.0.1</version>
<artifactId>feign-jackson</artifactId> </dependency>
</dependency>
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>com.squareup.okhttp3</groupId>
<artifactId>feign-jaxrs</artifactId> <artifactId>logging-interceptor</artifactId>
</dependency> <version>4.9.1</version>
<dependency> </dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-gson</artifactId> <dependency>
</dependency> <groupId>org.threeten</groupId>
<dependency> <artifactId>threetenbp</artifactId>
<groupId>org.testng</groupId> <version>1.5.0</version>
<artifactId>testng</artifactId> </dependency>
</dependency>
<dependency> <dependency>
<groupId>org.apache.oltu.oauth2</groupId> <groupId>io.gsonfire</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId> <artifactId>gson-fire</artifactId>
</dependency> <version>1.8.5</version>
<dependency> </dependency>
<groupId>io.github.openfeign</groupId> <dependency>
<artifactId>feign-slf4j</artifactId> <groupId>io.swagger.parser.v3</groupId>
</dependency> <artifactId>swagger-parser</artifactId>
<dependency> <version>2.0.25</version>
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId> </dependency>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency> <!--<dependency>-->
<dependency> <!--<groupId>junit</groupId>-->
<groupId>com.fasterxml.jackson.datatype</groupId> <!--<artifactId>junit</artifactId>-->
<artifactId>jackson-datatype-joda</artifactId> <!--</dependency>-->
</dependency> <!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-core</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-jackson</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-jaxrs</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-gson</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.testng</groupId>-->
<!--<artifactId>testng</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.oltu.oauth2</groupId>-->
<!--<artifactId>org.apache.oltu.oauth2.client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.github.openfeign</groupId>-->
<!--<artifactId>feign-slf4j</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>-->
<!--<artifactId>jackson-databind</artifactId>-->
<!--<version>${jackson-databind.version}</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>com.fasterxml.jackson.datatype</groupId>-->
<!--<artifactId>jackson-datatype-joda</artifactId>-->
<!--</dependency>-->
</dependencies> </dependencies>
<properties> <properties>
<maven.javadoc.skip>true</maven.javadoc.skip> <maven.javadoc.skip>true</maven.javadoc.skip>

View File

@ -43,10 +43,22 @@
<dependency> <dependency>
<groupId>org.eclipse.osgi</groupId> <groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId> <artifactId>org.eclipse.osgi</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.osgi</groupId> <groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId> <artifactId>org.eclipse.osgi.services</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
@ -55,62 +67,166 @@
<dependency> <dependency>
<groupId>org.wso2.tomcat</groupId> <groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId> <artifactId>tomcat</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.tomcat</groupId> <groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId> <artifactId>tomcat-servlet-api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId> <artifactId>org.wso2.carbon.core</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId> <artifactId>org.wso2.carbon.utils</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.axis2.wso2</groupId> <groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId> <artifactId>axis2</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.orbit.org.scannotation</groupId> <groupId>org.wso2.orbit.org.scannotation</groupId>
<artifactId>scannotation</artifactId> <artifactId>scannotation</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.governance</groupId> <groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.api</artifactId> <artifactId>org.wso2.carbon.governance.api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.governance</groupId> <groupId>org.wso2.carbon.governance</groupId>
<artifactId>org.wso2.carbon.governance.lcm</artifactId> <artifactId>org.wso2.carbon.governance.lcm</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId> <artifactId>javax.ws.rs-api</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <artifactId>org.wso2.carbon.apimgt.api</artifactId>
<scope>provided</scope>
<version>9.0.5</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
<version>9.0.5</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database.wso2</groupId> <groupId>com.h2database.wso2</groupId>
@ -144,70 +260,62 @@
org.wso2.carbon.apimgt.webapp.publisher.* org.wso2.carbon.apimgt.webapp.publisher.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, com.google.gson;version="2.3",com.google.gson.reflect;
org.osgi.service.component, version="2.3",io.swagger.annotations,javax.servlet;version="2.6",javax.xml,javax.xml.bind,javax.xml.bind.annotat
org.apache.commons.logging, ion,javax.xml.parsers,org.apache.catalina;version="9.0",org.apache.ca
javax.servlet, talina.core;version="9.0",org.apache.commons.logging;version="1.2",org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
javax.xml.*, org.osgi.service.*;version="${imp.package.version.osgi.service}",org.scannotation;version="1.0",org.scannotation.archiveiterator;ve
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, rsion="1.0",org.w3c.dom,org.wso2.carbon.apimgt.annotations.api,org.ws
com.google.gson.*, o2.carbon.apimgt.api,org.wso2.carbon.apimgt.api.model,org.wso2.carbon
org.apache.catalina, .apimgt.impl,org.wso2.carbon.apimgt.webapp.publisher,org.wso2.carbon.
org.apache.catalina.core, apimgt.webapp.publisher.config,org.wso2.carbon.apimgt.webapp.publishe
org.apache.axis2.*;version="${axis2.osgi.version.range}", r.dto,org.wso2.carbon.apimgt.webapp.publisher.exception,org.wso2.carb
org.wso2.carbon.core, on.apimgt.webapp.publisher.lifecycle.listener,org.wso2.carbon.apimgt.
org.apache.commons.lang, webapp.publisher.lifecycle.util,org.wso2.carbon.base;version="1.0",or
org.wso2.carbon.utils, g.wso2.carbon.context;version="4.6",org.wso2.carbon.core;version="4.6
org.wso2.carbon.apimgt.annotations.*, ",org.wso2.carbon.core.util;version="4.6",org.wso2.carbon.registry.co
org.wso2.carbon.governance.lcm.util.*, re.service;version="1.0",org.wso2.carbon.user.api;version="1.0",org.w
org.wso2.carbon.registry.core.*, so2.carbon.user.core.service;version="4.6",org.wso2.carbon.user.core.
io.swagger.annotations, tenant;version="4.6",org.wso2.carbon.utils;version="4.6",org.wso2.car
javax.net.ssl, bon.utils.multitenancy;version="4.6"
org.scannotation,
org.scannotation.archiveiterator,
org.w3c.dom,
org.wso2.carbon.apimgt.integration.client.*,
org.wso2.carbon.context,
org.wso2.carbon.core.util,
org.wso2.carbon.user.api,
org.wso2.carbon.user.core.*,
org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.apimgt.integration.generated.client.publisher.api,
org.wso2.carbon.apimgt.integration.generated.client.publisher.model
</Import-Package> </Import-Package>
<Embed-Dependency> <Embed-Dependency>
javax.ws.rs-api, <!--javax.ws.rs;scope=compile|runtime;inline=false-->
scribe;scope=compile|runtime;inline=false; jsr311-api;scope=compile|runtime;inline=false
<!--scribe;scope=compile|runtime;inline=false;-->
</Embed-Dependency> </Embed-Dependency>
<DynamicImport-Package>*</DynamicImport-Package> <!--<DynamicImport-Package>*</DynamicImport-Package>-->
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <!--<plugin>-->
<groupId>org.jacoco</groupId> <!--<groupId>org.jacoco</groupId>-->
<artifactId>jacoco-maven-plugin</artifactId> <!--<artifactId>jacoco-maven-plugin</artifactId>-->
<configuration> <!--<configuration>-->
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile> <!--<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>-->
</configuration> <!--</configuration>-->
<executions> <!--<executions>-->
<execution> <!--<execution>-->
<id>jacoco-initialize</id> <!--<id>jacoco-initialize</id>-->
<goals> <!--<goals>-->
<goal>prepare-agent</goal> <!--<goal>prepare-agent</goal>-->
</goals> <!--</goals>-->
</execution> <!--</execution>-->
<execution> <!--<execution>-->
<id>jacoco-site</id> <!--<id>jacoco-site</id>-->
<phase>test</phase> <!--<phase>test</phase>-->
<goals> <!--<goals>-->
<goal>report</goal> <!--<goal>report</goal>-->
</goals> <!--</goals>-->
<configuration> <!--<configuration>-->
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile> <!--<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>-->
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory> <!--<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>-->
</configuration> <!--</configuration>-->
</execution> <!--</execution>-->
</executions> <!--</executions>-->
</plugin> <!--</plugin>-->
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -18,15 +18,34 @@
*/ */
package org.wso2.carbon.apimgt.webapp.publisher; package org.wso2.carbon.apimgt.webapp.publisher;
import feign.FeignException; import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*; import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; import org.wso2.carbon.apimgt.api.FaultGatewaysException;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
import org.wso2.carbon.apimgt.api.model.APIRevision;
import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment;
import org.wso2.carbon.apimgt.api.model.CORSConfiguration;
import org.wso2.carbon.apimgt.api.model.Scope;
import org.wso2.carbon.apimgt.api.model.Tier;
import org.wso2.carbon.apimgt.api.model.URITemplate;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
import org.wso2.carbon.apimgt.webapp.publisher.dto.ApiUriTemplate;
import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException; import org.wso2.carbon.apimgt.webapp.publisher.exception.APIManagerPublisherException;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
//import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*;
//import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient;
/** /**
* This class represents the concrete implementation of the APIPublisherService that corresponds to providing all * This class represents the concrete implementation of the APIPublisherService that corresponds to providing all
@ -39,6 +58,7 @@ public class APIPublisherServiceImpl implements APIPublisherService {
private static final String PUBLISHED_STATUS = "PUBLISHED"; private static final String PUBLISHED_STATUS = "PUBLISHED";
private static final String CREATED_STATUS = "CREATED"; private static final String CREATED_STATUS = "CREATED";
private static final String PUBLISH_ACTION = "Publish"; private static final String PUBLISH_ACTION = "Publish";
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
@Override @Override
public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException { public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException {
@ -47,99 +67,127 @@ public class APIPublisherServiceImpl implements APIPublisherService {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner()); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner());
try { try {
PublisherClient publisherClient = APIPublisherDataHolder.getInstance().getIntegrationClientService() APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(apiConfig.getOwner());
.getPublisherClient();
API api = getAPI(apiConfig); API api = getAPI(apiConfig);
APIList apiList = publisherClient.getApis().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null);
if (!isExist(api, apiList)) { if (!apiProvider.isAPIAvailable(api.getId())) {
api = publisherClient.getApi().apisPost(api, CONTENT_TYPE, null); API createdAPI = apiProvider.addAPI(api);
if (CREATED_STATUS.equals(api.getStatus())) { if (CREATED_STATUS.equals(createdAPI.getStatus())) {
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null); apiProvider.changeLifeCycleStatus(tenantDomain, createdAPI.getUuid(), PUBLISH_ACTION, null);
APIRevision apiRevision = new APIRevision();
apiRevision.setApiUUID(createdAPI.getUuid());
apiRevision.setDescription("Initial Revision");
String apiRevisionId = apiProvider.addAPIRevision(apiRevision, tenantDomain);
APIRevisionDeployment apiRevisionDeployment = new APIRevisionDeployment();
apiRevisionDeployment.setDeployment(API_PUBLISH_ENVIRONMENT);
apiRevisionDeployment.setVhost("localhost");
apiRevisionDeployment.setDisplayOnDevportal(true);
List<APIRevisionDeployment> apiRevisionDeploymentList = new ArrayList<>();
apiRevisionDeploymentList.add(apiRevisionDeployment);
apiProvider.deployAPIRevision(createdAPI.getUuid(), apiRevisionId, apiRevisionDeploymentList);
} }
} else { } else {
if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) {
for (APIInfo apiInfo : apiList.getList()) { API existingAPI = apiProvider.getAPI(api.getId());
if (api.getName().equals(apiInfo.getName()) && api.getVersion().equals(apiInfo.getVersion())) { api.setStatus(existingAPI.getStatus());
api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, null); apiProvider.updateAPI(api);
if (api != null && CREATED_STATUS.equals(api.getStatus())) { if (api.getId().getName().equals(existingAPI.getId().getName()) &&
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, api.getId().getVersion().equals(existingAPI.getId().getVersion())) {
null); if (CREATED_STATUS.equals(existingAPI.getStatus())) {
} apiProvider.changeLifeCycleStatus(tenantDomain, existingAPI.getUuid(), PUBLISH_ACTION, null);
} }
} }
} }
} }
} catch (FeignException e) {
} catch (FaultGatewaysException | APIManagementException e) {
throw new APIManagerPublisherException(e); throw new APIManagerPublisherException(e);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
} }
private boolean isExist(API api, APIList apiList) {
if (apiList == null || apiList.getList() == null || apiList.getList().size() == 0) {
return false;
}
for (APIInfo existingApi : apiList.getList()) {
if (existingApi.getName() != null && existingApi.getName().equals(api.
getName()) && existingApi.getVersion() != null &&
existingApi.getVersion().equals(api.getVersion())) {
return true;
}
}
return false;
}
private API getAPI(APIConfig config) { private API getAPI(APIConfig config) {
API api = new API(); APIIdentifier apiIdentifier = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
api.setName(config.getName()); API api = new API(apiIdentifier);
api.setDescription(""); api.setDescription("");
String context = config.getContext(); String context = config.getContext();
context = context.startsWith("/") ? context : ("/" + context); context = context.startsWith("/") ? context : ("/" + context);
api.setContext(context); api.setContext(context + "/" + config.getVersion());
api.setVersion(config.getVersion()); // api.setContext(context);
api.setProvider(config.getOwner()); api.setStatus(CREATED_STATUS);
api.setApiDefinition(APIPublisherUtil.getSwaggerDefinition(config)); api.setWsdlUrl(null);
api.setWsdlUri(null); api.setResponseCache("Disabled");
api.setStatus(PUBLISHED_STATUS); api.setContextTemplate(context + "/{version}" );
api.setResponseCaching("DISABLED"); api.setSwaggerDefinition(APIPublisherUtil.getSwaggerDefinition(config));
api.setDestinationStatsEnabled("false"); api.setType("HTTP");
api.isDefaultVersion(config.isDefault());
List<String> transport = new ArrayList<>();
transport.add("https");
transport.add("http");
api.transport(transport);
api.setTags(Arrays.asList(config.getTags()));
api.addTiersItem(UNLIMITED_TIER);
api.setGatewayEnvironments(API_PUBLISH_ENVIRONMENT);
if (config.isSharedWithAllTenants()) {
api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.all_tenants);
api.setVisibility(API.VisibilityEnum.PUBLIC);
} else {
api.setSubscriptionAvailability(API.SubscriptionAvailabilityEnum.current_tenant);
api.setVisibility(API.VisibilityEnum.PRIVATE);
}
String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() +
"\",\"config\":null},\"implementation_status\":\"managed\",\"endpoint_type\":\"http\"}";
Set<URITemplate> uriTemplates = new HashSet<>();
Iterator<ApiUriTemplate> iterator;
for (iterator = config.getUriTemplates().iterator(); iterator.hasNext(); ) {
ApiUriTemplate apiUriTemplate = iterator.next();
URITemplate uriTemplate = new URITemplate();
uriTemplate.setAuthType(apiUriTemplate.getAuthType());
uriTemplate.setHTTPVerb(apiUriTemplate.getHttpVerb());
uriTemplate.setResourceURI(apiUriTemplate.getResourceURI());
uriTemplate.setUriTemplate(apiUriTemplate.getUriTemplate());
Scope scope = new Scope();
if (apiUriTemplate.getScope() != null) {
scope.setName(apiUriTemplate.getScope().getName());
scope.setDescription(apiUriTemplate.getScope().getDescription());
scope.setKey(apiUriTemplate.getScope().getKey());
scope.setRoles(apiUriTemplate.getScope().getRoles());
uriTemplate.setScope(scope);
}
uriTemplates.add(uriTemplate);
}
api.setUriTemplates(uriTemplates);
api.setApiOwner(config.getOwner());
api.setDefaultVersion(config.isDefault());
api.setTransports("https,http");
Set<String> tags = new HashSet<>();
tags.addAll(Arrays.asList(config.getTags()));
api.setTags(tags);
Set<Tier> availableTiers = new HashSet<>();
availableTiers.add(new Tier(UNLIMITED_TIER));
api.setAvailableTiers(availableTiers);
Set<String> environments = new HashSet<>();
environments.add(API_PUBLISH_ENVIRONMENT);
api.setEnvironments(environments);
if (config.isSharedWithAllTenants()) {
api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_ALL_TENANTS);
api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY);
} else {
api.setSubscriptionAvailability(APIConstants.SUBSCRIPTION_TO_CURRENT_TENANT);
api.setVisibility(APIConstants.API_PRIVATE_VISIBILITY);
}
// String endpointConfig = "{\"production_endpoints\":{\"url\":\"" + config.getEndpoint() +
// "\",\"config\":null},\"endpoint_type\":\"http\"}";
String endpointConfig = "{ \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \" " +
config.getEndpoint() + "\" }, \"production_endpoints\": { \"url\": \" "+ config.getEndpoint()+"\" } }";
api.setEndpointConfig(endpointConfig); api.setEndpointConfig(endpointConfig);
APICorsConfiguration apiCorsConfiguration = new APICorsConfiguration();
List<String> accessControlAllowOrigins = new ArrayList<>(); List<String> accessControlAllowOrigins = new ArrayList<>();
accessControlAllowOrigins.add("*"); accessControlAllowOrigins.add("*");
apiCorsConfiguration.setAccessControlAllowOrigins(accessControlAllowOrigins);
List<String> accessControlAllowHeaders = new ArrayList<>(); List<String> accessControlAllowHeaders = new ArrayList<>();
accessControlAllowHeaders.add("authorization"); accessControlAllowHeaders.add("authorization");
accessControlAllowHeaders.add("Access-Control-Allow-Origin"); accessControlAllowHeaders.add("Access-Control-Allow-Origin");
accessControlAllowHeaders.add("Content-Type"); accessControlAllowHeaders.add("Content-Type");
accessControlAllowHeaders.add("SOAPAction"); accessControlAllowHeaders.add("SOAPAction");
apiCorsConfiguration.setAccessControlAllowHeaders(accessControlAllowHeaders); accessControlAllowHeaders.add("apikey");
accessControlAllowHeaders.add("testKey");
List<String> accessControlAllowMethods = new ArrayList<>(); List<String> accessControlAllowMethods = new ArrayList<>();
accessControlAllowMethods.add("GET"); accessControlAllowMethods.add("GET");
accessControlAllowMethods.add("PUT"); accessControlAllowMethods.add("PUT");
@ -147,10 +195,16 @@ public class APIPublisherServiceImpl implements APIPublisherService {
accessControlAllowMethods.add("POST"); accessControlAllowMethods.add("POST");
accessControlAllowMethods.add("PATCH"); accessControlAllowMethods.add("PATCH");
accessControlAllowMethods.add("OPTIONS"); accessControlAllowMethods.add("OPTIONS");
apiCorsConfiguration.setAccessControlAllowMethods(accessControlAllowMethods); CORSConfiguration corsConfiguration = new CORSConfiguration(false, accessControlAllowOrigins, false,
apiCorsConfiguration.setAccessControlAllowCredentials(false); accessControlAllowHeaders, accessControlAllowMethods);
apiCorsConfiguration.corsConfigurationEnabled(false); api.setCorsConfiguration(corsConfiguration);
api.setCorsConfiguration(apiCorsConfiguration);
api.setAuthorizationHeader("Authorization");
List<String> keyManagers = new ArrayList<>();
keyManagers.add("all");
api.setKeyManagers(keyManagers);
api.setEnableStore(true);
return api; return api;
} }
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.wso2.carbon.apimgt.webapp.publisher.internal; package org.wso2.carbon.apimgt.webapp.publisher.internal;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; //import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.webapp.publisher.APIConfig; import org.wso2.carbon.apimgt.webapp.publisher.APIConfig;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
@ -37,7 +37,7 @@ public class APIPublisherDataHolder {
private RegistryService registryService; private RegistryService registryService;
private boolean isServerStarted; private boolean isServerStarted;
private Stack<APIConfig> unpublishedApis = new Stack<>(); private Stack<APIConfig> unpublishedApis = new Stack<>();
private IntegrationClientService integrationClientService; // private IntegrationClientService integrationClientService;
private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder(); private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder();
@ -117,12 +117,12 @@ public class APIPublisherDataHolder {
this.unpublishedApis = unpublishedApis; this.unpublishedApis = unpublishedApis;
} }
public IntegrationClientService getIntegrationClientService() { // public IntegrationClientService getIntegrationClientService() {
return integrationClientService; // return integrationClientService;
} // }
public void setIntegrationClientService( // public void setIntegrationClientService(
IntegrationClientService integrationClientService) { // IntegrationClientService integrationClientService) {
this.integrationClientService = integrationClientService; // this.integrationClientService = integrationClientService;
} // }
} }

View File

@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; //import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler; import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler;
@ -45,11 +45,7 @@ import org.wso2.carbon.user.core.service.RealmService;
* policy="dynamic" * policy="dynamic"
* bind="setRegistryService" * bind="setRegistryService"
* unbind="unsetRegistryService" * unbind="unsetRegistryService"
* interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService"
* cardinality="1..1"
* policy="dynamic"
* bind="setIntegrationClientService"
* unbind="unsetIntegrationClientService"
*/ */
public class APIPublisherServiceComponent { public class APIPublisherServiceComponent {
@ -120,14 +116,14 @@ public class APIPublisherServiceComponent {
APIPublisherDataHolder.getInstance().setRegistryService(null); APIPublisherDataHolder.getInstance().setRegistryService(null);
} }
protected void setIntegrationClientService(IntegrationClientService integrationClientService) { // protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
if (integrationClientService != null && log.isDebugEnabled()) { // if (integrationClientService != null && log.isDebugEnabled()) {
log.debug("integrationClientService initialized"); // log.debug("integrationClientService initialized");
} // }
APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService); // APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService);
} // }
//
protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) { // protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
APIPublisherDataHolder.getInstance().setIntegrationClientService(null); // APIPublisherDataHolder.getInstance().setIntegrationClientService(null);
} // }
} }

View File

@ -34,13 +34,13 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.apimgt.integration.generated.client</module> <!--<module>org.wso2.carbon.apimgt.integration.generated.client</module>-->
<module>org.wso2.carbon.apimgt.integration.client</module> <!--<module>org.wso2.carbon.apimgt.integration.client</module>-->
<module>org.wso2.carbon.apimgt.webapp.publisher</module> <module>org.wso2.carbon.apimgt.webapp.publisher</module>
<module>org.wso2.carbon.apimgt.application.extension</module> <module>org.wso2.carbon.apimgt.application.extension</module>
<module>org.wso2.carbon.apimgt.application.extension.api</module> <module>org.wso2.carbon.apimgt.application.extension.api</module>
<module>org.wso2.carbon.apimgt.annotations</module> <module>org.wso2.carbon.apimgt.annotations</module>
<module>org.wso2.carbon.apimgt.handlers</module> <!--<module>org.wso2.carbon.apimgt.handlers</module>-->
</modules> </modules>
<build> <build>

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -56,7 +56,7 @@
io.swagger.annotations.*;resolution:=optional, io.swagger.annotations.*;resolution:=optional,
com.fasterxml.jackson.annotation, com.fasterxml.jackson.annotation,
javax.validation.constraints, javax.validation.constraints,
javax.xml.bind.annotation.*, javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
org.wso2.carbon.device.application.mgt.common.* org.wso2.carbon.device.application.mgt.common.*

View File

@ -51,8 +51,66 @@
<Bundle-Description>Application Management Core Bundle</Bundle-Description> <Bundle-Description>Application Management Core Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.application.mgt.core.internal</Private-Package> <Private-Package>org.wso2.carbon.device.application.mgt.core.internal</Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, <!--com.dd.plist;version="[1.21,2)",com.google.gson;versio-->
org.osgi.service.component, <!--n="[2.3,3)",com.google.gson.reflect;version="[2.3,3)",javax.annotatio-->
<!--n;version="[1.3,2)",javax.naming,javax.sql,javax.ws.rs.core;version="-->
<!--[2.0,3)",javax.xml.bind;version="[2.3,3)",javax.xml.bind.annotation;v-->
<!--ersion="[2.3,3)",javax.xml.parsers,org.apache.commons.codec.binary;ve-->
<!--rsion="[1.4,2)",org.apache.commons.codec.digest;version="[1.4,2)",org-->
<!--.apache.commons.httpclient;version="[3.1,4)",org.apache.commons.httpc-->
<!--lient.methods;version="[3.1,4)",org.apache.commons.io;version="[2.4,3-->
<!--)",org.apache.commons.lang;version="[2.6,3)",org.apache.commons.loggi-->
<!--ng;version="[1.2,2)",org.apache.commons.validator.routines;version="[-->
<!--1.6,2)",org.apache.cxf.jaxrs.ext.multipart;version="[3.3,4)",org.boun-->
<!--cycastle.cert,org.bouncycastle.cert.jcajce,org.bouncycastle.cms,org.b-->
<!--ouncycastle.jce.provider;version="[1.60,2)",org.bouncycastle.util;ver-->
<!--sion="[1.60,2)",org.json;version="[3.0,4)",org.osgi.framework;version-->
<!--="[1.7,2)",org.osgi.service.component;version="[1.2,2)",org.quartz;ve-->
<!--rsion="[2.1,3)",org.wso2.carbon.apimgt.application.extension;version=-->
<!--"[4.1,5)",org.wso2.carbon.apimgt.application.extension.dto;version="[-->
<!--4.1,5)",org.wso2.carbon.apimgt.application.extension.exception;versio-->
<!--n="[4.1,5)",org.wso2.carbon.context;version="[4.6,5)",org.wso2.carbon-->
<!--.device.application.mgt.common;version="[4.1,5)",org.wso2.carbon.devi-->
<!--ce.application.mgt.common.config;version="[4.1,5)",org.wso2.carbon.de-->
<!--vice.application.mgt.common.dto;version="[4.1,5)",org.wso2.carbon.dev-->
<!--ice.application.mgt.common.exception;version="[4.1,5)",org.wso2.carbo-->
<!--n.device.application.mgt.common.response;version="[4.1,5)",org.wso2.c-->
<!--arbon.device.application.mgt.common.services;version="[4.1,5)",org.ws-->
<!--o2.carbon.device.application.mgt.common.wrapper;version="[4.1,5)",org-->
<!--.wso2.carbon.device.application.mgt.core.config,org.wso2.carbon.devic-->
<!--e.application.mgt.core.dao,org.wso2.carbon.device.application.mgt.cor-->
<!--e.dao.common,org.wso2.carbon.device.application.mgt.core.dao.impl,org-->
<!--.wso2.carbon.device.application.mgt.core.dao.impl.application,org.wso-->
<!--2.carbon.device.application.mgt.core.dao.impl.application.release,org-->
<!--.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate,org.-->
<!--wso2.carbon.device.application.mgt.core.dao.impl.review,org.wso2.carb-->
<!--on.device.application.mgt.core.dao.impl.subscription,org.wso2.carbon.-->
<!--device.application.mgt.core.dao.impl.visibility,org.wso2.carbon.devic-->
<!--e.application.mgt.core.exception,org.wso2.carbon.device.mgt.common;ve-->
<!--rsion="[4.1,5)",org.wso2.carbon.device.mgt.common.app.mgt;version="[4-->
<!--.1,5)",org.wso2.carbon.device.mgt.common.app.mgt.android;version="[4.-->
<!--1,5)",org.wso2.carbon.device.mgt.common.exceptions;version="[4.1,5)",-->
<!--org.wso2.carbon.device.mgt.common.group.mgt;version="[4.1,5)",org.wso-->
<!--2.carbon.device.mgt.common.operation.mgt;version="[4.1,5)",org.wso2.c-->
<!--arbon.device.mgt.common.permission.mgt;version="[4.1,5)",org.wso2.car-->
<!--bon.device.mgt.core.dto;version="[4.1,5)",org.wso2.carbon.device.mgt.-->
<!--core.operation.mgt;version="[4.1,5)",org.wso2.carbon.device.mgt.core.-->
<!--permission.mgt;version="[4.1,5)",org.wso2.carbon.device.mgt.core.serv-->
<!--ice;version="[4.1,5)",org.wso2.carbon.device.mgt.core.task.impl;versi-->
<!--on="[4.1,5)",org.wso2.carbon.device.mgt.core.util;version="[4.1,5)",o-->
<!--rg.wso2.carbon.identity.jwt.client.extension,org.wso2.carbon.identity-->
<!--.jwt.client.extension.dto,org.wso2.carbon.identity.jwt.client.extensi-->
<!--on.exception,org.wso2.carbon.identity.jwt.client.extension.service,or-->
<!--g.wso2.carbon.ndatasource.core;version="[4.6,5)",org.wso2.carbon.ntas-->
<!--k.common;version="[4.6,5)",org.wso2.carbon.ntask.core;version="[4.6,5-->
<!--)",org.wso2.carbon.ntask.core.service;version="[4.6,5)",org.wso2.carb-->
<!--on.user.api;version="[1.0,2)",org.wso2.carbon.user.core.service;versi-->
<!--on="[4.6,5)",org.wso2.carbon.utils;version="[4.6,5)",org.wso2.carbon.-->
<!--utils.dbcreator;version="[4.6,5)",org.xml.sax,org.xml.sax.helpers-->
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context.*, org.wso2.carbon.context.*,
@ -62,8 +120,8 @@
javax.sql, javax.sql,
com.google.gson.*, com.google.gson.*,
javax.naming, javax.naming,
javax.xml.bind.annotation, javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
javax.xml.bind, javax.xml.bind; version="${javax.xml.bind.imp.pkg.version}",
org.wso2.carbon.device.application.mgt.common.*, org.wso2.carbon.device.application.mgt.common.*,
org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.device.mgt.core.*,
org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common.*,
@ -348,6 +406,14 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId></groupId>-->
<!--<artifactId></artifactId>-->
<!--</dependency>-->
</dependencies> </dependencies>
</project> </project>

View File

@ -63,7 +63,7 @@ public class OAuthUtils {
apiApplicationKeyInfo = apiManagementProviderService. apiApplicationKeyInfo = apiManagementProviderService.
generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE,
registrationProfile.getApplicationName(), registrationProfile.isAllowedToAllDomains(), null, registrationProfile.isAllowedToAllDomains(),
Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD); Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD);
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -133,10 +133,22 @@
</profiles> </profiles>
<dependencies> <dependencies>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec.wso2</groupId> <groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
@ -147,24 +159,26 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.apache.cxf</groupId> <!--<groupId>org.apache.cxf</groupId>-->
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
</dependency> <!--<scope>provided</scope>-->
<dependency> <!--</dependency>-->
<groupId>org.apache.cxf</groupId> <!--<dependency>-->
<artifactId>cxf-rt-transports-http</artifactId> <!--<groupId>org.apache.cxf</groupId>-->
</dependency> <!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>javax.ws.rs</groupId> <!--<groupId>javax.ws.rs</groupId>-->
<artifactId>jsr311-api</artifactId> <!--<artifactId>jsr311-api</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
@ -207,11 +221,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>javax.servlet</groupId> <!--<groupId>javax.servlet</groupId>-->
<artifactId>javax.servlet-api</artifactId> <!--<artifactId>javax.servlet-api</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -133,10 +133,26 @@
</profiles> </profiles>
<dependencies> <dependencies>
<!--<dependency>-->
<!--<groupId>io.swagger</groupId>-->
<!--<artifactId>swagger-jaxrs</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>commons-codec.wso2</groupId> <groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
@ -147,14 +163,10 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.apache.cxf</groupId> <!--<groupId>org.apache.cxf</groupId>-->
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <!--<artifactId>cxf-rt-transports-http</artifactId>-->
</dependency> <!--</dependency>-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@ -204,11 +216,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>javax.servlet</groupId> <!--<groupId>javax.servlet</groupId>-->
<artifactId>javax.servlet-api</artifactId> <!--<artifactId>javax.servlet-api</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -72,8 +72,8 @@
org.wso2.carbon.certificate.mgt.core.util org.wso2.carbon.certificate.mgt.core.util
</Private-Package> </Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
org.apache.commons.collections.map, org.apache.commons.collections.map,
javax.security.auth.x500, javax.security.auth.x500,

View File

@ -140,8 +140,8 @@
org.apache.axis2.deployment.*, org.apache.axis2.deployment.*,
org.apache.commons.lang;version="${commons-lang.wso2.osgi.version.range}", org.apache.commons.lang;version="${commons-lang.wso2.osgi.version.range}",
org.apache.commons.logging, org.apache.commons.logging,
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.w3c.dom, org.w3c.dom,
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common.*,

View File

@ -82,8 +82,8 @@
org.wso2.carbon.device.mgt.extensions.pull.notification.* org.wso2.carbon.device.mgt.extensions.pull.notification.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.core.service org.wso2.carbon.device.mgt.core.service

View File

@ -135,7 +135,8 @@
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
com.google.gson, com.google.gson,
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.common.push.notification,
org.apache.commons.logging, org.apache.commons.logging,

View File

@ -126,13 +126,13 @@
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.apache.commons.logging, org.apache.commons.logging,
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.common.push.notification,
org.wso2.carbon.device.mgt.common, org.wso2.carbon.device.mgt.common,
org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.device.mgt.core.service,
org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt, org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core, org.wso2.carbon.core,
com.google.gson, com.google.gson,

View File

@ -148,7 +148,8 @@
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.apache.commons.logging, org.apache.commons.logging,
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.common.push.notification,
@ -157,7 +158,6 @@
org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.device.mgt.core.service,
org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception, org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt, org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core, org.wso2.carbon.core,
org.wso2.carbon.device.application.mgt.common.*, org.wso2.carbon.device.application.mgt.common.*,

View File

@ -135,14 +135,14 @@
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.apache.commons.logging, org.apache.commons.logging,
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.operation.mgt,
org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.common.push.notification,
org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.device.mgt.core.service,
org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception, org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework,
org.wso2.carbon.core, org.wso2.carbon.core,
org.wso2.carbon.device.mgt.common.* org.wso2.carbon.device.mgt.common.*
</Import-Package> </Import-Package>

View File

@ -146,15 +146,26 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.springframework</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>spring-web</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!---->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId> <artifactId>jsr311-api</artifactId>

View File

@ -200,8 +200,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig
DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
KeyManagerConfigurations kmConfig = deviceManagementConfig.getKeyManagerConfigurations(); KeyManagerConfigurations kmConfig = deviceManagementConfig.getKeyManagerConfigurations();
AppRegistrationCredentials credentials = DeviceManagerUtil.getApplicationRegistrationCredentials( AppRegistrationCredentials credentials = DeviceManagerUtil.getApplicationRegistrationCredentials(
System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HOST), System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HOST),
System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_GATEWAY_HTTPS_PORT), System.getProperty(DeviceManagementConstants.ConfigurationManagement.IOT_CORE_HTTPS_PORT),
kmConfig.getAdminUsername(), kmConfig.getAdminUsername(),
kmConfig.getAdminPassword()); kmConfig.getAdminPassword());
AccessTokenInfo accessTokenForAdmin = DeviceManagerUtil.getAccessTokenForDeviceOwner( AccessTokenInfo accessTokenForAdmin = DeviceManagerUtil.getAccessTokenForDeviceOwner(

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -107,8 +107,8 @@
org.wso2.carbon.device.mgt.analytics.data.publisher.*;version="${carbon.device.mgt.version}" org.wso2.carbon.device.mgt.analytics.data.publisher.*;version="${carbon.device.mgt.version}"
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging.*, org.apache.commons.logging.*,
org.wso2.carbon.utils.multitenancy, org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.context;version="${carbon.kernel.version.range}", org.wso2.carbon.context;version="${carbon.kernel.version.range}",

View File

@ -146,30 +146,41 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.springframework</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>spring-web</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!---->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>commons-httpclient.wso2</groupId> <groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>javax.ws.rs</groupId> <!--<groupId>javax.ws.rs</groupId>-->
<artifactId>jsr311-api</artifactId> <!--<artifactId>jsr311-api</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId> <artifactId>org.wso2.carbon.utils</artifactId>
@ -200,11 +211,11 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId> <!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId> <artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
@ -351,11 +362,11 @@
<artifactId>org.wso2.carbon.analytics.api</artifactId> <artifactId>org.wso2.carbon.analytics.api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics</groupId> <!--<groupId>org.wso2.carbon.analytics</groupId>-->
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId> <!--<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId> <artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
@ -402,11 +413,11 @@
<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId> <artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <!--<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.powermock</groupId> <groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId> <artifactId>powermock-module-testng</artifactId>

View File

@ -67,64 +67,64 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface DeviceEventManagementService { public interface DeviceEventManagementService {
@POST // @POST
@Path("/{type}") // @Path("/{type}")
@ApiOperation( // @ApiOperation(
produces = MediaType.APPLICATION_JSON, // produces = MediaType.APPLICATION_JSON,
httpMethod = "POST", // httpMethod = "POST",
value = "Adding the Event Type Definition", // value = "Adding the Event Type Definition",
notes = "Add the event definition for a device.", // notes = "Add the event definition for a device.",
tags = "Device Event Management", // tags = "Device Event Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
}) // })
} // }
) // )
@ApiResponses( // @ApiResponses(
value = { // value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK. \n Successfully added the event defintion.", // message = "OK. \n Successfully added the event defintion.",
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "ETag", // name = "ETag",
description = "Entity Tag of the response resource.\n" + // description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = // description =
"Date and time the resource was last modified.\n" + // "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
} // }
), // ),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = // message =
"Bad Request. \n"), // "Bad Request. \n"),
@ApiResponse( // @ApiResponse(
code = 406, // code = 406,
message = "Not Acceptable.\n The requested media type is not supported"), // message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " + // message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.", // "list of supported device types.",
response = ErrorResponse.class) // response = ErrorResponse.class)
} // }
) // )
Response deployDeviceTypeEventDefinition( // Response deployDeviceTypeEventDefinition(
@ApiParam(name = "type", value = "The device type, such as android, ios, and windows.") // @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
@PathParam("type")String deviceType, // @PathParam("type")String deviceType,
@ApiParam(name = "skipPersist", value = "Is it required to persist the data or not") // @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
@QueryParam("skipPersist") boolean skipPersist, // @QueryParam("skipPersist") boolean skipPersist,
@ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants") // @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
@QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants, // @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
@ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.", // @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.",
required = true) // required = true)
@Valid DeviceTypeEvent deviceTypeEvent); // @Valid DeviceTypeEvent deviceTypeEvent);
@DELETE @DELETE
@Path("/{type}") @Path("/{type}")
@ -178,183 +178,183 @@ public interface DeviceEventManagementService {
"ios, and windows.", required = false) "ios, and windows.", required = false)
@PathParam("type")String deviceType); @PathParam("type")String deviceType);
@GET // @GET
@Path("/{type}/{deviceId}") // @Path("/{type}/{deviceId}")
@ApiOperation( // @ApiOperation(
produces = MediaType.APPLICATION_JSON, // produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", // httpMethod = "GET",
value = "Getting Device Events", // value = "Getting Device Events",
notes = "Get the events for the device.", // notes = "Get the events for the device.",
tags = "Device Event Management", // tags = "Device Event Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
}) // })
} // }
) // )
@ApiResponses( // @ApiResponses(
value = { // value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK. \n Successfully fetched the event definition.", // message = "OK. \n Successfully fetched the event definition.",
response = EventRecords.class, // response = EventRecords.class,
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "ETag", // name = "ETag",
description = "Entity Tag of the response resource.\n" + // description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = // description =
"Date and time the resource was last modified.\n" + // "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
} // }
), // ),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = // message =
"Bad Request. \n"), // "Bad Request. \n"),
@ApiResponse( // @ApiResponse(
code = 406, // code = 406,
message = "Not Acceptable.\n The requested media type is not supported"), // message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " + // message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.", // "list of supported device types.",
response = ErrorResponse.class) // response = ErrorResponse.class)
} // }
) // )
Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false) // Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
@PathParam("deviceId") String deviceId, // @PathParam("deviceId") String deviceId,
@ApiParam(name = "from", value = "unix timestamp to retrieve", required = false) // @ApiParam(name = "from", value = "unix timestamp to retrieve", required = false)
@QueryParam("from") long from, // @QueryParam("from") long from,
@ApiParam(name = "to", value = "unix time to retrieve", required = false) // @ApiParam(name = "to", value = "unix time to retrieve", required = false)
@QueryParam("to") long to, // @QueryParam("to") long to,
@ApiParam(name = "type", value = "name of the device type", required = false) // @ApiParam(name = "type", value = "name of the device type", required = false)
@PathParam("type") String deviceType, // @PathParam("type") String deviceType,
@ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false) // @ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false)
@QueryParam("offset") int offset, // @QueryParam("offset") int offset,
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) // @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
@QueryParam("limit") int limit); // @QueryParam("limit") int limit);
@GET // @GET
@Path("last-known/{type}/{deviceId}") // @Path("last-known/{type}/{deviceId}")
@ApiOperation( // @ApiOperation(
produces = MediaType.APPLICATION_JSON, // produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", // httpMethod = "GET",
value = "Getting Last Known Device Events", // value = "Getting Last Known Device Events",
notes = "Get the last known events for the device.", // notes = "Get the last known events for the device.",
tags = "Device Event Management", // tags = "Device Event Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
}) // })
} // }
) // )
@ApiResponses( // @ApiResponses(
value = { // value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK. \n Successfully fetched the event.", // message = "OK. \n Successfully fetched the event.",
response = EventRecords.class, // response = EventRecords.class,
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "ETag", // name = "ETag",
description = "Entity Tag of the response resource.\n" + // description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = // description =
"Date and time the resource was last modified.\n" + // "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
} // }
), // ),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = // message =
"Bad Request. \n"), // "Bad Request. \n"),
@ApiResponse( // @ApiResponse(
code = 406, // code = 406,
message = "Not Acceptable.\n The requested media type is not supported"), // message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " + // message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.", // "list of supported device types.",
response = ErrorResponse.class) // response = ErrorResponse.class)
} // }
) // )
Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true) // Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true)
@PathParam("deviceId") String deviceId, // @PathParam("deviceId") String deviceId,
@ApiParam(name = "type", value = "name of the device type", required = true) // @ApiParam(name = "type", value = "name of the device type", required = true)
@PathParam("type") String deviceType, // @PathParam("type") String deviceType,
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false) // @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
@QueryParam("limit") int limit); // @QueryParam("limit") int limit);
@GET // @GET
@Path("filter/{type}/{parameter}") // @Path("filter/{type}/{parameter}")
@ApiOperation( // @ApiOperation(
produces = MediaType.APPLICATION_JSON, // produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", // httpMethod = "GET",
value = "Getting the filtered devices", // value = "Getting the filtered devices",
notes = "Get the list of devices based on the filter parameter", // notes = "Get the list of devices based on the filter parameter",
tags = "Device Event Management", // tags = "Device Event Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
}) // })
} // }
) // )
@ApiResponses( // @ApiResponses(
value = { // value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK. \n Successfully fetched the event.", // message = "OK. \n Successfully fetched the event.",
response = EventRecords.class, // response = EventRecords.class,
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "ETag", // name = "ETag",
description = "Entity Tag of the response resource.\n" + // description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = // description =
"Date and time the resource was last modified.\n" + // "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
} // }
), // ),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = // message =
"Bad Request. \n"), // "Bad Request. \n"),
@ApiResponse( // @ApiResponse(
code = 406, // code = 406,
message = "Not Acceptable.\n The requested media type is not supported"), // message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " + // message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.", // "list of supported device types.",
response = ErrorResponse.class) // response = ErrorResponse.class)
} // }
) // )
Response getFilteredDevices( // Response getFilteredDevices(
@ApiParam(name = "type", value = "name of the device type", required = true) // @ApiParam(name = "type", value = "name of the device type", required = true)
@PathParam("type") String deviceType, // @PathParam("type") String deviceType,
@ApiParam(name = "type", value = "name of the parameter", required = true) // @ApiParam(name = "type", value = "name of the parameter", required = true)
@PathParam("type") String parameter, // @PathParam("type") String parameter,
@ApiParam(name = "limit", value = "minimum value the parameter can have", required = false) // @ApiParam(name = "limit", value = "minimum value the parameter can have", required = false)
@QueryParam("min") double min, // @QueryParam("min") double min,
@ApiParam(name = "max", value = "max value the parameter can have", required = false) // @ApiParam(name = "max", value = "max value the parameter can have", required = false)
@QueryParam("max") double max // @QueryParam("max") double max
); // );
@GET @GET
@Path("/{type}") @Path("/{type}")

View File

@ -97,71 +97,71 @@ public interface GeoLocationBasedService {
/** /**
* Retrieve Analytics for the device type * Retrieve Analytics for the device type
*/ */
@GET // @GET
@Path("stats/{deviceType}/{deviceId}") // @Path("stats/{deviceType}/{deviceId}")
@ApiOperation( // @ApiOperation(
consumes = "application/json", // consumes = "application/json",
produces = "application/json", // produces = "application/json",
httpMethod = "GET", // httpMethod = "GET",
value = "Getting the Location Details of a Device", // value = "Getting the Location Details of a Device",
notes = "Get the location details of a device during a define time period.", // notes = "Get the location details of a device during a define time period.",
response = Response.class, // response = Response.class,
tags = "Geo Service Management", // tags = "Geo Service Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view")
}) // })
} // }
) // )
@ApiResponses(value = { // @ApiResponses(value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK.", // message = "OK.",
response = Response.class, // response = Response.class,
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = "Date and time the resource was last modified.\n" + // description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."), // "Used by caches, or in conditional requests."),
}), // }),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.", // message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class), // response = Response.class),
@ApiResponse( // @ApiResponse(
code = 401, // code = 401,
message = "Unauthorized. \n Unauthorized request."), // message = "Unauthorized. \n Unauthorized request."),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Error on retrieving stats", // message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class) // response = Response.class)
}) // })
Response getGeoDeviceStats( // Response getGeoDeviceStats(
@ApiParam( // @ApiParam(
name = "deviceId", // name = "deviceId",
value = "The device ID.", // value = "The device ID.",
required = true) // required = true)
@PathParam("deviceId") String deviceId, // @PathParam("deviceId") String deviceId,
@ApiParam( // @ApiParam(
name = "device-type", // name = "device-type",
value = "The device type, such as ios, android, or windows.", // value = "The device type, such as ios, android, or windows.",
required = true) // required = true)
@PathParam("deviceType") // @PathParam("deviceType")
@Size(max = 45) // @Size(max = 45)
String deviceType, // String deviceType,
@ApiParam( // @ApiParam(
name = "from", // name = "from",
value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.", // value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
required = true) // required = true)
@QueryParam("from") long from, // @QueryParam("from") long from,
@ApiParam( // @ApiParam(
name = "to", // name = "to",
value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.", // value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
required = true) // required = true)
@QueryParam("to") long to); // @QueryParam("to") long to);
/** /**
* Get data to show device locations in a map * Get data to show device locations in a map
@ -602,128 +602,128 @@ public interface GeoLocationBasedService {
/** /**
* Retrieve Geo alerts history * Retrieve Geo alerts history
*/ */
@GET // @GET
@Path("alerts/history/{deviceType}/{deviceId}") // @Path("alerts/history/{deviceType}/{deviceId}")
@ApiOperation( // @ApiOperation(
consumes = "application/json", // consumes = "application/json",
produces = "application/json", // produces = "application/json",
httpMethod = "GET", // httpMethod = "GET",
value = "Getting the Geo Service Alert History of a Device", // value = "Getting the Geo Service Alert History of a Device",
notes = "Get the geo alert history of a device during the defined time period.", // notes = "Get the geo alert history of a device during the defined time period.",
response = Response.class, // response = Response.class,
tags = "Geo Service Management", // tags = "Geo Service Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
}) // })
} // }
) // )
@ApiResponses(value = { // @ApiResponses(value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK.", // message = "OK.",
response = Response.class, // response = Response.class,
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = "Date and time the resource was last modified.\n" + // description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.") // "Used by caches, or in conditional requests.")
}), // }),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.", // message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class), // response = Response.class),
@ApiResponse( // @ApiResponse(
code = 401, // code = 401,
message = "Unauthorized. \n Unauthorized request."), // message = "Unauthorized. \n Unauthorized request."),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Error on retrieving stats", // message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class) // response = Response.class)
}) // })
Response getGeoAlertsHistory( // Response getGeoAlertsHistory(
@ApiParam( // @ApiParam(
name = "deviceId", // name = "deviceId",
value = "The device ID.", // value = "The device ID.",
required = true) // required = true)
@PathParam("deviceId") String deviceId, // @PathParam("deviceId") String deviceId,
@ApiParam( // @ApiParam(
name = "device-type", // name = "device-type",
value = "The device type, such as ios, android, or windows.", // value = "The device type, such as ios, android, or windows.",
required = true) // required = true)
@PathParam("deviceType") // @PathParam("deviceType")
@Size(max = 45) // @Size(max = 45)
String deviceType, // String deviceType,
@ApiParam( // @ApiParam(
name = "from", // name = "from",
value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.", // value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
required = true) // required = true)
@QueryParam("from") long from, // @QueryParam("from") long from,
@ApiParam( // @ApiParam(
name = "to", // name = "to",
value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.", // value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
required = true) // required = true)
@QueryParam("to") long to); // @QueryParam("to") long to);
/** /**
* Retrieve Geo alerts history for geo clusters * Retrieve Geo alerts history for geo clusters
*/ */
@GET // @GET
@Path("alerts/history") // @Path("alerts/history")
@ApiOperation( // @ApiOperation(
consumes = "application/json", // consumes = "application/json",
produces = "application/json", // produces = "application/json",
httpMethod = "GET", // httpMethod = "GET",
value = "Retrieve Geo alerts history for geo clusters", // value = "Retrieve Geo alerts history for geo clusters",
notes = "Retrieving geo alert history of all defined alerts for geo clusters", // notes = "Retrieving geo alert history of all defined alerts for geo clusters",
response = Response.class, // response = Response.class,
tags = "Geo Service Management", // tags = "Geo Service Management",
extensions = { // extensions = {
@Extension(properties = { // @Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage") // @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
}) // })
} // }
) // )
@ApiResponses(value = { // @ApiResponses(value = {
@ApiResponse( // @ApiResponse(
code = 200, // code = 200,
message = "OK.", // message = "OK.",
response = Response.class, // response = Response.class,
responseHeaders = { // responseHeaders = {
@ResponseHeader( // @ResponseHeader(
name = "Content-Type", // name = "Content-Type",
description = "The content type of the body"), // description = "The content type of the body"),
@ResponseHeader( // @ResponseHeader(
name = "Last-Modified", // name = "Last-Modified",
description = "Date and time the resource was last modified.\n" + // description = "Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests.") // "Used by caches, or in conditional requests.")
}), // }),
@ApiResponse( // @ApiResponse(
code = 400, // code = 400,
message = "Bad Request. \n Invalid Device Identifiers found.", // message = "Bad Request. \n Invalid Device Identifiers found.",
response = Response.class), // response = Response.class),
@ApiResponse( // @ApiResponse(
code = 401, // code = 401,
message = "Unauthorized. \n Unauthorized request."), // message = "Unauthorized. \n Unauthorized request."),
@ApiResponse( // @ApiResponse(
code = 500, // code = 500,
message = "Internal Server Error. \n Error on retrieving stats", // message = "Internal Server Error. \n Error on retrieving stats",
response = Response.class) // response = Response.class)
}) // })
Response getGeoAlertsHistoryForGeoClusters( // Response getGeoAlertsHistoryForGeoClusters(
@ApiParam( // @ApiParam(
name = "from", // name = "from",
value = "Get stats from what time", // value = "Get stats from what time",
required = true) // required = true)
@QueryParam("from") long from, // @QueryParam("from") long from,
@ApiParam( // @ApiParam(
name = "to", // name = "to",
value = "Get stats up to what time", // value = "Get stats up to what time",
required = true) // required = true)
@QueryParam("to") long to); // @QueryParam("to") long to);
/** /**

View File

@ -26,7 +26,7 @@ import org.apache.axis2.AxisFault;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; //import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
@ -280,19 +280,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
i++; i++;
} }
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type // todo: amalka: commented data publishing
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) // if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
, Constants.DEFAULT_STREAM_VERSION, metaData // , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
, null, payloadData)) { // , Constants.DEFAULT_STREAM_VERSION, metaData
// , null, payloadData)) {
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} else { // } else {
String msg = "Error occurred while publishing the event."; // String msg = "Error occurred while publishing the event.";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} // }
} catch (DataPublisherConfigurationException e) { // } catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing the event."; // String msg = "Error occurred while publishing the event.";
log.error(msg, e); // log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceAccessAuthorizationException e) { } catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred when checking for authorization"; String msg = "Error occurred when checking for authorization";
log.error(msg, e); log.error(msg, e);
@ -380,19 +381,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
i++; i++;
} }
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type // todo: amalka: commented data publishing
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()) // if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
, Constants.DEFAULT_STREAM_VERSION, metaData // , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
, null, payloadData)) { // , Constants.DEFAULT_STREAM_VERSION, metaData
// , null, payloadData)) {
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} else { // } else {
String msg = "Error occurred while publishing the event."; // String msg = "Error occurred while publishing the event.";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} // }
} catch (DataPublisherConfigurationException e) { // } catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing the event."; // String msg = "Error occurred while publishing the event.";
log.error(msg, e); // log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceAccessAuthorizationException e) { } catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred when checking for authorization"; String msg = "Error occurred when checking for authorization";
log.error(msg, e); log.error(msg, e);

View File

@ -4,18 +4,18 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Stub; import org.apache.axis2.client.Stub;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; //import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; //import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; //import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField; //import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType; //import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.Record; //import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException; //import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; //import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable; //import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable;
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord; //import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord;
import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
@ -81,49 +81,49 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
private static final String MQTT_CONTENT_VALIDATOR = "default"; private static final String MQTT_CONTENT_VALIDATOR = "default";
private static final String TIMESTAMP_FIELD_NAME = "_timestamp"; private static final String TIMESTAMP_FIELD_NAME = "_timestamp";
private static AnalyticsDataAPI getAnalyticsDataAPI() { // private static AnalyticsDataAPI getAnalyticsDataAPI() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
AnalyticsDataAPI analyticsDataAPI = // AnalyticsDataAPI analyticsDataAPI =
(AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null); // (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
if (analyticsDataAPI == null) { // if (analyticsDataAPI == null) {
String msg = "Analytics api service has not initialized."; // String msg = "Analytics api service has not initialized.";
log.error(msg); // log.error(msg);
throw new IllegalStateException(msg); // throw new IllegalStateException(msg);
} // }
return analyticsDataAPI; // return analyticsDataAPI;
} // }
private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields // private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
, int offset, int limit) throws AnalyticsException { // , int offset, int limit) throws AnalyticsException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); // int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI(); // AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
EventRecords eventRecords = new EventRecords(); // EventRecords eventRecords = new EventRecords();
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query); // int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
if (eventCount == 0) { // if (eventCount == 0) {
eventRecords.setCount(0); // eventRecords.setCount(0);
} // }
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit, // List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
sortByFields); // sortByFields);
List<String> recordIds = getRecordIds(resultEntries); // List<String> recordIds = getRecordIds(resultEntries);
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds); // AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
eventRecords.setCount(eventCount); // eventRecords.setCount(eventCount);
List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response); // List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
records.sort(new Comparator<Record>() { // records.sort(new Comparator<Record>() {
@Override public int compare(Record r1, Record r2) { // @Override public int compare(Record r1, Record r2) {
return Long.compare(r2.getTimestamp(), r1.getTimestamp()); // return Long.compare(r2.getTimestamp(), r1.getTimestamp());
} // }
}); // });
eventRecords.setList(records); // eventRecords.setList(records);
return eventRecords; // return eventRecords;
} // }
private static List<String> getRecordIds(List<SearchResultEntry> searchResults) { // private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
List<String> ids = new ArrayList<>(); // List<String> ids = new ArrayList<>();
for (SearchResultEntry searchResult : searchResults) { // for (SearchResultEntry searchResult : searchResults) {
ids.add(searchResult.getId()); // ids.add(searchResult.getId());
} // }
return ids; // return ids;
} // }
/** /**
* Retrieves the stream definition from das for the given device type. * Retrieves the stream definition from das for the given device type.
@ -195,65 +195,65 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
/** /**
* Deploy Event Stream, Receiver, Publisher and Store Configuration. * Deploy Event Stream, Receiver, Publisher and Store Configuration.
*/ */
@POST // @POST
@Path("/{type}") // @Path("/{type}")
@Override // @Override
public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType, // public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
@QueryParam("skipPersist") boolean skipPersist, // @QueryParam("skipPersist") boolean skipPersist,
@QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants, // @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
@Valid DeviceTypeEvent deviceTypeEvent) { // @Valid DeviceTypeEvent deviceTypeEvent) {
TransportType transportType = deviceTypeEvent.getTransportType(); // TransportType transportType = deviceTypeEvent.getTransportType();
EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList(); // EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); // String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
try { // try {
if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 || // if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
deviceType == null || transportType == null || // deviceType == null || transportType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { // !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid Payload"; // String errorMessage = "Invalid Payload";
log.error(errorMessage); // log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); // return Response.status(Response.Status.BAD_REQUEST).build();
} // }
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain); // String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION; // String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); // publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType); // publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
if (!skipPersist) { // if (!skipPersist) {
publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes); // publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
} // }
publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType); // publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
try { // try {
PrivilegedCarbonContext.startTenantFlow(); // PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( // PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); // MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { // if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes); // publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType); // publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
} // }
} finally { // } finally {
PrivilegedCarbonContext.endTenantFlow(); // PrivilegedCarbonContext.endTenantFlow();
} // }
return Response.ok().build(); // return Response.ok().build();
} catch (AxisFault e) { // } catch (AxisFault e) {
log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e); // log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (RemoteException e) { // } catch (RemoteException e) {
log.error("Failed to connect with the remote services:" + tenantDomain, e); // log.error("Failed to connect with the remote services:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (JWTClientException e) { // } catch (JWTClientException e) {
log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e); // log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (UserStoreException e) { // } catch (UserStoreException e) {
log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e); // log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (DeviceManagementException e) { // } catch (DeviceManagementException e) {
log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e); // log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) { // } catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType, // log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
e); // e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} // }
} // }
/** /**
* Delete device type specific artifacts from DAS. * Delete device type specific artifacts from DAS.
@ -349,175 +349,175 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
/** /**
* Returns device specific data for the give period of time. * Returns device specific data for the give period of time.
*/ */
@GET // @GET
@Path("/{type}/{deviceId}") // @Path("/{type}/{deviceId}")
@Override // @Override
public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, // public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
@QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset") // @QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset")
int offset, @QueryParam("limit") int limit) { // int offset, @QueryParam("limit") int limit) {
if (from == 0 || to == 0) { // if (from == 0 || to == 0) {
String errorMessage = "Invalid values for from/to"; // String errorMessage = "Invalid values for from/to";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); // return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} // }
if (limit == 0) { // if (limit == 0) {
String errorMessage = "Invalid values for offset/limit"; // String errorMessage = "Invalid values for offset/limit";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); // return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} // }
String fromDate = String.valueOf(from); // String fromDate = String.valueOf(from);
String toDate = String.valueOf(to); // String toDate = String.valueOf(to);
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId // String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId
+ " AND _timestamp : [" + fromDate + " TO " + toDate + "]"; // + " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); // String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); // String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
try { // try {
if (deviceType == null || // if (deviceType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { // !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid device type"; // String errorMessage = "Invalid device type";
log.error(errorMessage); // log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); // return Response.status(Response.Status.BAD_REQUEST).build();
} // }
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( // if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType))) { // new DeviceIdentifier(deviceId, deviceType))) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); // return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
} // }
List<SortByField> sortByFields = new ArrayList<>(); // List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); // SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
sortByFields.add(sortByField); // sortByFields.add(sortByField);
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit); // EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit);
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); // return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
} catch (AnalyticsException e) { // } catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) { // } catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage(), e); // log.error(e.getErrorMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (DeviceManagementException e) { // } catch (DeviceManagementException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} // }
} // }
/** /**
* Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point. * Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point.
* Limit parameter needs to be zero or positive. * Limit parameter needs to be zero or positive.
*/ */
@GET // @GET
@Path("/last-known/{type}/{deviceId}") // @Path("/last-known/{type}/{deviceId}")
@Override // @Override
public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) { // public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) {
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId; // String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId;
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); // String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); // String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
try { // try {
if (deviceType == null || // if (deviceType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { // !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid device type"; // String errorMessage = "Invalid device type";
log.error(errorMessage); // log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); // return Response.status(Response.Status.BAD_REQUEST).build();
} // }
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( // if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType))) { // new DeviceIdentifier(deviceId, deviceType))) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); // return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
} // }
List<SortByField> sortByFields = new ArrayList<>(); // List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); // SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
sortByFields.add(sortByField); // sortByFields.add(sortByField);
if (limit == 0) { // if (limit == 0) {
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1); // EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); // return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
} else if (limit > 0) { // } else if (limit > 0) {
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit); // EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build(); // return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
} else { // } else {
String errorMessage = "Invalid limit value"; // String errorMessage = "Invalid limit value";
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); // return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
} // }
} catch (AnalyticsException e) { // } catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) { // } catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage(), e); // log.error(e.getErrorMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (DeviceManagementException e) { // } catch (DeviceManagementException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} // }
} // }
/** /**
* Returns the filterd device list. Devices are filterd using the paramter given and the timestamp of the record. * Returns the filterd device list. Devices are filterd using the paramter given and the timestamp of the record.
* parameter should given as a range. * parameter should given as a range.
*/ */
@GET // @GET
@Path("filter/{type}/{parameter}") // @Path("filter/{type}/{parameter}")
@Override // @Override
public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter, // public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter,
@QueryParam("min") double min, @QueryParam("max") double max) { // @QueryParam("min") double min, @QueryParam("max") double max) {
String query; // String query;
Calendar c = java.util.Calendar.getInstance(); // Calendar c = java.util.Calendar.getInstance();
long currentTimestamp = c.getTimeInMillis(); // long currentTimestamp = c.getTimeInMillis();
long previousTimestamp = currentTimestamp - 300 * 1000; // long previousTimestamp = currentTimestamp - 300 * 1000;
String fromDate = String.valueOf(previousTimestamp); // String fromDate = String.valueOf(previousTimestamp);
String toDate = String.valueOf(currentTimestamp); // String toDate = String.valueOf(currentTimestamp);
if (min != 0 & max != 0) { // if (min != 0 & max != 0) {
query = parameter + " : [" + min + " TO " + max + "]" + // query = parameter + " : [" + min + " TO " + max + "]" +
" AND _timestamp : [" + fromDate + " TO " + toDate + "]"; // " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
} else { // } else {
String errorMessage = "The of range values need to be given"; // String errorMessage = "The of range values need to be given";
log.error(errorMessage); // log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); // return Response.status(Response.Status.BAD_REQUEST).build();
} // }
//
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); // String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain)); // String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
try { // try {
if (deviceType == null || // if (deviceType == null ||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) { // !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
String errorMessage = "Invalid device type"; // String errorMessage = "Invalid device type";
log.error(errorMessage); // log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); // return Response.status(Response.Status.BAD_REQUEST).build();
} // }
//
List<SortByField> sortByFields = new ArrayList<>(); // List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC); // SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
sortByFields.add(sortByField); // sortByFields.add(sortByField);
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100); // EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100);
List<Record> filterdEvents = eventRecords.getRecord(); // List<Record> filterdEvents = eventRecords.getRecord();
List<Record> uniqueFilterdEvents = new ArrayList<Record>(); // List<Record> uniqueFilterdEvents = new ArrayList<Record>();
Set<String> devices = new HashSet<>(); // Set<String> devices = new HashSet<>();
//
for (int i = 0; i < filterdEvents.size(); i++) { // for (int i = 0; i < filterdEvents.size(); i++) {
String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId"); // String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId");
if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( // if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceid, deviceType))) { // new DeviceIdentifier(deviceid, deviceType))) {
devices.add(deviceid); // devices.add(deviceid);
uniqueFilterdEvents.add(filterdEvents.get(i)); // uniqueFilterdEvents.add(filterdEvents.get(i));
} // }
} // }
//
EventRecords filterdRecords = new EventRecords(); // EventRecords filterdRecords = new EventRecords();
filterdRecords.setList(uniqueFilterdEvents); // filterdRecords.setList(uniqueFilterdEvents);
return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build(); // return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build();
//
} catch (AnalyticsException e) { // } catch (AnalyticsException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceManagementException e) { // } catch (DeviceManagementException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
} catch (DeviceAccessAuthorizationException e) { // } catch (DeviceAccessAuthorizationException e) {
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query; // String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
log.error(errorMsg); // log.error(errorMsg);
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); // return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
} // }
} // }
private void publishEventReceivers(String streamNameWithVersion, TransportType transportType private void publishEventReceivers(String streamNameWithVersion, TransportType transportType
@ -613,47 +613,47 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
} }
} }
private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes) // private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
throws RemoteException, UserStoreException, JWTClientException, // throws RemoteException, UserStoreException, JWTClientException,
EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException { // EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub = // EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub(); // DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
try { // try {
AnalyticsTable analyticsTable = new AnalyticsTable(); // AnalyticsTable analyticsTable = new AnalyticsTable();
analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME); // analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
analyticsTable.setStreamVersion(version); // analyticsTable.setStreamVersion(version);
analyticsTable.setTableName(streamName); // analyticsTable.setTableName(streamName);
analyticsTable.setMergeSchema(false); // analyticsTable.setMergeSchema(false);
analyticsTable.setPersist(true); // analyticsTable.setPersist(true);
AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1]; // AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
int i = 0; // int i = 0;
for (Attribute attribute : eventAttributes.getList()) { // for (Attribute attribute : eventAttributes.getList()) {
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord(); // AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
analyticsTableRecord.setColumnName(attribute.getName()); // analyticsTableRecord.setColumnName(attribute.getName());
analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase()); // analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
analyticsTableRecord.setFacet(false); // analyticsTableRecord.setFacet(false);
analyticsTableRecord.setIndexed(false); // analyticsTableRecord.setIndexed(false);
analyticsTableRecord.setPersist(true); // analyticsTableRecord.setPersist(true);
analyticsTableRecord.setPrimaryKey(false); // analyticsTableRecord.setPrimaryKey(false);
analyticsTableRecord.setScoreParam(false); // analyticsTableRecord.setScoreParam(false);
analyticsTableRecords[i] = analyticsTableRecord; // analyticsTableRecords[i] = analyticsTableRecord;
i++; // i++;
} // }
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord(); // AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE); // analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase()); // analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
analyticsTableRecord.setFacet(false); // analyticsTableRecord.setFacet(false);
analyticsTableRecord.setIndexed(true); // analyticsTableRecord.setIndexed(true);
analyticsTableRecord.setPersist(true); // analyticsTableRecord.setPersist(true);
analyticsTableRecord.setPrimaryKey(false); // analyticsTableRecord.setPrimaryKey(false);
analyticsTableRecord.setScoreParam(false); // analyticsTableRecord.setScoreParam(false);
analyticsTableRecords[i] = analyticsTableRecord; // analyticsTableRecords[i] = analyticsTableRecord;
analyticsTable.setAnalyticsTableRecords(analyticsTableRecords); // analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable); // eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
} finally { // } finally {
cleanup(eventStreamPersistenceAdminServiceStub); // cleanup(eventStreamPersistenceAdminServiceStub);
} // }
} // }
private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType) private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType)
throws RemoteException, UserStoreException, JWTClientException { throws RemoteException, UserStoreException, JWTClientException {

View File

@ -25,14 +25,14 @@ import com.google.gson.Gson;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI; //import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; //import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; //import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; //import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
import org.wso2.carbon.analytics.dataservice.commons.SortByField; //import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType; //import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.Record; //import org.wso2.carbon.analytics.datasource.commons.Record;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; //import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@ -93,63 +93,63 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class); private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class);
@Path("stats/{deviceType}/{deviceId}") // @Path("stats/{deviceType}/{deviceId}")
@GET // @GET
@Consumes("application/json") // @Consumes("application/json")
@Produces("application/json") // @Produces("application/json")
public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId, // public Response getGeoDeviceStats(@PathParam("deviceId") String deviceId,
@PathParam("deviceType") String deviceType, // @PathParam("deviceType") String deviceType,
@QueryParam("from") long from, @QueryParam("to") long to) { // @QueryParam("from") long from, @QueryParam("to") long to) {
try { // try {
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { // if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
return Response.status(Response.Status.BAD_REQUEST.getStatusCode()) // return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
.entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build(); // .entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build();
} // }
} catch (DeviceManagementException e) { // } catch (DeviceManagementException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build();
} // }
String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT"; // String tableName = "IOT_PER_DEVICE_STREAM_GEO_FUSEDSPATIALEVENT";
String fromDate = String.valueOf(from); // String fromDate = String.valueOf(from);
String toDate = String.valueOf(to); // String toDate = String.valueOf(to);
String query = "id:" + deviceId + " AND type:" + deviceType; // String query = "id:" + deviceId + " AND type:" + deviceType;
if (from != 0 || to != 0) { // if (from != 0 || to != 0) {
query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]"; // query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
} // }
try { // try {
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( // if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType), // new DeviceIdentifier(deviceId, deviceType),
DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) { // DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); // return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
} // }
List<SortByField> sortByFields = new ArrayList<>(); // List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("timeStamp", SortType.ASC); // SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
sortByFields.add(sortByField); // sortByFields.add(sortByField);
//
// this is the user who initiates the request // // this is the user who initiates the request
String authorizedUser = MultitenantUtils.getTenantAwareUsername( // String authorizedUser = MultitenantUtils.getTenantAwareUsername(
CarbonContext.getThreadLocalCarbonContext().getUsername()); // CarbonContext.getThreadLocalCarbonContext().getUsername());
//
try { // try {
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); // String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); // int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); // AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query, // List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
0, // 0,
100, // 100,
sortByFields); // sortByFields);
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(), // List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
searchResults); // searchResults);
return Response.ok().entity(events).build(); // return Response.ok().entity(null).build();
} catch (AnalyticsException | UserStoreException e) { // } catch (AnalyticsException| UserStoreException e) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); // log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException( // throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); // Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
} // }
} catch (DeviceAccessAuthorizationException e) { // } catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage()); // log.error(e.getErrorMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build(); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
} // }
} // }
@Path("stats/device-locations") @Path("stats/device-locations")
@GET @GET
@ -471,142 +471,142 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
} }
} }
@Path("alerts/history/{deviceType}/{deviceId}") // @Path("alerts/history/{deviceType}/{deviceId}")
@GET // @GET
@Consumes("application/json") // @Consumes("application/json")
@Produces("application/json") // @Produces("application/json")
public Response getGeoAlertsHistory(@PathParam("deviceId") String deviceId, // public Response getGeoAlertsHistory(@PathParam("deviceId") String deviceId,
@PathParam("deviceType") String deviceType, // @PathParam("deviceType") String deviceType,
@QueryParam("from") long from, @QueryParam("to") long to) { // @QueryParam("from") long from, @QueryParam("to") long to) {
String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS"; // String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS";
String fromDate = String.valueOf(from); // String fromDate = String.valueOf(from);
String toDate = String.valueOf(to); // String toDate = String.valueOf(to);
String query = "id:" + deviceId + " AND type:" + deviceType; // String query = "id:" + deviceId + " AND type:" + deviceType;
if (from != 0 || to != 0) { // if (from != 0 || to != 0) {
query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]"; // query += " AND timeStamp : [" + fromDate + " TO " + toDate + "]";
} // }
try { // try {
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized( // if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(deviceId, deviceType), // new DeviceIdentifier(deviceId, deviceType),
DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) { // DeviceGroupConstants.Permissions.DEFAULT_STATS_MONITOR_PERMISSIONS)) {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); // return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
} // }
List<SortByField> sortByFields = new ArrayList<>(); // List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("timeStamp", SortType.ASC); // SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
sortByFields.add(sortByField); // sortByFields.add(sortByField);
//
// // this is the user who initiates the request
// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
// CarbonContext.getThreadLocalCarbonContext().getUsername());
//
// try {
// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
// List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
// 0,
// 100,
// sortByFields);
// List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
// searchResults);
// return Response.ok().entity(events).build();
// } catch (AnalyticsException | UserStoreException e) {
// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
// throw DeviceMgtUtil.buildBadRequestException(
// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
// }
// } catch (DeviceAccessAuthorizationException e) {
// log.error(e.getErrorMessage());
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
// }
// }
// this is the user who initiates the request // @Path("alerts/history")
String authorizedUser = MultitenantUtils.getTenantAwareUsername( // @GET
CarbonContext.getThreadLocalCarbonContext().getUsername()); // @Consumes("application/json")
// @Produces("application/json")
// public Response getGeoAlertsHistoryForGeoClusters(@QueryParam("from") long from, @QueryParam("to") long to) {
// String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS";
// String fromDate = String.valueOf(from);
// String toDate = String.valueOf(to);
// String query = "";
// if (from != 0 || to != 0) {
// query = "timeStamp : [" + fromDate + " TO " + toDate + "]";
// }
// try {
// List<SortByField> sortByFields = new ArrayList<>();
// SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
// sortByFields.add(sortByField);
//
// // this is the user who initiates the request
// String authorizedUser = MultitenantUtils.getTenantAwareUsername(
// CarbonContext.getThreadLocalCarbonContext().getUsername());
//
// String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser);
// int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain);
// AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI();
// List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query,
// 0,
// 100,
// sortByFields);
// List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(),
// searchResults);
// return Response.ok().entity(events).build();
//
// } catch (AnalyticsException | UserStoreException e) {
// log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
// throw DeviceMgtUtil.buildBadRequestException(
// Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
// }
// }
try { // private List<Event> getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName,
String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); // List<String> columns,
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); // List<SearchResultEntry> searchResults) throws AnalyticsException {
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); // List<String> ids = getIds(searchResults);
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query, // List<String> requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
0, // AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
100, // List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
sortByFields); // Map<String, Event> eventBeanMap = getEventBeanKeyedWithIds(records);
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(), // return getSortedEventBeans(eventBeanMap, searchResults);
searchResults); // }
return Response.ok().entity(events).build();
} catch (AnalyticsException | UserStoreException e) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e);
throw DeviceMgtUtil.buildBadRequestException(
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT);
}
} catch (DeviceAccessAuthorizationException e) {
log.error(e.getErrorMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
}
}
@Path("alerts/history") // private List<Event> getSortedEventBeans(Map<String, Event> eventBeanMap,
@GET // List<SearchResultEntry> searchResults) {
@Consumes("application/json") // List<Event> sortedRecords = new ArrayList<>();
@Produces("application/json") // for (SearchResultEntry entry : searchResults) {
public Response getGeoAlertsHistoryForGeoClusters(@QueryParam("from") long from, @QueryParam("to") long to) { // sortedRecords.add(eventBeanMap.get(entry.getId()));
String tableName = "IOT_PER_DEVICE_STREAM_GEO_ALERTNOTIFICATIONS"; // }
String fromDate = String.valueOf(from); // return sortedRecords;
String toDate = String.valueOf(to); // }
String query = "";
if (from != 0 || to != 0) {
query = "timeStamp : [" + fromDate + " TO " + toDate + "]";
}
try {
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("timeStamp", SortType.ASC);
sortByFields.add(sortByField);
// this is the user who initiates the request // private Map<String, Event> getEventBeanKeyedWithIds(List<Record> records) {
String authorizedUser = MultitenantUtils.getTenantAwareUsername( // Map<String, Event> eventBeanMap = new HashMap<>();
CarbonContext.getThreadLocalCarbonContext().getUsername()); // for (Record record : records) {
// Event event = getEventBean(record);
// eventBeanMap.put(event.getId(), event);
// }
// return eventBeanMap;
// }
String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); // private List<String> getIds(List<SearchResultEntry> searchResults) {
int tenantId = DeviceMgtAPIUtils.getRealmService().getTenantManager().getTenantId(tenantDomain); // List<String> ids = new ArrayList<>();
AnalyticsDataAPI analyticsDataAPI = DeviceMgtAPIUtils.getAnalyticsDataAPI(); // if (searchResults != null) {
List<SearchResultEntry> searchResults = analyticsDataAPI.search(tenantId, tableName, query, // for (SearchResultEntry resultEntry : searchResults) {
0, // ids.add(resultEntry.getId());
100, // }
sortByFields); // }
List<Event> events = getEventBeans(analyticsDataAPI, tenantId, tableName, new ArrayList<String>(), // return ids;
searchResults); // }
return Response.ok().entity(events).build();
} catch (AnalyticsException | UserStoreException e) { // private static Event getEventBean(Record record) {
log.error("Failed to perform search on table: " + tableName + " : " + e.getMessage(), e); // Event eventBean = new Event();
throw DeviceMgtUtil.buildBadRequestException( // eventBean.setId(record.getId());
Constants.ErrorMessages.STATUS_BAD_REQUEST_MESSAGE_DEFAULT); // eventBean.setTableName(record.getTableName());
} // eventBean.setTimestamp(record.getTimestamp());
} // eventBean.setValues(record.getValues());
// return eventBean;
private List<Event> getEventBeans(AnalyticsDataAPI analyticsDataAPI, int tenantId, String tableName, // }
List<String> columns,
List<SearchResultEntry> searchResults) throws AnalyticsException {
List<String> ids = getIds(searchResults);
List<String> requiredColumns = (columns == null || columns.isEmpty()) ? null : columns;
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, requiredColumns, ids);
List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
Map<String, Event> eventBeanMap = getEventBeanKeyedWithIds(records);
return getSortedEventBeans(eventBeanMap, searchResults);
}
private List<Event> getSortedEventBeans(Map<String, Event> eventBeanMap,
List<SearchResultEntry> searchResults) {
List<Event> sortedRecords = new ArrayList<>();
for (SearchResultEntry entry : searchResults) {
sortedRecords.add(eventBeanMap.get(entry.getId()));
}
return sortedRecords;
}
private Map<String, Event> getEventBeanKeyedWithIds(List<Record> records) {
Map<String, Event> eventBeanMap = new HashMap<>();
for (Record record : records) {
Event event = getEventBean(record);
eventBeanMap.put(event.getId(), event);
}
return eventBeanMap;
}
private List<String> getIds(List<SearchResultEntry> searchResults) {
List<String> ids = new ArrayList<>();
if (searchResults != null) {
for (SearchResultEntry resultEntry : searchResults) {
ids.add(resultEntry.getId());
}
}
return ids;
}
private static Event getEventBean(Record record) {
Event eventBean = new Event();
eventBean.setId(record.getId());
eventBean.setTableName(record.getTableName());
eventBean.setTimestamp(record.getTimestamp());
eventBean.setValues(record.getValues());
return eventBean;
}
@Path("/geo-fence") @Path("/geo-fence")
@POST @POST

View File

@ -64,8 +64,9 @@ public class CredentialManagementResponseBuilder {
username = CarbonContext.getThreadLocalCarbonContext().getUsername(); username = CarbonContext.getThreadLocalCarbonContext().getUsername();
userStoreManager.updateCredential(username, credentials.getNewPassword(), userStoreManager.updateCredential(username, credentials.getNewPassword(),
credentials.getOldPassword()); credentials.getOldPassword());
DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, //todo:amalka
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); // DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
return Response.status(Response.Status.OK).entity("UserImpl password by username: " + return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
username + " was successfully changed.").build(); username + " was successfully changed.").build();
} catch (UserStoreException e) { } catch (UserStoreException e) {
@ -108,8 +109,9 @@ public class CredentialManagementResponseBuilder {
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build();
} }
userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword()); userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword());
DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username, //todo:amalka
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); // DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
return Response.status(Response.Status.OK).entity("UserImpl password by username: " + return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
username + " was successfully changed.").build(); username + " was successfully changed.").build();
} catch (UserStoreException e) { } catch (UserStoreException e) {

View File

@ -46,14 +46,14 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; //import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI; import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.core.util.Utils;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; //import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
@ -171,7 +171,7 @@ public class DeviceMgtAPIUtils {
private static KeyStore trustStore; private static KeyStore trustStore;
private static char[] keyStorePassword; private static char[] keyStorePassword;
private static IntegrationClientService integrationClientService; // private static IntegrationClientService integrationClientService;
private static MetadataManagementService metadataManagementService; private static MetadataManagementService metadataManagementService;
private static OTPManagementService otpManagementService; private static OTPManagementService otpManagementService;
@ -374,22 +374,22 @@ public class DeviceMgtAPIUtils {
} }
public static IntegrationClientService getIntegrationClientService() { // public static IntegrationClientService getIntegrationClientService() {
if (integrationClientService == null) { // if (integrationClientService == null) {
synchronized (DeviceMgtAPIUtils.class) { // synchronized (DeviceMgtAPIUtils.class) {
if (integrationClientService == null) { // if (integrationClientService == null) {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null); // integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null);
if (integrationClientService == null) { // if (integrationClientService == null) {
String msg = "IntegrationClientService is not initialized"; // String msg = "IntegrationClientService is not initialized";
log.error(msg); // log.error(msg);
throw new IllegalStateException(msg); // throw new IllegalStateException(msg);
} // }
} // }
} // }
} // }
return integrationClientService; // return integrationClientService;
} // }
/** /**
* Initializing and accessing method for OTPManagementService. * Initializing and accessing method for OTPManagementService.
@ -626,17 +626,18 @@ public class DeviceMgtAPIUtils {
return username; return username;
} }
public static EventsPublisherService getEventPublisherService() { // todo: amalka: commented
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // public static EventsPublisherService getEventPublisherService() {
EventsPublisherService eventsPublisherService = // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
(EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); // EventsPublisherService eventsPublisherService =
if (eventsPublisherService == null) { // (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
String msg = "Event Publisher service has not initialized."; // if (eventsPublisherService == null) {
log.error(msg); // String msg = "Event Publisher service has not initialized.";
throw new IllegalStateException(msg); // log.error(msg);
} // throw new IllegalStateException(msg);
return eventsPublisherService; // }
} // return eventsPublisherService;
// }
public static String getStreamDefinition(String deviceType, String tenantDomain) { public static String getStreamDefinition(String deviceType, String tenantDomain) {
return STREAM_DEFINITION_PREFIX + tenantDomain + "." + deviceType.replace(" ", "."); return STREAM_DEFINITION_PREFIX + tenantDomain + "." + deviceType.replace(" ", ".");

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -50,7 +50,7 @@
<Import-Package> <Import-Package>
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
com.fasterxml.jackson.annotation;version="${jackson-annotations.version}", com.fasterxml.jackson.annotation;version="${jackson-annotations.version}",
org.wso2.carbon.analytics.datasource.commons;version="${carbon.analytics.version.range}", <!--org.wso2.carbon.analytics.datasource.commons;version="${carbon.analytics.version.range}",-->
io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional, io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional,
com.google.gson com.google.gson
</Import-Package> </Import-Package>
@ -96,14 +96,14 @@
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId> <groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics</groupId> <!--<groupId>org.wso2.carbon.analytics</groupId>-->
<artifactId>org.wso2.carbon.analytics.api</artifactId> <!--<artifactId>org.wso2.carbon.analytics.api</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics</groupId> <!--<groupId>org.wso2.carbon.analytics</groupId>-->
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId> <!--<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>

View File

@ -78,8 +78,8 @@
<Private-Package>org.wso2.carbon.device.mgt.core.internal</Private-Package> <Private-Package>org.wso2.carbon.device.mgt.core.internal</Private-Package>
<Import-Package> <Import-Package>
org.apache.axis2.*;version="${axis2.osgi.version.range}", org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.naming, javax.naming,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
@ -90,7 +90,7 @@
org.wso2.carbon.core, org.wso2.carbon.core,
org.wso2.carbon.utils.*, org.wso2.carbon.utils.*,
org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.analytics.data.publisher.service, <!--org.wso2.carbon.device.mgt.analytics.data.publisher.service,-->
org.wso2.carbon.user.api, org.wso2.carbon.user.api,
org.wso2.carbon.user.core.*, org.wso2.carbon.user.core.*,
org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.core.service,
@ -104,8 +104,8 @@
org.wso2.carbon.ndatasource.core, org.wso2.carbon.ndatasource.core,
org.wso2.carbon.ntask.core.*, org.wso2.carbon.ntask.core.*,
org.wso2.carbon.ntask.common, org.wso2.carbon.ntask.common,
org.apache.catalina, <!--org.apache.catalina,-->
org.apache.catalina.core, <!--org.apache.catalina.core,-->
org.apache.commons.collections;version="${commons-collections.version.range}", org.apache.commons.collections;version="${commons-collections.version.range}",
org.wso2.carbon.email.sender.*, org.wso2.carbon.email.sender.*,
io.swagger.annotations.*;resolution:=optional, io.swagger.annotations.*;resolution:=optional,
@ -166,32 +166,32 @@
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId> <!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
<exclusions> <!--<exclusions>-->
<exclusion> <!--<exclusion>-->
<groupId>org.slf4j</groupId> <!--<groupId>org.slf4j</groupId>-->
<artifactId>slf4j-api</artifactId> <!--<artifactId>slf4j-api</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>javax.servlet</groupId> <!--<groupId>javax.servlet</groupId>-->
<artifactId>javax.servlet-api</artifactId> <!--<artifactId>javax.servlet-api</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>org.wso2.carbon.registry</groupId> <!--<groupId>org.wso2.carbon.registry</groupId>-->
<artifactId>org.wso2.carbon.registry.indexing</artifactId> <!--<artifactId>org.wso2.carbon.registry.indexing</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>org.wso2.carbon.identity.framework</groupId> <!--<groupId>org.wso2.carbon.identity.framework</groupId>-->
<artifactId>org.wso2.carbon.user.mgt</artifactId> <!--<artifactId>org.wso2.carbon.user.mgt</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>commons-lang</groupId> <!--<groupId>commons-lang</groupId>-->
<artifactId>commons-lang</artifactId> <!--<artifactId>commons-lang</artifactId>-->
</exclusion> <!--</exclusion>-->
</exclusions> <!--</exclusions>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>

View File

@ -53,6 +53,8 @@ public final class DeviceManagementConstants {
public static final String SCOPES_FOR_TOKEN = "perm:device:operations perm:device:publish-event perm:windows:enroll"; public static final String SCOPES_FOR_TOKEN = "perm:device:operations perm:device:publish-event perm:windows:enroll";
public static final String IOT_GATEWAY_HOST = "iot.gateway.host"; public static final String IOT_GATEWAY_HOST = "iot.gateway.host";
public static final String IOT_GATEWAY_HTTPS_PORT = "iot.gateway.https.port"; public static final String IOT_GATEWAY_HTTPS_PORT = "iot.gateway.https.port";
public static final String IOT_CORE_HOST = "iot.core.host";
public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port";
public static final String APPLICATION_REGISTRATION_API_ENDPOINT = public static final String APPLICATION_REGISTRATION_API_ENDPOINT =
"/api-application-registration/register"; "/api-application-registration/register";
public static final String AUTHORIZATION_HEADER = "authorization"; public static final String AUTHORIZATION_HEADER = "authorization";

View File

@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; //import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
@ -178,9 +178,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceInfo.getAvailableRAMMemory(), deviceInfo.getAvailableRAMMemory(),
deviceInfo.isPluggedIn() deviceInfo.isPluggedIn()
}; };
DeviceManagerUtil.getEventPublisherService().publishEvent( // DeviceManagerUtil.getEventPublisherService().publishEvent(
DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
); // );
} }
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new DeviceDetailsMgtException("Transactional error occurred while adding the device information.", e); throw new DeviceDetailsMgtException("Transactional error occurred while adding the device information.", e);
@ -193,8 +193,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while updating the last update timestamp of the " + throw new DeviceDetailsMgtException("Error occurred while updating the last update timestamp of the " +
"device", e); "device", e);
} catch (DataPublisherConfigurationException e) { // } catch (DataPublisherConfigurationException e) {
throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); // throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
@ -389,9 +389,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
deviceLocation.getBearing(), deviceLocation.getBearing(),
deviceLocation.getDistance() deviceLocation.getDistance()
}; };
DeviceManagerUtil.getEventPublisherService().publishEvent( // DeviceManagerUtil.getEventPublisherService().publishEvent(
LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
); // );
} }
DeviceManagementDAOFactory.commitTransaction(); DeviceManagementDAOFactory.commitTransaction();
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
@ -403,9 +403,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while getting the device information.", e); throw new DeviceDetailsMgtException("Error occurred while getting the device information.", e);
} catch (DataPublisherConfigurationException e) { // } catch (DataPublisherConfigurationException e) {
DeviceManagementDAOFactory.rollbackTransaction(); // DeviceManagementDAOFactory.rollbackTransaction();
throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e); // throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }

View File

@ -49,7 +49,7 @@ import org.apache.http.protocol.HTTP;
import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; //import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.ActivityPaginationRequest; import org.wso2.carbon.device.mgt.common.ActivityPaginationRequest;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceEnrollmentInfoNotification; import org.wso2.carbon.device.mgt.common.DeviceEnrollmentInfoNotification;
@ -1964,20 +1964,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
operation.getStatus() != null ? operation.getStatus().toString() : null, operation.getStatus() != null ? operation.getStatus().toString() : null,
operation.getOperationResponse() operation.getOperationResponse()
}; };
DeviceManagerUtil.getEventPublisherService().publishEvent( // DeviceManagerUtil.getEventPublisherService().publishEvent(
OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
); // );
} }
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while reading configs."; String msg = "Error occurred while reading configs.";
log.error(msg, e); log.error(msg, e);
throw new OperationManagementException(msg, e); throw new OperationManagementException(msg, e);
} catch (DataPublisherConfigurationException e) { } //catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing event."; // String msg = "Error occurred while publishing event.";
log.error(msg, e); // log.error(msg, e);
throw new OperationManagementException(msg, e); // throw new OperationManagementException(msg, e);
} // }
} }
@Override @Override
@ -2006,20 +2006,20 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
operation.getStatus() != null ? operation.getStatus().toString() : null, operation.getStatus() != null ? operation.getStatus().toString() : null,
operation.getOperationResponse() operation.getOperationResponse()
}; };
DeviceManagerUtil.getEventPublisherService().publishEvent( // DeviceManagerUtil.getEventPublisherService().publishEvent(
OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload // OPERATION_RESPONSE_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
); // );
} }
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while reading configs."; String msg = "Error occurred while reading configs.";
log.error(msg, e); log.error(msg, e);
throw new OperationManagementException(msg, e); throw new OperationManagementException(msg, e);
} catch (DataPublisherConfigurationException e) { } //catch (DataPublisherConfigurationException e) {
String msg = "Error occurred while publishing event."; // String msg = "Error occurred while publishing event.";
log.error(msg, e); // log.error(msg, e);
throw new OperationManagementException(msg, e); // throw new OperationManagementException(msg, e);
} // }
} }
@Override @Override

View File

@ -50,7 +50,7 @@ import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.caching.impl.CacheImpl; import org.wso2.carbon.caching.impl.CacheImpl;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; //import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials;
import org.wso2.carbon.device.mgt.common.ApplicationRegistration; import org.wso2.carbon.device.mgt.common.ApplicationRegistration;
import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException;
@ -595,17 +595,17 @@ public final class DeviceManagerUtil {
return Caching.getCacheManagerFactory().getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER); return Caching.getCacheManagerFactory().getCacheManager(DeviceManagementConstants.DM_CACHE_MANAGER);
} }
public static EventsPublisherService getEventPublisherService() { // public static EventsPublisherService getEventPublisherService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
EventsPublisherService eventsPublisherService = // EventsPublisherService eventsPublisherService =
(EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null); // (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
if (eventsPublisherService == null) { // if (eventsPublisherService == null) {
String msg = "Event Publisher service has not initialized."; // String msg = "Event Publisher service has not initialized.";
log.error(msg); // log.error(msg);
throw new IllegalStateException(msg); // throw new IllegalStateException(msg);
} // }
return eventsPublisherService; // return eventsPublisherService;
} // }
/** /**
* Retrieve EventConfigurationProviderService osgi service component * Retrieve EventConfigurationProviderService osgi service component

View File

@ -178,15 +178,15 @@
javax.xml.stream, javax.xml.stream,
javax.xml.parsers;resolution:=optional, javax.xml.parsers;resolution:=optional,
org.apache.commons.lang, org.apache.commons.lang,
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.w3c.dom, org.w3c.dom,
org.wso2.carbon.ndatasource.core, org.wso2.carbon.ndatasource.core,
org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.core.service,
org.wso2.carbon.utils.dbcreator, org.wso2.carbon.utils.dbcreator,
org.wso2.carbon.utils.multitenancy, org.wso2.carbon.utils.multitenancy,
org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.device.mgt.core.service,
com.google.gson, com.google.gson
org.osgi.framework
</Import-Package> </Import-Package>
<DynamicImport-Package>org.wso2.carbon.device.mgt.extensions.pull.notification, <DynamicImport-Package>org.wso2.carbon.device.mgt.extensions.pull.notification,
org.wso2.carbon.device.mgt.extensions.pull.notification.*</DynamicImport-Package> org.wso2.carbon.device.mgt.extensions.pull.notification.*</DynamicImport-Package>

View File

@ -61,8 +61,8 @@
<Bundle-Description>IoT Server Impl Bundle</Bundle-Description> <Bundle-Description>IoT Server Impl Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.url.printer.internal</Private-Package> <Private-Package>org.wso2.carbon.device.mgt.url.printer.internal</Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
org.apache.axis2.*;version="${axis2.osgi.version.range}", org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.wso2.carbon.core, org.wso2.carbon.core,

View File

@ -38,9 +38,9 @@
<module>org.wso2.carbon.device.mgt.extensions</module> <module>org.wso2.carbon.device.mgt.extensions</module>
<module>org.wso2.carbon.device.mgt.ui</module> <module>org.wso2.carbon.device.mgt.ui</module>
<module>org.wso2.carbon.device.mgt.api</module> <module>org.wso2.carbon.device.mgt.api</module>
<module>org.wso2.carbon.device.mgt.analytics.data.publisher</module> <!--<module>org.wso2.carbon.device.mgt.analytics.data.publisher</module>-->
<module>org.wso2.carbon.device.mgt.url.printer</module> <module>org.wso2.carbon.device.mgt.url.printer</module>
<module>org.wso2.carbon.device.mgt.analytics.wsproxy</module> <!--<module>org.wso2.carbon.device.mgt.analytics.wsproxy</module>-->
<module>io.entgra.carbon.device.mgt.config.api</module> <module>io.entgra.carbon.device.mgt.config.api</module>
</modules> </modules>

View File

@ -53,20 +53,20 @@
<Import-Package> <Import-Package>
org.apache.axis2.*;version="${axis2.osgi.version.range}", org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.apache.axiom.*; version="${axiom.osgi.version.range}", org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.utils.*, org.wso2.carbon.utils.*,
org.wso2.carbon.ndatasource.core, org.wso2.carbon.ndatasource.core,
org.w3c.dom, org.w3c.dom,
org.apache.velocity;version="${velocity.version}", <!--org.apache.velocity;version="${velocity.version}",-->
org.apache.velocity.app;version="${velocity.version}", <!--org.apache.velocity.app;version="${velocity.version}",-->
org.apache.velocity.context;version="${velocity.version}", <!--org.apache.velocity.context;version="${velocity.version}",-->
org.apache.velocity.exception;version="${velocity.version}", <!--org.apache.velocity.exception;version="${velocity.version}",-->
org.apache.velocity.runtime.resource;version="${velocity.version}", <!--org.apache.velocity.runtime.resource;version="${velocity.version}",-->
org.apache.velocity.runtime.resource.loader;version="${velocity.version}", <!--org.apache.velocity.runtime.resource.loader;version="${velocity.version}",-->
org.apache.commons.io, org.apache.commons.io,
org.apache.axis2.transport.mail, org.apache.axis2.transport.mail,
org.apache.commons.collections, org.apache.commons.collections,
@ -149,10 +149,14 @@
<groupId>org.apache.axis2.wso2</groupId> <groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId> <artifactId>axis2</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.orbit.org.apache.velocity</groupId> <!--<groupId>org.wso2.orbit.org.apache.velocity</groupId>-->
<artifactId>velocity</artifactId> <!--<artifactId>velocity</artifactId>-->
</dependency> <!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.velocity</groupId>-->
<!--<artifactId>velocity</artifactId>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>commons-io.wso2</groupId> <groupId>commons-io.wso2</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>

View File

@ -87,10 +87,11 @@
org.wso2.carbon.device.mgt.oauth.extensions.* org.wso2.carbon.device.mgt.oauth.extensions.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}", <!--org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}",-->
org.apache.commons.lang, org.apache.commons.lang,
org.apache.commons.logging, org.apache.commons.logging,
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}",
org.wso2.carbon.identity.application.common;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.common;version="${carbon.identity.framework.version.range}",
org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.version.range}", org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.version.range}",
@ -113,6 +114,10 @@
org.apache.oltu.oauth2.common.validators, org.apache.oltu.oauth2.common.validators,
org.apache.commons.lang3.tuple, org.apache.commons.lang3.tuple,
</Import-Package> </Import-Package>
<!--<Embed-Dependency>-->
<!--</Embed-Dependency>-->
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator; import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator;
import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse; import org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
@ -58,8 +57,8 @@ public class AccessTokenGrantHandler extends AbstractAuthorizationGrantHandler {
} }
@Override @Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); return super.validateScope(tokReqMsgCtx);
} }
@Override @Override

View File

@ -20,14 +20,10 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler; import org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler;
import org.wso2.carbon.identity.oauth2.model.RequestParameter; import org.wso2.carbon.identity.oauth2.model.RequestParameter;
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
/** /**
* This sets up user with tenant aware username. * This sets up user with tenant aware username.
@ -38,8 +34,8 @@ public class ExtendedJWTGrantHandler extends JWTBearerGrantHandler {
private static final String TENANT_DOMAIN_KEY = "tenantDomain"; private static final String TENANT_DOMAIN_KEY = "tenantDomain";
@Override @Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); return super.validateScope(tokReqMsgCtx);
} }
@Override @Override

View File

@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.keymgt.ScopesIssuer;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext; import org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext;
@ -35,8 +34,8 @@ public class ExtendedSAML2BearerGrantHandler extends SAML2BearerGrantHandler {
private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class); private static Log log = LogFactory.getLog(ExtendedSAML2BearerGrantHandler.class);
@Override @Override
public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) { public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx) throws IdentityOAuth2Exception {
return ScopesIssuer.getInstance().setScopes(tokReqMsgCtx); return super.validateScope(tokReqMsgCtx);
} }
@Override @Override

View File

@ -109,8 +109,8 @@
org.apache.commons.httpclient, org.apache.commons.httpclient,
org.apache.commons.logging, org.apache.commons.logging,
org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}",
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.core.security, org.wso2.carbon.core.security,
org.wso2.carbon.core.services.authentication, org.wso2.carbon.core.services.authentication,
org.wso2.carbon.utils.multitenancy, org.wso2.carbon.utils.multitenancy,

View File

@ -185,8 +185,8 @@
org.wso2.carbon.identity.jwt.client.extension.* org.wso2.carbon.identity.jwt.client.extension.*
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.registry.core, org.wso2.carbon.registry.core,
org.wso2.carbon.registry.core.exceptions, org.wso2.carbon.registry.core.exceptions,

View File

@ -33,8 +33,8 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.identity.authenticator.backend.oauth</module> <!--<module>org.wso2.carbon.identity.authenticator.backend.oauth</module>-->
<module>org.wso2.carbon.device.mgt.oauth.extensions</module> <!--<module>org.wso2.carbon.device.mgt.oauth.extensions</module>-->
<module>org.wso2.carbon.identity.jwt.client.extension</module> <module>org.wso2.carbon.identity.jwt.client.extension</module>
</modules> </modules>

View File

@ -35,9 +35,9 @@
<Bundle-Description>Policy Decision Point Bundle</Bundle-Description> <Bundle-Description>Policy Decision Point Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.decision.point.internal</Private-Package> <Private-Package>org.wso2.carbon.policy.decision.point.internal</Private-Package>
<Import-Package> <Import-Package>
org.wso2.carbon.context.*; org.wso2.carbon.context;version="${carbon.kernel.version.range}",
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
org.wso2.carbon.policy.mgt.common.*, org.wso2.carbon.policy.mgt.common.*,
org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.policy.mgt.core.*,

View File

@ -53,8 +53,8 @@
<Bundle-Description>Policy Management Core Bundle</Bundle-Description> <Bundle-Description>Policy Management Core Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.mgt.core.internal</Private-Package> <Private-Package>org.wso2.carbon.policy.mgt.core.internal</Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.sql, javax.sql,
javax.cache, javax.cache,

View File

@ -39,7 +39,7 @@
<module>org.wso2.carbon.policy.mgt.core</module> <module>org.wso2.carbon.policy.mgt.core</module>
<module>org.wso2.carbon.policy.information.point</module> <module>org.wso2.carbon.policy.information.point</module>
<module>org.wso2.carbon.policy.decision.point</module> <module>org.wso2.carbon.policy.decision.point</module>
<module>org.wso2.carbon.complex.policy.decision.point</module> <!--<module>org.wso2.carbon.complex.policy.decision.point</module>-->
</modules> </modules>
<build> <build>

View File

@ -53,8 +53,8 @@
<Import-Package> <Import-Package>
org.apache.axis2.*;version="${axis2.osgi.version.range}", org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.apache.axiom.*; version="${axiom.osgi.version.range}", org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.osgi.framework, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.service.component, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.apache.commons.logging, org.apache.commons.logging,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
org.wso2.carbon.context, org.wso2.carbon.context,

View File

@ -87,20 +87,30 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.springframework</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>spring-web</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>CXF,Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -99,20 +99,35 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId> <artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId> <artifactId>cxf-bundle-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxws</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.apache.cxf</groupId>-->
<!--<artifactId>cxf-rt-transports-http</artifactId>-->
<!--<scope>provided</scope>-->
<!--</dependency>-->
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>

View File

@ -73,6 +73,7 @@ public class InvokerHandler extends HttpServlet {
private static final long serialVersionUID = -6508020875358160165L; private static final long serialVersionUID = -6508020875358160165L;
private static AuthData authData; private static AuthData authData;
private static String apiEndpoint; private static String apiEndpoint;
private static String iotsCoreUrl;
@Override @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) { protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
@ -368,8 +369,14 @@ public class InvokerHandler extends HttpServlet {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("refreshing the token"); log.debug("refreshing the token");
} }
String iotsCorePort = System.getProperty("iot.core.https.port");
if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) {
iotsCorePort = System.getProperty("iot.core.http.port");
}
iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + iotsCorePort;
HttpPost tokenEndpoint = new HttpPost( HttpPost tokenEndpoint = new HttpPost(
apiEndpoint + HandlerConstants.API_COMMON_CONTEXT + HandlerConstants.TOKEN_ENDPOINT); iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT);
HttpSession session = req.getSession(false); HttpSession session = req.getSession(false);
if (session == null) { if (session == null) {
log.error("Couldn't find a session, hence it is required to login and proceed."); log.error("Couldn't find a session, hence it is required to login and proceed.");

View File

@ -35,7 +35,16 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl;
import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.authenticator.stub.AuthenticationAdmin;
import org.wso2.carbon.authenticator.stub.Login;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import io.entgra.ui.request.interceptor.beans.ProxyResponse; import io.entgra.ui.request.interceptor.beans.ProxyResponse;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
@ -44,7 +53,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.List;
@MultipartConfig @MultipartConfig
@WebServlet("/login") @WebServlet("/login")
@ -56,6 +67,7 @@ public class LoginHandler extends HttpServlet {
private static String password; private static String password;
private static String gatewayUrl; private static String gatewayUrl;
private static String uiConfigUrl; private static String uiConfigUrl;
private static String keyManagerUrl;
@Override @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) { protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
@ -68,26 +80,37 @@ public class LoginHandler extends HttpServlet {
httpSession = req.getSession(true); httpSession = req.getSession(true);
//setting session to expiry in 5 minutes //setting session to expiry in 5 minutes
httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT)); httpSession.setMaxInactiveInterval(Math.toIntExact(HandlerConstants.TIMEOUT));
//todo: amalka do we need this remote call?
JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp);
JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray();
JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray();
HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); List<String> list = new ArrayList<String>();
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() for(int i=0; i < tags.size(); i++) {
.encodeToString((username + HandlerConstants.COLON + password).getBytes())); list.add(tags.get(i).getAsString());
apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password));
ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint);
if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) {
HandlerUtil.handleError(resp, clientAppResponse);
return;
} }
if (clientAppResponse.getCode() == HttpStatus.SC_CREATED && getTokenAndPersistInSession(req, resp,
clientAppResponse.getData(), scopes)) { String[] tagsAsStringArray = list.toArray(new String[list.size()]);
String scopeString = HandlerUtil.getScopeString(scopes);
if (scopeString != null) {
scopeString = scopeString.trim();
} else {
scopeString = "default";
}
APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl();
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
HandlerConstants.PUBLISHER_APPLICATION_NAME,
tagsAsStringArray, HandlerConstants.PRODUCTION_KEY, username, false,
ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, scopeString);
if (apiApplicationKey != null && getTokenAndPersistInSession(apiApplicationKey.getConsumerKey(),
apiApplicationKey.getConsumerSecret(), req, resp, scopes)) {
log.info("tenantDomain : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
log.info("username : " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername());
ProxyResponse proxyResponse = new ProxyResponse(); ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setCode(HttpStatus.SC_OK);
HandlerUtil.handleSuccess(resp, proxyResponse); HandlerUtil.handleSuccess(resp, proxyResponse);
@ -100,6 +123,8 @@ public class LoginHandler extends HttpServlet {
log.error("Error occurred while parsing the response. ", e); log.error("Error occurred while parsing the response. ", e);
} catch (LoginException e) { } catch (LoginException e) {
log.error("Error occurred while getting token data. ", e); log.error("Error occurred while getting token data. ", e);
} catch (APIManagerException e) {
log.error("Error occurred while creating application. ", e);
} }
} }
@ -107,19 +132,19 @@ public class LoginHandler extends HttpServlet {
* Generates token from token endpoint and persists them inside the session * Generates token from token endpoint and persists them inside the session
* *
* @param req - {@link HttpServletRequest} * @param req - {@link HttpServletRequest}
* @param clientAppResult - clientAppResult // * @param clientAppResult - clientAppResult
* @param scopes - scopes defied in the application-mgt.xml * @param scopes - scopes defied in the application-mgt.xml
* @throws LoginException - login exception throws when getting token result * @throws LoginException - login exception throws when getting token result
*/ */
private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp, private boolean getTokenAndPersistInSession(String clientId, String clientSecret, HttpServletRequest req,
String clientAppResult, JsonArray scopes) throws LoginException { HttpServletResponse resp, JsonArray scopes) throws LoginException {
JsonParser jsonParser = new JsonParser(); JsonParser jsonParser = new JsonParser();
try { try {
JsonElement jClientAppResult = jsonParser.parse(clientAppResult); // JsonElement jClientAppResult = jsonParser.parse(clientAppResult);
if (jClientAppResult.isJsonObject()) { if (clientId != null && clientSecret != null) {
JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); // JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject();
String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); // String clientId = jClientAppResultAsJsonObject.get("client_id").getAsString();
String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); // String clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString();
String encodedClientApp = Base64.getEncoder() String encodedClientApp = Base64.getEncoder()
.encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes());
@ -171,12 +196,18 @@ public class LoginHandler extends HttpServlet {
if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) { if (HandlerConstants.HTTP_PROTOCOL.equals(req.getScheme())) {
iotsCorePort = System.getProperty("iot.core.http.port"); iotsCorePort = System.getProperty("iot.core.http.port");
} }
String keyManagerPort = System.getProperty("iot.keymanager.https.port");
username = req.getParameter("username"); username = req.getParameter("username");
password = req.getParameter("password"); password = req.getParameter("password");
gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host")
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") uiConfigUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + iotsCorePort + HandlerConstants.UI_CONFIG_ENDPOINT; + HandlerConstants.COLON + iotsCorePort + HandlerConstants.UI_CONFIG_ENDPOINT;
keyManagerUrl = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR +
System.getProperty("iot.keymanager.host") + HandlerConstants.COLON + keyManagerPort;
if (username == null || password == null) { if (username == null || password == null) {
String msg = "Invalid login request. Username or Password is not received for login request."; String msg = "Invalid login request. Username or Password is not received for login request.";
log.error(msg); log.error(msg);
@ -193,7 +224,7 @@ public class LoginHandler extends HttpServlet {
* @throws IOException IO exception throws if an error occurred when invoking token endpoint * @throws IOException IO exception throws if an error occurred when invoking token endpoint
*/ */
private ProxyResponse getTokenResult(String encodedClientApp, JsonArray scopes) throws IOException { private ProxyResponse getTokenResult(String encodedClientApp, JsonArray scopes) throws IOException {
HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.TOKEN_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp);
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());
String scopeString = HandlerUtil.getScopeString(scopes); String scopeString = HandlerUtil.getScopeString(scopes);

View File

@ -61,7 +61,7 @@ public class SsoLoginCallbackHandler extends HttpServlet {
String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host") String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + iotsCorePort; + HandlerConstants.COLON + iotsCorePort;
HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp"));
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());

View File

@ -101,7 +101,7 @@ public class SsoLoginHandler extends HttpServlet {
*/ */
private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) {
try { try {
File userMgtConf = new File("conf/user-mgt.xml"); File userMgtConf = new File("repository/conf/user-mgt.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(userMgtConf); Document doc = dBuilder.parse(userMgtConf);
@ -136,7 +136,7 @@ public class SsoLoginHandler extends HttpServlet {
JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray();
// Register the client application // Register the client application
HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); HttpPost apiRegEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.APP_REG_ENDPOINT);
encodedAdminCredentials = Base64.getEncoder() encodedAdminCredentials = Base64.getEncoder()
.encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes()); .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes());
apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC +
@ -262,7 +262,7 @@ public class SsoLoginHandler extends HttpServlet {
* @throws IOException IO exception throws if an error occurred when invoking token endpoint * @throws IOException IO exception throws if an error occurred when invoking token endpoint
*/ */
private ProxyResponse getTokenResult(String encodedClientApp) throws IOException { private ProxyResponse getTokenResult(String encodedClientApp) throws IOException {
HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.TOKEN_ENDPOINT); HttpPost tokenEndpoint = new HttpPost(iotsCoreUrl + HandlerConstants.TOKEN_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp);
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString());

View File

@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.IOException; import java.io.IOException;
import java.util.Base64;
@MultipartConfig @MultipartConfig
@WebServlet("/user") @WebServlet("/user")
@ -52,8 +53,8 @@ public class UserHandler extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp) { protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
try { try {
String serverUrl = String serverUrl =
req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.gateway.host") req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty("iot.core.host")
+ HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme());
HttpSession httpSession = req.getSession(false); HttpSession httpSession = req.getSession(false);
if (httpSession == null) { if (httpSession == null) {
HandlerUtil.sendUnAuthorizeResponse(resp); HandlerUtil.sendUnAuthorizeResponse(resp);
@ -68,26 +69,32 @@ public class UserHandler extends HttpServlet {
String accessToken = authData.getAccessToken(); String accessToken = authData.getAccessToken();
HttpPost tokenEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT); HttpPost introspectionEndpoint = new HttpPost(serverUrl + HandlerConstants.INTROSPECT_ENDPOINT);
tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); introspectionEndpoint.setHeader(HttpHeaders.CONTENT_TYPE,
StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, ContentType.APPLICATION_FORM_URLENCODED.toString());
//todo:amalka
String username = "admin";
String password = "admin";
introspectionEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder()
.encodeToString((username + HandlerConstants.COLON + password).getBytes()));
StringEntity introspectionPayload = new StringEntity("token=" + accessToken,
ContentType.APPLICATION_FORM_URLENCODED); ContentType.APPLICATION_FORM_URLENCODED);
tokenEndpoint.setEntity(tokenEPPayload); introspectionEndpoint.setEntity(introspectionPayload);
ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint); ProxyResponse introspectionStatus = HandlerUtil.execute(introspectionEndpoint);
if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { if (introspectionStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) {
log.error("Error occurred while invoking the API to get token status."); log.error("Error occurred while invoking the API to get token status.");
HandlerUtil.handleError(resp, tokenStatus); HandlerUtil.handleError(resp, introspectionStatus);
return; return;
} }
String tokenData = tokenStatus.getData(); String introspectionData = introspectionStatus.getData();
if (tokenData == null) { if (introspectionData == null) {
log.error("Invalid token data is received."); log.error("Invalid token data is received.");
HandlerUtil.handleError(resp, tokenStatus); HandlerUtil.handleError(resp, introspectionStatus);
return; return;
} }
JsonParser jsonParser = new JsonParser(); JsonParser jsonParser = new JsonParser();
JsonElement jTokenResult = jsonParser.parse(tokenData); JsonElement jTokenResult = jsonParser.parse(introspectionData);
if (jTokenResult.isJsonObject()) { if (jTokenResult.isJsonObject()) {
JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject();
if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) {

View File

@ -22,7 +22,7 @@ public class HandlerConstants {
public static final String PUBLISHER_APPLICATION_NAME = "application-mgt-publisher"; public static final String PUBLISHER_APPLICATION_NAME = "application-mgt-publisher";
public static final String APP_REG_ENDPOINT = "/api-application-registration/register"; public static final String APP_REG_ENDPOINT = "/api-application-registration/register";
public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt-config/v1.0/configurations/ui-config"; public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt-config/v1.0/configurations/ui-config";
public static final String TOKEN_ENDPOINT = "/token"; public static final String TOKEN_ENDPOINT = "/oauth2/token";
public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect"; public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect";
public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize";
public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/store/v0.12/applications/"; public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/store/v0.12/applications/";
@ -59,6 +59,7 @@ public class HandlerConstants {
public static final String SCHEME_SEPARATOR = "://"; public static final String SCHEME_SEPARATOR = "://";
public static final String COLON = ":"; public static final String COLON = ":";
public static final String HTTP_PROTOCOL = "http"; public static final String HTTP_PROTOCOL = "http";
public static final String HTTPS_PROTOCOL = "https";
public static final String UNDERSCORE = "_"; public static final String UNDERSCORE = "_";
public static final int INTERNAL_ERROR_CODE = 500; public static final int INTERNAL_ERROR_CODE = 500;

View File

@ -23,6 +23,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -36,12 +38,12 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import io.entgra.ui.request.interceptor.beans.ProxyResponse; import io.entgra.ui.request.interceptor.beans.ProxyResponse;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -80,6 +82,7 @@ public class HandlerUtil {
HandlerConstants.INTERNAL_ERROR_CODE)); HandlerConstants.INTERNAL_ERROR_CODE));
return proxyResponse; return proxyResponse;
} else { } else {
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) { try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
@ -400,4 +403,16 @@ public class HandlerUtil {
return stringOutput; return stringOutput;
} }
public static APIManagementProviderService getAPIManagementProviderService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
APIManagementProviderService apiManagementProviderService =
(APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null);
if (apiManagementProviderService == null) {
String msg = "API management provider service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg);
}
return apiManagementProviderService;
}
} }

View File

@ -31,5 +31,5 @@
Tomcat environment is the default and every webapps gets it even if they didn't specify it. Tomcat environment is the default and every webapps gets it even if they didn't specify it.
e.g. If a webapps requires CXF, they will get both Tomcat and CXF. e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
--> -->
<Environments>Carbon</Environments> <Environments>CXF3,Carbon</Environments>
</Classloading> </Classloading>

View File

@ -63,15 +63,15 @@
javax.xml.bind.annotation, javax.xml.bind.annotation,
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
javax.xml.validation, javax.xml.validation,
org.apache.catalina, <!--org.apache.catalina,-->
org.apache.catalina.connector, <!--org.apache.catalina.connector,-->
org.apache.catalina.util, <!--org.apache.catalina.util,-->
org.apache.commons.logging, org.apache.commons.logging,
org.apache.coyote, <!--org.apache.coyote,-->
org.apache.tomcat.util.buf, <!--org.apache.tomcat.util.buf,-->
org.apache.tomcat.util.http, <!--org.apache.tomcat.util.http,-->
org.osgi.service.component, org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
org.osgi.framework, org.osgi.service.*;version="${imp.package.version.osgi.service}",
org.w3c.dom, org.w3c.dom,
org.wso2.carbon.context, org.wso2.carbon.context,
org.wso2.carbon.core.util, org.wso2.carbon.core.util,
@ -79,7 +79,7 @@
org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}", org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}",
org.wso2.carbon.identity.oauth2.*; org.wso2.carbon.identity.oauth2.*;
version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}", version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}",
org.wso2.carbon.tomcat.ext.valves, <!--org.wso2.carbon.tomcat.ext.valves,-->
org.wso2.carbon.user.api, org.wso2.carbon.user.api,
org.wso2.carbon.user.core.service, org.wso2.carbon.user.core.service,
org.wso2.carbon.user.core.tenant, org.wso2.carbon.user.core.tenant,
@ -106,8 +106,8 @@
org.apache.commons.pool.impl, org.apache.commons.pool.impl,
org.apache.http.conn, org.apache.http.conn,
org.apache.http.impl.conn, org.apache.http.impl.conn,
javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}", <!--javax.xml.soap; version="${javax.xml.soap.imp.pkg.version}",-->
javax.xml.stream, <!--javax.xml.stream,-->
org.apache.axiom.*; version="${axiom.osgi.version.range}", org.apache.axiom.*; version="${axiom.osgi.version.range}",
org.wso2.carbon.registry.core.*, org.wso2.carbon.registry.core.*,
org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}", org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}",

View File

@ -107,9 +107,9 @@
<bundleDef> <bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version} org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.client:${project.version}
</bundleDef> </bundleDef>
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.generated.client:${project.version} <!--org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.integration.generated.client:${project.version}-->
</bundleDef> <!--</bundleDef>-->
</bundles> </bundles>
</configuration> </configuration>
</execution> </execution>

View File

@ -24,7 +24,7 @@
<WebappPublisherConfigs> <WebappPublisherConfigs>
<!-- This host is used to define the host address which is used to publish APIs --> <!-- This host is used to define the host address which is used to publish APIs -->
<Host>https://${iot.core.host}:${iot.core.https.port}</Host> <Host>https://localhost:9443</Host>
<!-- If it is true, the APIs of this instance will be published to the defined host --> <!-- If it is true, the APIs of this instance will be published to the defined host -->
<PublishAPI>true</PublishAPI> <PublishAPI>true</PublishAPI>

View File

@ -35,10 +35,10 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<modules> <modules>
<module>org.wso2.carbon.apimgt.integration.client.feature</module> <!--<module>org.wso2.carbon.apimgt.integration.client.feature</module>-->
<module>org.wso2.carbon.apimgt.webapp.publisher.feature</module> <module>org.wso2.carbon.apimgt.webapp.publisher.feature</module>
<module>org.wso2.carbon.apimgt.application.extension.feature</module> <module>org.wso2.carbon.apimgt.application.extension.feature</module>
<module>org.wso2.carbon.apimgt.handler.server.feature</module> <!--<module>org.wso2.carbon.apimgt.handler.server.feature</module>-->
</modules> </modules>
</project> </project>

View File

@ -30,7 +30,7 @@
</jndiConfig> </jndiConfig>
<definition type="RDBMS"> <definition type="RDBMS">
<configuration> <configuration>
<url>jdbc:h2:repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url> <url>jdbc:h2:./repository/database/WSO2DM_APPM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username> <username>wso2carbon</username>
<password>wso2carbon</password> <password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName> <driverClassName>org.h2.Driver</driverClassName>

View File

@ -27,7 +27,6 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>4.1.16-SNAPSHOT</version> <version>4.1.16-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>

View File

@ -43,34 +43,34 @@
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId> <!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.registry</groupId> <!--<groupId>org.wso2.carbon.registry</groupId>-->
<artifactId>org.wso2.carbon.registry.indexing</artifactId> <!--<artifactId>org.wso2.carbon.registry.indexing</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics-common</groupId> <!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<artifactId>org.wso2.carbon.event.receiver.stub</artifactId> <!--<artifactId>org.wso2.carbon.event.receiver.stub</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics-common</groupId> <!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<artifactId>org.wso2.carbon.event.stream.stub</artifactId> <!--<artifactId>org.wso2.carbon.event.stream.stub</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics-common</groupId> <!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<artifactId>org.wso2.carbon.event.publisher.stub</artifactId> <!--<artifactId>org.wso2.carbon.event.publisher.stub</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.analytics-common</groupId> <!--<groupId>org.wso2.carbon.analytics-common</groupId>-->
<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId> <!--<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.orbit.org.scannotation</groupId> <!--<groupId>org.wso2.orbit.org.scannotation</groupId>-->
<artifactId>scannotation</artifactId> <!--<artifactId>scannotation</artifactId>-->
</dependency> <!--</dependency>-->
</dependencies> </dependencies>
<build> <build>
@ -127,27 +127,27 @@
<bundleDef> <bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:${carbon.device.mgt.version} org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:${carbon.device.mgt.version}
</bundleDef> </bundleDef>
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.analytics.data.publisher:${carbon.device.mgt.version} <!--org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.analytics.data.publisher:${carbon.device.mgt.version}-->
</bundleDef> <!--</bundleDef>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.analytics-common:org.wso2.carbon.event.receiver.stub:${carbon.analytics.common.version} <!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.receiver.stub:${carbon.analytics.common.version}-->
</bundleDef> <!--</bundleDef>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.stub:${carbon.analytics.common.version} <!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.stub:${carbon.analytics.common.version}-->
</bundleDef> <!--</bundleDef>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.analytics-common:org.wso2.carbon.event.publisher.stub:${carbon.analytics.common.version} <!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.publisher.stub:${carbon.analytics.common.version}-->
</bundleDef> <!--</bundleDef>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.persistence.stub:${carbon.analytics.common.version} <!--org.wso2.carbon.analytics-common:org.wso2.carbon.event.stream.persistence.stub:${carbon.analytics.common.version}-->
</bundleDef> <!--</bundleDef>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version} <!--org.wso2.orbit.com.fasterxml.jackson.core:jackson-annotations:${jackson-annotations.version}-->
</bundleDef> <!--</bundleDef>-->
<bundleDef> <!--<bundleDef>-->
org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} <!--org.wso2.orbit.org.scannotation:scannotation:${scannotation.version}-->
</bundleDef> <!--</bundleDef>-->
</bundles> </bundles>
<importBundles> <importBundles>
<importBundleDef> <importBundleDef>

View File

@ -20,7 +20,7 @@
</filter> </filter>
</inSequence> </inSequence>
<outSequence> <outSequence>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/> <!--<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>-->
<send/> <send/>
</outSequence> </outSequence>
</resource> </resource>

View File

@ -20,7 +20,7 @@
</filter> </filter>
</inSequence> </inSequence>
<outSequence> <outSequence>
<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/> <!--<class name="org.wso2.carbon.apimgt.gateway.handlers.analytics.APIMgtResponseHandler"/>-->
<send/> <send/>
</outSequence> </outSequence>
</resource> </resource>

View File

@ -19,7 +19,7 @@
<UIConfiguration> <UIConfiguration>
<EnableOAuth>true</EnableOAuth> <EnableOAuth>true</EnableOAuth>
<EnableSSO>true</EnableSSO> <EnableSSO>false</EnableSSO>
<AppRegistration> <AppRegistration>
<Tags> <Tags>
<Tag>application_management</Tag> <Tag>application_management</Tag>

View File

@ -87,8 +87,8 @@
<importFeatures> <importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version} <importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
</importFeatureDef> </importFeatureDef>
<importFeatureDef>org.wso2.carbon.governance.metadata.server:${carbon.governance.version} <!--<importFeatureDef>org.wso2.carbon.governance.metadata.server:${carbon.governance.version}-->
</importFeatureDef> <!--</importFeatureDef>-->
</importFeatures> </importFeatures>
</configuration> </configuration>
</execution> </execution>

View File

@ -39,7 +39,7 @@
<module>org.wso2.carbon.device.mgt.api.feature</module> <module>org.wso2.carbon.device.mgt.api.feature</module>
<module>org.wso2.carbon.device.mgt.feature</module> <module>org.wso2.carbon.device.mgt.feature</module>
<module>org.wso2.carbon.device.mgt.extensions.feature</module> <module>org.wso2.carbon.device.mgt.extensions.feature</module>
<module>org.wso2.carbon.device.mgt.analytics.feature</module> <!--<module>org.wso2.carbon.device.mgt.analytics.feature</module>-->
</modules> </modules>
</project> </project>

View File

@ -73,14 +73,14 @@
<groupId>org.codehaus.woodstox</groupId> <groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId> <artifactId>wstx-asl</artifactId>
</exclusion> </exclusion>
<exclusion> <!--<exclusion>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId> <!--<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>org.wso2.carbon.analytics</groupId> <!--<groupId>org.wso2.carbon.analytics</groupId>-->
<artifactId>org.wso2.carbon.analytics.api</artifactId> <!--<artifactId>org.wso2.carbon.analytics.api</artifactId>-->
</exclusion> <!--</exclusion>-->
</exclusions> </exclusions>
</dependency> </dependency>
</dependencies> </dependencies>

143
pom.xml
View File

@ -27,7 +27,6 @@
<name>WSO2 Carbon - Device Management - Parent</name> <name>WSO2 Carbon - Device Management - Parent</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Connected Device Manager Components</description> <description>WSO2 Connected Device Manager Components</description>
<parent> <parent>
<groupId>org.wso2</groupId> <groupId>org.wso2</groupId>
<artifactId>wso2</artifactId> <artifactId>wso2</artifactId>
@ -43,21 +42,23 @@
<module>components/application-mgt</module> <module>components/application-mgt</module>
<module>components/policy-mgt</module> <module>components/policy-mgt</module>
<module>components/certificate-mgt</module> <module>components/certificate-mgt</module>
<module>components/webapp-authenticator-framework</module>
<module>components/ui-request-interceptor</module> <module>components/ui-request-interceptor</module>
<module>components/transport-mgt</module> <module>components/transport-mgt</module>
<module>features/device-mgt</module> <module>features/device-mgt</module>
<module>features/apimgt-extensions</module> <module>features/apimgt-extensions</module>
<module>features/application-mgt</module> <module>features/application-mgt</module>
<module>features/policy-mgt</module> <module>features/policy-mgt</module>
<module>features/webapp-authenticator-framework</module>
<module>features/certificate-mgt</module> <module>features/certificate-mgt</module>
<module>features/oauth-extensions</module>
<module>features/heartbeat-management</module> <module>features/heartbeat-management</module>
<module>features/ui-request-interceptor</module> <module>features/ui-request-interceptor</module>
<module>features/jwt-client</module> <module>features/jwt-client</module>
<module>features/device-mgt-extensions</module> <module>features/device-mgt-extensions</module>
<module>features/transport-mgt</module> <module>features/transport-mgt</module>
<!--<module>components/webapp-authenticator-framework</module>-->
<!--<module>features/webapp-authenticator-framework</module>-->
<!--<module>features/oauth-extensions</module>-->
</modules> </modules>
<dependencyManagement> <dependencyManagement>
@ -245,16 +246,16 @@
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId> <artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId> <!--<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>-->
<version>${carbon.device.mgt.version}</version> <!--<version>${carbon.device.mgt.version}</version>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId> <!--<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>-->
<version>${carbon.device.mgt.version}</version> <!--<version>${carbon.device.mgt.version}</version>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId> <artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
@ -286,11 +287,11 @@
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId> <artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.device.mgt.analytics.wsproxy</artifactId> <!--<artifactId>org.wso2.carbon.device.mgt.analytics.wsproxy</artifactId>-->
<version>${carbon.device.mgt.version}</version> <!--<version>${carbon.device.mgt.version}</version>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId>
@ -331,11 +332,11 @@
<version>${carbon.device.mgt.version}</version> <version>${carbon.device.mgt.version}</version>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.wso2.carbon.devicemgt</groupId> <!--<groupId>org.wso2.carbon.devicemgt</groupId>-->
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId> <!--<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>-->
<version>${carbon.device.mgt.version}</version> <!--<version>${carbon.device.mgt.version}</version>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.device.application.mgt.server.feature</artifactId>
@ -832,7 +833,7 @@
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
<version>${carbon.kernel.version}</version> <version>4.4.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
@ -1153,17 +1154,17 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.apache.cxf</groupId> <!--<groupId>org.apache.cxf</groupId>-->
<artifactId>cxf-rt-bindings-http</artifactId> <!--<artifactId>cxf-rt-bindings-http</artifactId>-->
<version>${cxf.bindings.version}</version> <!--<version>${cxf.bindings.version}</version>-->
<exclusions> <!--<exclusions>-->
<exclusion> <!--<exclusion>-->
<groupId>org.codehaus.jra</groupId> <!--<groupId>org.codehaus.jra</groupId>-->
<artifactId>jra</artifactId> <!--<artifactId>jra</artifactId>-->
</exclusion> <!--</exclusion>-->
</exclusions> <!--</exclusions>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId> <artifactId>cxf-rt-rs-extension-providers</artifactId>
@ -1347,11 +1348,21 @@
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>${google.gson.version}</version> <version>${google.gson.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.orbit.com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.wso2.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.squareup.okhttp3</groupId> <groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId> <artifactId>okhttp</artifactId>
<version>${squareup.okhttp3.version}</version> <version>${squareup.okhttp3.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.orbit.com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>${okio.wso2.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.squareup.okio</groupId> <groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId> <artifactId>okio</artifactId>
@ -1794,6 +1805,16 @@
<artifactId>commons-validator</artifactId> <artifactId>commons-validator</artifactId>
<version>${apache.validator.version}</version> <version>${apache.validator.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-web.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>${cxf-bundle-package.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -2054,9 +2075,9 @@
<properties> <properties>
<servelet.jsp.version>2.2.1</servelet.jsp.version> <servelet.jsp.version>2.2.1</servelet.jsp.version>
<testng.version>6.1.1</testng.version> <testng.version>6.1.1</testng.version>
<carbon.kernel.version>4.4.26</carbon.kernel.version> <carbon.kernel.version>4.6.1</carbon.kernel.version>
<carbon.kernel.version.range>[4.4.0, 5.0.0)</carbon.kernel.version.range> <carbon.kernel.version.range>[4.6.0, 5.0.0)</carbon.kernel.version.range>
<carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version> <carbon.p2.plugin.version>5.1.2</carbon.p2.plugin.version>
<maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version> <maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version>
<carbon.feature.plugin.version>3.1.3</carbon.feature.plugin.version> <carbon.feature.plugin.version>3.1.3</carbon.feature.plugin.version>
@ -2097,16 +2118,16 @@
<carbon.deployment.version>4.7.15</carbon.deployment.version> <carbon.deployment.version>4.7.15</carbon.deployment.version>
<!-- Carbon Identity --> <!-- Carbon Identity -->
<carbon.identity.framework.version>5.11.148</carbon.identity.framework.version> <carbon.identity.framework.version>5.18.187</carbon.identity.framework.version>
<carbon.identity.framework.version.range>[5.2.0, 6.0.0)</carbon.identity.framework.version.range> <carbon.identity.framework.version.range>[5.2.0, 7.0.0)</carbon.identity.framework.version.range>
<identity.inbound.auth.oauth.version>5.6.63</identity.inbound.auth.oauth.version> <identity.inbound.auth.oauth.version>6.4.111</identity.inbound.auth.oauth.version>
<identity.inbound.auth.saml.version>5.4.6</identity.inbound.auth.saml.version> <identity.inbound.auth.saml.version>5.4.6</identity.inbound.auth.saml.version>
<carbon.identity.jwt.grant.version>1.0.10</carbon.identity.jwt.grant.version> <carbon.identity.jwt.grant.version>1.0.31</carbon.identity.jwt.grant.version>
<carbon.identity.jwt.grant.version.range>[1.0.10, 2.0.0)</carbon.identity.jwt.grant.version.range> <carbon.identity.jwt.grant.version.range>[1.0.31, 2.0.0)</carbon.identity.jwt.grant.version.range>
<!-- Carbon Identity import version ranges --> <!-- Carbon Identity import version ranges -->
<carbon.identity.imp.pkg.version>[5.7.0, 6.0.0)</carbon.identity.imp.pkg.version> <carbon.identity.imp.pkg.version>[5.7.0, 6.0.0)</carbon.identity.imp.pkg.version>
<carbon.identity-inbound-auth-oauth.imp.pkg.version>[5.2.0, 6.0.0)</carbon.identity-inbound-auth-oauth.imp.pkg.version> <carbon.identity-inbound-auth-oauth.imp.pkg.version>[5.2.0, 7.0.0)</carbon.identity-inbound-auth-oauth.imp.pkg.version>
<carbon.identity-user-ws.imp.pkg.version>[5.1.0, 6.0.0)</carbon.identity-user-ws.imp.pkg.version> <carbon.identity-user-ws.imp.pkg.version>[5.1.0, 7.0.0)</carbon.identity-user-ws.imp.pkg.version>
<!-- Carbon Multi-tenancy --> <!-- Carbon Multi-tenancy -->
<carbon.multitenancy.version>4.6.11</carbon.multitenancy.version> <carbon.multitenancy.version>4.6.11</carbon.multitenancy.version>
@ -2131,8 +2152,8 @@
<commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range> <commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range>
<!-- Carbon API Management --> <!-- Carbon API Management -->
<carbon.api.mgt.version>6.2.201</carbon.api.mgt.version> <carbon.api.mgt.version>9.0.5</carbon.api.mgt.version>
<carbon.api.mgt.version.range>(6.0.0,7.0.0]</carbon.api.mgt.version.range> <carbon.api.mgt.version.range>(6.0.0,10.0.0]</carbon.api.mgt.version.range>
<!-- Carbon Analytics --> <!-- Carbon Analytics -->
<carbon.analytics.common.version>5.1.37</carbon.analytics.common.version> <carbon.analytics.common.version>5.1.37</carbon.analytics.common.version>
@ -2142,20 +2163,20 @@
<carbon.event-processing.version>2.1.23</carbon.event-processing.version> <carbon.event-processing.version>2.1.23</carbon.event-processing.version>
<!-- Carbon Registry --> <!-- Carbon Registry -->
<carbon.registry.version>4.6.28</carbon.registry.version> <carbon.registry.version>4.7.38</carbon.registry.version>
<carbon.registry.resource.version>4.6.8</carbon.registry.resource.version> <carbon.registry.resource.version>${carbon.registry.version}</carbon.registry.resource.version>
<carbon.registry.imp.pkg.version.range>[4.4.8, 5.0.0)</carbon.registry.imp.pkg.version.range> <carbon.registry.imp.pkg.version.range>[4.7.0, 5.0.0)</carbon.registry.imp.pkg.version.range>
<!--CXF properties--> <!--CXF properties-->
<cxf.version>3.2.0</cxf.version> <cxf.version>3.3.6</cxf.version>
<cxf.bindings.version>2.5.11</cxf.bindings.version> <!--<cxf.bindings.version>2.5.11</cxf.bindings.version>-->
<json-simple.version>1.1.wso2v1</json-simple.version> <json-simple.version>1.1.wso2v1</json-simple.version>
<jackson.version>1.9.0</jackson.version> <jackson.version>1.9.0</jackson.version>
<!-- BouncyCastle --> <!-- BouncyCastle -->
<bcprov.wso2.version>1.52.0.wso2v1</bcprov.wso2.version> <bcprov.wso2.version>1.60.0.wso2v1</bcprov.wso2.version>
<bcpkix.wso2.version>1.52.0.wso2v2</bcpkix.wso2.version> <bcpkix.wso2.version>1.60.0.wso2v1</bcpkix.wso2.version>
<bcprov.wso2.version.range>[1.52.0,1.60.0)</bcprov.wso2.version.range> <bcprov.wso2.version.range>[1.52.0,1.70.0)</bcprov.wso2.version.range>
<!-- JSCEP --> <!-- JSCEP -->
<jscep.version>2.3.0.wso2v2</jscep.version> <jscep.version>2.3.0.wso2v2</jscep.version>
@ -2166,7 +2187,9 @@
<commons-json.version>3.0.0.wso2v1</commons-json.version> <commons-json.version>3.0.0.wso2v1</commons-json.version>
<json.smart.version>1.3</json.smart.version> <json.smart.version>1.3</json.smart.version>
<google.gson.version>2.3.1</google.gson.version> <google.gson.version>2.3.1</google.gson.version>
<squareup.okhttp3.version>3.8.1</squareup.okhttp3.version> <squareup.okhttp3.version>4.6.0</squareup.okhttp3.version>
<okhttp.wso2.version>4.2.0.wso2v1</okhttp.wso2.version>
<okio.wso2.version>2.4.0.wso2v1</okio.wso2.version>
<okio.version>1.13.0</okio.version> <okio.version>1.13.0</okio.version>
<github.openfeign.version>9.3.1</github.openfeign.version> <github.openfeign.version>9.3.1</github.openfeign.version>
<jsr311.version>1.1.1</jsr311.version> <jsr311.version>1.1.1</jsr311.version>
@ -2282,6 +2305,12 @@
<tomcat.websocket.version>7.0.85</tomcat.websocket.version> <tomcat.websocket.version>7.0.85</tomcat.websocket.version>
<javax.websocket.version>1.0</javax.websocket.version> <javax.websocket.version>1.0</javax.websocket.version>
<glassfish.tyrus.version>1.13.1</glassfish.tyrus.version> <glassfish.tyrus.version>1.13.1</glassfish.tyrus.version>
<spring-web.version>5.1.2.RELEASE</spring-web.version>
<cxf-bundle-package.version>2.7.18</cxf-bundle-package.version>
<imp.package.version.osgi.framework>[1.6.0, 2.0.0)</imp.package.version.osgi.framework>
<imp.package.version.osgi.service>[1.2.0,1.3.0)</imp.package.version.osgi.service>
</properties> </properties>
<distributionManagement> <distributionManagement>