mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'kernel-4.6.2' into 'kernel-4.6.x'
Updating to Kernel 4.6.2 See merge request entgra/carbon-device-mgt!770
This commit is contained in:
commit
1b7db92e91
@ -22,13 +22,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Management Annotations</name>
|
||||
<description>WSO2 Carbon - API Management Custom Annotation Module</description>
|
||||
@ -73,8 +72,8 @@
|
||||
org.wso2.carbon.apimgt.annotations.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.apache.commons.logging,
|
||||
javax.servlet,
|
||||
javax.xml.*,
|
||||
|
||||
@ -21,12 +21,11 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension.api</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - API Application Management API</name>
|
||||
@ -34,42 +33,24 @@
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<!--CXF -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<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-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>
|
||||
</dependency>
|
||||
|
||||
<!--JAX-RS -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
|
||||
@ -27,8 +27,6 @@ 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.dto.ApiApplicationKey;
|
||||
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
|
||||
import org.wso2.carbon.apimgt.integration.client.OAuthRequestInterceptor;
|
||||
import org.wso2.carbon.apimgt.integration.client.store.StoreClient;
|
||||
import org.wso2.carbon.base.MultitenantConstants;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
@ -110,12 +108,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
|
||||
|
||||
if (username.equals(registrationProfile.getUsername())) {
|
||||
synchronized (ApiApplicationRegistrationServiceImpl.class) {
|
||||
StoreClient storeClient = new StoreClient(new OAuthRequestInterceptor(registrationProfile.getUsername(),
|
||||
registrationProfile.getPassword()));
|
||||
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
||||
applicationName, registrationProfile.getTags(),
|
||||
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username,
|
||||
registrationProfile.isAllowedToAllDomains(), validityPeriod, storeClient);
|
||||
registrationProfile.isAllowedToAllDomains(), validityPeriod);
|
||||
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,12 @@ import org.wso2.carbon.user.api.UserRealm;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
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.HttpServletResponse;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -22,12 +22,11 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Application Management</name>
|
||||
@ -52,12 +51,13 @@
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
|
||||
<groupId>org.wso2.carbon.apimgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
|
||||
<groupId>org.wso2.carbon.apimgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple.wso2</groupId>
|
||||
@ -100,24 +100,32 @@
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>API Management Application Bundle</Bundle-Description>
|
||||
<Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging.*,
|
||||
org.wso2.carbon.user.core.*,
|
||||
org.wso2.carbon.user.api,
|
||||
org.wso2.carbon.utils.multitenancy,
|
||||
<Import-Packages>
|
||||
org.apache.commons.lang;version="[2.6,3)",
|
||||
org.apache.commons.logging;version="[1.2,2)",
|
||||
org.json.simple,
|
||||
org.wso2.carbon.context,
|
||||
org.wso2.carbon.base,
|
||||
org.wso2.carbon.registry.core.*;resolution:=optional,
|
||||
org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}",
|
||||
org.wso2.carbon.apimgt.integration.client.*,
|
||||
org.wso2.carbon.apimgt.integration.generated.client.store.api,
|
||||
org.wso2.carbon.apimgt.integration.generated.client.store.model,
|
||||
org.wso2.carbon.identity.jwt.client.extension.*,
|
||||
feign
|
||||
</Import-Package>
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.apimgt.api.dto;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.apimgt.application.extension.bean,
|
||||
org.wso2.carbon.apimgt.application.extension.dto,
|
||||
org.wso2.carbon.apimgt.application.extension.exception,
|
||||
org.wso2.carbon.apimgt.impl;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.apimgt.impl.utils;version="${carbon.api.mgt.version.range}",
|
||||
org.wso2.carbon.context;version="${carbon.kernel.version.range}",
|
||||
org.wso2.carbon.identity.jwt.client.extension,
|
||||
org.wso2.carbon.identity.jwt.client.extension.dto,
|
||||
org.wso2.carbon.identity.jwt.client.extension.exception,
|
||||
org.wso2.carbon.identity.jwt.client.extension.service,
|
||||
org.wso2.carbon.registry.core.exceptions;version="[1.0,2)",
|
||||
org.wso2.carbon.registry.core.service;version="[1.0,2)",
|
||||
org.wso2.carbon.registry.indexing.service;version="${carbon.registry.imp.pkg.version.range}",
|
||||
org.wso2.carbon.user.api;version="[1.0,2)",
|
||||
org.wso2.carbon.user.core.service;version="${carbon.kernel.version.range}",
|
||||
org.wso2.carbon.user.core.tenant;version="${carbon.kernel.version.range}"
|
||||
</Import-Packages>
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.apimgt.application.extension.internal,
|
||||
org.wso2.carbon.apimgt.application.extension.*
|
||||
|
||||
@ -20,7 +20,6 @@ package org.wso2.carbon.apimgt.application.extension;
|
||||
|
||||
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -51,28 +50,6 @@ public interface APIManagementProviderService {
|
||||
String keyType, String username, boolean isAllowedAllDomains,
|
||||
String validityTime) throws APIManagerException;
|
||||
|
||||
/**
|
||||
* Generate and retreive application keys. if the application does exist then
|
||||
* create it and subscribe to apis that are grouped with the tags.
|
||||
*
|
||||
* @param apiApplicationName name of the application.
|
||||
* @param tags tags of the apis that application needs to be subscribed.
|
||||
* @param keyType of the application.
|
||||
* @param username to whom the application is created
|
||||
* @param isAllowedAllDomains application is allowed to all the tenants
|
||||
* @param validityTime validity period of the application
|
||||
* @param storeClient Specified store client
|
||||
* @return consumerkey and secrete of the created application.
|
||||
* @throws APIManagerException
|
||||
*/
|
||||
ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName,
|
||||
String tags[],
|
||||
String keyType,
|
||||
String username,
|
||||
boolean isAllowedAllDomains,
|
||||
String validityTime,
|
||||
StoreClient storeClient) throws APIManagerException;
|
||||
|
||||
/**
|
||||
* Remove APIM Application.
|
||||
*/
|
||||
|
||||
@ -18,18 +18,29 @@
|
||||
|
||||
package org.wso2.carbon.apimgt.application.extension;
|
||||
|
||||
import feign.FeignException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
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.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.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.constants.ApiApplicationConstants;
|
||||
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.internal.APIApplicationManagerExtensionDataHolder;
|
||||
import org.wso2.carbon.apimgt.application.extension.util.APIManagerUtil;
|
||||
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.*;
|
||||
import org.wso2.carbon.apimgt.impl.APIAdminImpl;
|
||||
import org.wso2.carbon.apimgt.impl.APIConstants;
|
||||
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
|
||||
import org.wso2.carbon.apimgt.impl.utils.APIUtil;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
|
||||
@ -39,7 +50,10 @@ import org.wso2.carbon.user.api.UserStoreException;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This class represents an implementation of APIManagementProviderService.
|
||||
@ -47,51 +61,37 @@ import java.util.List;
|
||||
public class APIManagementProviderServiceImpl implements APIManagementProviderService {
|
||||
|
||||
private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class);
|
||||
private static final String CONTENT_TYPE = "application/json";
|
||||
private static final int MAX_API_PER_TAG = 200;
|
||||
private static final String APP_TIER_TYPE = "application";
|
||||
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
|
||||
|
||||
@Override
|
||||
public boolean isTierLoaded() {
|
||||
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
|
||||
.getStoreClient();
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.getTenantDomain();
|
||||
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
|
||||
try {
|
||||
storeClient.getIndividualTier().tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER,
|
||||
APP_TIER_TYPE,
|
||||
tenantDomain, CONTENT_TYPE, null, null);
|
||||
APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, tenantDomain);
|
||||
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) {
|
||||
} catch (APIManagementException e) {
|
||||
log.error("APIs not ready", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAPIApplication(String applicationName, String username) throws APIManagerException {
|
||||
|
||||
StoreClient storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
|
||||
.getStoreClient();
|
||||
ApplicationList applicationList = storeClient.getApplications()
|
||||
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
|
||||
if (applicationList.getList() != null && applicationList.getList().size() > 0) {
|
||||
ApplicationInfo applicationInfo = applicationList.getList().get(0);
|
||||
storeClient.getIndividualApplication().applicationsApplicationIdDelete(applicationInfo.getApplicationId(),
|
||||
null, null);
|
||||
try {
|
||||
APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
|
||||
Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
|
||||
if (application != null) {
|
||||
apiConsumer.removeApplication(application, username);
|
||||
}
|
||||
} catch (APIManagementException e) {
|
||||
throw new APIManagerException("Failed to remove api application : " + applicationName, e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,95 +99,83 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
*/
|
||||
@Override
|
||||
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
|
||||
String keyType, String username,
|
||||
boolean isAllowedAllDomains, String validityTime,
|
||||
StoreClient sClient) throws APIManagerException {
|
||||
String keyType, String username, boolean isAllowedAllDomains, String validityTime)
|
||||
throws APIManagerException {
|
||||
|
||||
StoreClient storeClient;
|
||||
|
||||
if (sClient == null) {
|
||||
storeClient = APIApplicationManagerExtensionDataHolder.getInstance().getIntegrationClientService()
|
||||
.getStoreClient();
|
||||
} else {
|
||||
storeClient = sClient;
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
}
|
||||
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.getTenantDomain();
|
||||
try {
|
||||
ApplicationList applicationList = storeClient.getApplications()
|
||||
.applicationsGet("", applicationName, 1, 0, CONTENT_TYPE, null);
|
||||
Application application;
|
||||
if (applicationList == null || applicationList.getList() == null || applicationList.getList().size() == 0) {
|
||||
//create application;
|
||||
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);
|
||||
}
|
||||
APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username);
|
||||
Application application = apiConsumer.getApplicationsByName(username, applicationName, "");
|
||||
|
||||
int applicationId = 0;
|
||||
Subscriber subscriber = null;
|
||||
if (application == null) {
|
||||
throw new APIManagerException(
|
||||
"Api application creation failed for " + applicationName + " to the user " + username);
|
||||
subscriber = apiConsumer.getSubscriber(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("");
|
||||
application.setTokenType("OAUTH");
|
||||
apiConsumer.addApplication(application, username);
|
||||
application = apiConsumer.getApplicationsByName(username, applicationName, "");
|
||||
} else {
|
||||
subscriber = apiConsumer.getSubscriber(username);
|
||||
}
|
||||
|
||||
SubscriptionList subscriptionList = storeClient.getSubscriptions().subscriptionsGet
|
||||
(null, application.getApplicationId(), "", 0, 100, CONTENT_TYPE, null);
|
||||
List<Subscription> needToSubscribe = new ArrayList<>();
|
||||
Set<SubscribedAPI> subscribedAPIs =
|
||||
apiConsumer.getSubscribedAPIs(subscriber, applicationName, "");
|
||||
|
||||
log.info("Already subscribed API count: " + subscribedAPIs.size());
|
||||
|
||||
// subscribe to apis.
|
||||
Set<String> tempApiIds = new HashSet<>();
|
||||
if (tags != null && tags.length > 0) {
|
||||
for (String tag : tags) {
|
||||
APIList apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0, tenantDomain, "tag:" + tag
|
||||
, CONTENT_TYPE, null);
|
||||
if (apiList.getList() == null || apiList.getList().size() == 0) {
|
||||
apiList = storeClient.getApis().apisGet(MAX_API_PER_TAG, 0
|
||||
, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, "tag:" + tag, CONTENT_TYPE, null);
|
||||
Set<API> apisWithTag = apiConsumer.getAPIsWithTag(tag, tenantDomain);
|
||||
if (apisWithTag == null || apisWithTag.size() == 0) {
|
||||
apisWithTag = apiConsumer.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
||||
}
|
||||
|
||||
if (apiList.getList() != null && apiList.getList().size() > 0) {
|
||||
for (APIInfo apiInfo : apiList.getList()) {
|
||||
String id = apiInfo.getProvider().replace("@", "-AT-")
|
||||
+ "-" + apiInfo.getName() + "-" + apiInfo.getVersion();
|
||||
id = id.replace(" ", "+");
|
||||
if (apisWithTag != null && apisWithTag.size() > 0) {
|
||||
for (API apiInfo : apisWithTag) {
|
||||
String id = apiInfo.getId().getProviderName().replace("@", "-AT-")
|
||||
+ "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion();
|
||||
// todo: amalka will this break old apis?
|
||||
boolean subscriptionExist = false;
|
||||
if (subscriptionList.getList() != null && subscriptionList.getList().size() > 0) {
|
||||
for (Subscription subs : subscriptionList.getList()) {
|
||||
if (subs.getApiIdentifier().equals(id)) {
|
||||
if (subscribedAPIs.size() > 0) {
|
||||
for (SubscribedAPI subscribedAPI : subscribedAPIs) {
|
||||
if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) {
|
||||
subscriptionExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!subscriptionExist) {
|
||||
Subscription subscription = new Subscription();
|
||||
//fix for APIMANAGER-5566 admin-AT-tenant1.com-Tenant1API1-1.0.0
|
||||
if (!subscriptionExist && !tempApiIds.contains(id)) {
|
||||
ApiTypeWrapper apiTypeWrapper = apiConsumer.getAPIorAPIProductByUUID(
|
||||
apiInfo.getUuid(), tenantDomain);
|
||||
apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER);
|
||||
|
||||
subscription.setApiIdentifier(id);
|
||||
subscription.setApplicationId(application.getApplicationId());
|
||||
subscription.tier(ApiApplicationConstants.DEFAULT_TIER);
|
||||
if (!needToSubscribe.contains(subscription)) {
|
||||
needToSubscribe.add(subscription);
|
||||
apiConsumer.addSubscription(apiTypeWrapper, username, application);
|
||||
tempApiIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!needToSubscribe.isEmpty()) {
|
||||
storeClient.getSubscriptionMultitpleApi().subscriptionsMultiplePost(needToSubscribe, CONTENT_TYPE);
|
||||
}
|
||||
//end of subscription
|
||||
|
||||
List<ApplicationKey> applicationKeys = application.getKeys();
|
||||
List<APIKey> applicationKeys = application.getKeys();
|
||||
if (applicationKeys != null) {
|
||||
for (ApplicationKey applicationKey : applicationKeys) {
|
||||
if (keyType.equals(applicationKey.getKeyType().toString())) {
|
||||
for (APIKey applicationKey : applicationKeys) {
|
||||
if (keyType.equals(applicationKey.getType())) {
|
||||
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
|
||||
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
|
||||
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
|
||||
@ -198,43 +186,49 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationKeyGenerateRequest applicationKeyGenerateRequest = new ApplicationKeyGenerateRequest();
|
||||
List<String> allowedDomains = new ArrayList<>();
|
||||
if (isAllowedAllDomains) {
|
||||
allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS);
|
||||
} else {
|
||||
allowedDomains.add(APIManagerUtil.getTenantDomain());
|
||||
}
|
||||
applicationKeyGenerateRequest.setAccessAllowDomains(allowedDomains);
|
||||
applicationKeyGenerateRequest.setCallbackUrl("");
|
||||
applicationKeyGenerateRequest.setKeyType(ApplicationKeyGenerateRequest.KeyTypeEnum.PRODUCTION);
|
||||
applicationKeyGenerateRequest.setValidityTime(validityTime);
|
||||
|
||||
ApplicationKey applicationKey = storeClient.getIndividualApplication().applicationsGenerateKeysPost(
|
||||
application.getApplicationId(), applicationKeyGenerateRequest, CONTENT_TYPE, null, null);
|
||||
if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) {
|
||||
APIAdmin apiAdmin = new APIAdminImpl();
|
||||
String keyManagerId = null;
|
||||
try {
|
||||
List<KeyManagerConfigurationDTO> keyManagerConfigurations = apiAdmin
|
||||
.getKeyManagerConfigurationsByTenant(tenantDomain);
|
||||
if (keyManagerConfigurations != null) {
|
||||
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 + "\"}";
|
||||
|
||||
Map<String, Object> keyDetails = apiConsumer
|
||||
.requestApprovalForApplicationRegistration(username, applicationName, keyType, "",
|
||||
allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "",
|
||||
jsonString, keyManagerId, tenantDomain);
|
||||
|
||||
if (keyDetails != null) {
|
||||
ApiApplicationKey apiApplicationKey = new ApiApplicationKey();
|
||||
apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey());
|
||||
apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret());
|
||||
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 (FeignException e) {
|
||||
} catch (APIManagementException e) {
|
||||
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
|
||||
}
|
||||
} catch (APIManagementException e) {
|
||||
throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[],
|
||||
String keyType, String username,
|
||||
boolean isAllowedAllDomains,
|
||||
String validityTime)
|
||||
throws APIManagerException {
|
||||
return this.generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username,
|
||||
isAllowedAllDomains, validityTime, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -311,7 +305,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
|
||||
if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) {
|
||||
info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
|
||||
registrationProfile.getTags(), tokenType, registrationProfile.getApplicationName(),
|
||||
registrationProfile.getTags(), tokenType, null,
|
||||
registrationProfile.isAllowedToAllDomains(), validityPeriod);
|
||||
}
|
||||
} finally {
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
package org.wso2.carbon.apimgt.application.extension.internal;
|
||||
|
||||
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
|
||||
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
|
||||
import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
|
||||
@ -35,7 +34,6 @@ public class APIApplicationManagerExtensionDataHolder {
|
||||
private TenantManager tenantManager;
|
||||
private TenantRegistryLoader tenantRegistryLoader;
|
||||
private TenantIndexingLoader indexLoader;
|
||||
private IntegrationClientService integrationClientService;
|
||||
private JWTClientManagerService jwtClientManagerService;
|
||||
|
||||
private APIApplicationManagerExtensionDataHolder() {
|
||||
@ -94,15 +92,6 @@ public class APIApplicationManagerExtensionDataHolder {
|
||||
return indexLoader;
|
||||
}
|
||||
|
||||
public IntegrationClientService getIntegrationClientService() {
|
||||
return integrationClientService;
|
||||
}
|
||||
|
||||
public void setIntegrationClientService(
|
||||
IntegrationClientService integrationClientService) {
|
||||
this.integrationClientService = integrationClientService;
|
||||
}
|
||||
|
||||
public JWTClientManagerService getJwtClientManagerService() {
|
||||
if (jwtClientManagerService == null) {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
|
||||
@ -23,7 +23,6 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.service.component.ComponentContext;;
|
||||
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
|
||||
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderServiceImpl;
|
||||
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
|
||||
import org.wso2.carbon.registry.core.service.TenantRegistryLoader;
|
||||
import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
@ -49,12 +48,6 @@ import org.wso2.carbon.user.core.service.RealmService;
|
||||
* policy="dynamic"
|
||||
* bind="setRealmService"
|
||||
* 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 {
|
||||
|
||||
@ -97,17 +90,6 @@ public class APIApplicationManagerExtensionServiceComponent {
|
||||
APIApplicationManagerExtensionDataHolder.getInstance().setIndexLoaderService(null);
|
||||
}
|
||||
|
||||
protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
|
||||
if (integrationClientService != null && log.isDebugEnabled()) {
|
||||
log.debug("integrationClientService initialized");
|
||||
}
|
||||
APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(integrationClientService);
|
||||
}
|
||||
|
||||
protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
|
||||
APIApplicationManagerExtensionDataHolder.getInstance().setIntegrationClientService(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Realm Service.
|
||||
*
|
||||
|
||||
@ -21,13 +21,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.handlers</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Security Handler Component</name>
|
||||
<description>WSO2 Carbon - API Management Security Handler Module</description>
|
||||
|
||||
@ -13,13 +13,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Management Integration Client</name>
|
||||
<description>WSO2 Carbon - API Management Integration Client</description>
|
||||
|
||||
@ -13,13 +13,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.integration.generated.client</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Management Integration Generated Client</name>
|
||||
<description>WSO2 Carbon - API Management Integration Client</description>
|
||||
|
||||
@ -22,13 +22,12 @@
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - API Management Webapp Publisher</name>
|
||||
<description>WSO2 Carbon - API Management Webapp Publisher</description>
|
||||
@ -109,8 +108,14 @@
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
|
||||
<groupId>org.wso2.carbon.apimgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.apimgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database.wso2</groupId>
|
||||
@ -144,41 +149,46 @@
|
||||
org.wso2.carbon.apimgt.webapp.publisher.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
javax.servlet,
|
||||
javax.xml.*,
|
||||
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
|
||||
com.google.gson.*,
|
||||
org.apache.catalina,
|
||||
org.apache.catalina.core,
|
||||
org.apache.axis2.*;version="${axis2.osgi.version.range}",
|
||||
org.wso2.carbon.core,
|
||||
org.apache.commons.lang,
|
||||
org.wso2.carbon.utils,
|
||||
org.wso2.carbon.apimgt.annotations.*,
|
||||
org.wso2.carbon.governance.lcm.util.*,
|
||||
org.wso2.carbon.registry.core.*,
|
||||
com.google.gson;version="2.3",
|
||||
com.google.gson.reflect;version="2.3",
|
||||
io.swagger.annotations,
|
||||
javax.net.ssl,
|
||||
org.scannotation,
|
||||
org.scannotation.archiveiterator,
|
||||
javax.servlet;version="2.6",
|
||||
javax.xml,
|
||||
javax.xml.bind,
|
||||
javax.xml.bind.annotation,
|
||||
javax.xml.parsers,
|
||||
org.apache.catalina;version="9.0",
|
||||
org.apache.catalina.core;version="9.0",
|
||||
org.apache.commons.logging;version="1.2",
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.scannotation;version="1.0",
|
||||
org.scannotation.archiveiterator;version="1.0",
|
||||
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
|
||||
org.wso2.carbon.apimgt.annotations.api,
|
||||
org.wso2.carbon.apimgt.api,
|
||||
org.wso2.carbon.apimgt.api.model,
|
||||
org.wso2.carbon.apimgt.impl,
|
||||
org.wso2.carbon.apimgt.webapp.publisher,
|
||||
org.wso2.carbon.apimgt.webapp.publisher.config,
|
||||
org.wso2.carbon.apimgt.webapp.publisher.dto,
|
||||
org.wso2.carbon.apimgt.webapp.publisher.exception,
|
||||
org.wso2.carbon.apimgt.webapp.publisher.lifecycle.listener,
|
||||
org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util,
|
||||
org.wso2.carbon.base;version="1.0",
|
||||
org.wso2.carbon.context;version="4.6",
|
||||
org.wso2.carbon.core;version="4.6",
|
||||
org.wso2.carbon.core.util;version="4.6",
|
||||
org.wso2.carbon.registry.core.service;version="1.0",
|
||||
org.wso2.carbon.user.api;version="1.0",
|
||||
org.wso2.carbon.user.core.service;version="4.6",
|
||||
org.wso2.carbon.user.core.tenant;version="4.6",
|
||||
org.wso2.carbon.utils;version="4.6",
|
||||
org.wso2.carbon.utils.multitenancy;version="4.6"
|
||||
</Import-Package>
|
||||
<Embed-Dependency>
|
||||
javax.ws.rs-api,
|
||||
scribe;scope=compile|runtime;inline=false;
|
||||
jsr311-api;scope=compile|runtime;inline=false
|
||||
</Embed-Dependency>
|
||||
<DynamicImport-Package>*</DynamicImport-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@ -210,4 +220,5 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@ -18,15 +18,31 @@
|
||||
*/
|
||||
package org.wso2.carbon.apimgt.webapp.publisher;
|
||||
|
||||
import feign.FeignException;
|
||||
import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*;
|
||||
import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient;
|
||||
import org.wso2.carbon.apimgt.api.APIManagementException;
|
||||
import org.wso2.carbon.apimgt.api.APIProvider;
|
||||
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.dto.ApiUriTemplate;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* This class represents the concrete implementation of the APIPublisherService that corresponds to providing all
|
||||
@ -34,11 +50,10 @@ import java.util.*;
|
||||
*/
|
||||
public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
private static final String UNLIMITED_TIER = "Unlimited";
|
||||
private static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox";
|
||||
private static final String CONTENT_TYPE = "application/json";
|
||||
private static final String PUBLISHED_STATUS = "PUBLISHED";
|
||||
private static final String API_PUBLISH_ENVIRONMENT = "Default";
|
||||
private static final String CREATED_STATUS = "CREATED";
|
||||
private static final String PUBLISH_ACTION = "Publish";
|
||||
public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance();
|
||||
|
||||
@Override
|
||||
public void publishAPI(APIConfig apiConfig) throws APIManagerPublisherException {
|
||||
@ -47,99 +62,124 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(apiConfig.getOwner());
|
||||
try {
|
||||
PublisherClient publisherClient = APIPublisherDataHolder.getInstance().getIntegrationClientService()
|
||||
.getPublisherClient();
|
||||
APIProvider apiProvider = API_MANAGER_FACTORY.getAPIProvider(apiConfig.getOwner());
|
||||
API api = getAPI(apiConfig);
|
||||
APIList apiList = publisherClient.getApis().apisGet(100, 0, "name:" + api.getName(), CONTENT_TYPE, null);
|
||||
|
||||
if (!isExist(api, apiList)) {
|
||||
api = publisherClient.getApi().apisPost(api, CONTENT_TYPE, null);
|
||||
if (CREATED_STATUS.equals(api.getStatus())) {
|
||||
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null, null);
|
||||
if (!apiProvider.isAPIAvailable(api.getId())) {
|
||||
API createdAPI = apiProvider.addAPI(api);
|
||||
if (CREATED_STATUS.equals(createdAPI.getStatus())) {
|
||||
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 {
|
||||
if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) {
|
||||
for (APIInfo apiInfo : apiList.getList()) {
|
||||
if (api.getName().equals(apiInfo.getName()) && api.getVersion().equals(apiInfo.getVersion())) {
|
||||
api = publisherClient.getApi().apisApiIdPut(apiInfo.getId(), api, CONTENT_TYPE, null, null);
|
||||
if (api != null && CREATED_STATUS.equals(api.getStatus())) {
|
||||
publisherClient.getApi().apisChangeLifecyclePost(PUBLISH_ACTION, api.getId(), null, null,
|
||||
null);
|
||||
API existingAPI = apiProvider.getAPI(api.getId());
|
||||
api.setStatus(existingAPI.getStatus());
|
||||
apiProvider.updateAPI(api);
|
||||
if (api.getId().getName().equals(existingAPI.getId().getName()) &&
|
||||
api.getId().getVersion().equals(existingAPI.getId().getVersion())) {
|
||||
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);
|
||||
} finally {
|
||||
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) {
|
||||
|
||||
API api = new API();
|
||||
api.setName(config.getName());
|
||||
APIIdentifier apiIdentifier = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
|
||||
API api = new API(apiIdentifier);
|
||||
api.setDescription("");
|
||||
|
||||
String context = config.getContext();
|
||||
context = context.startsWith("/") ? context : ("/" + context);
|
||||
api.setContext(context);
|
||||
api.setVersion(config.getVersion());
|
||||
api.setProvider(config.getOwner());
|
||||
api.setApiDefinition(APIPublisherUtil.getSwaggerDefinition(config));
|
||||
api.setWsdlUri(null);
|
||||
api.setStatus(PUBLISHED_STATUS);
|
||||
api.setResponseCaching("DISABLED");
|
||||
api.setDestinationStatsEnabled("false");
|
||||
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\"}";
|
||||
api.setContext(context + "/" + config.getVersion());
|
||||
api.setStatus(CREATED_STATUS);
|
||||
api.setWsdlUrl(null);
|
||||
api.setResponseCache("Disabled");
|
||||
api.setContextTemplate(context + "/{version}" );
|
||||
api.setSwaggerDefinition(APIPublisherUtil.getSwaggerDefinition(config));
|
||||
api.setType("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 = "{ \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \" " +
|
||||
config.getEndpoint() + "\" }, \"production_endpoints\": { \"url\": \" "+ config.getEndpoint()+"\" } }";
|
||||
|
||||
api.setEndpointConfig(endpointConfig);
|
||||
APICorsConfiguration apiCorsConfiguration = new APICorsConfiguration();
|
||||
List<String> accessControlAllowOrigins = new ArrayList<>();
|
||||
accessControlAllowOrigins.add("*");
|
||||
apiCorsConfiguration.setAccessControlAllowOrigins(accessControlAllowOrigins);
|
||||
|
||||
List<String> accessControlAllowHeaders = new ArrayList<>();
|
||||
accessControlAllowHeaders.add("authorization");
|
||||
accessControlAllowHeaders.add("Access-Control-Allow-Origin");
|
||||
accessControlAllowHeaders.add("Content-Type");
|
||||
accessControlAllowHeaders.add("SOAPAction");
|
||||
apiCorsConfiguration.setAccessControlAllowHeaders(accessControlAllowHeaders);
|
||||
|
||||
accessControlAllowHeaders.add("apikey");
|
||||
accessControlAllowHeaders.add("Internal-Key");
|
||||
List<String> accessControlAllowMethods = new ArrayList<>();
|
||||
accessControlAllowMethods.add("GET");
|
||||
accessControlAllowMethods.add("PUT");
|
||||
@ -147,10 +187,16 @@ public class APIPublisherServiceImpl implements APIPublisherService {
|
||||
accessControlAllowMethods.add("POST");
|
||||
accessControlAllowMethods.add("PATCH");
|
||||
accessControlAllowMethods.add("OPTIONS");
|
||||
apiCorsConfiguration.setAccessControlAllowMethods(accessControlAllowMethods);
|
||||
apiCorsConfiguration.setAccessControlAllowCredentials(false);
|
||||
apiCorsConfiguration.corsConfigurationEnabled(false);
|
||||
api.setCorsConfiguration(apiCorsConfiguration);
|
||||
CORSConfiguration corsConfiguration = new CORSConfiguration(false, accessControlAllowOrigins, false,
|
||||
accessControlAllowHeaders, accessControlAllowMethods);
|
||||
api.setCorsConfiguration(corsConfiguration);
|
||||
|
||||
api.setAuthorizationHeader("Authorization");
|
||||
List<String> keyManagers = new ArrayList<>();
|
||||
keyManagers.add("all");
|
||||
api.setKeyManagers(keyManagers);
|
||||
api.setEnableStore(true);
|
||||
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.wso2.carbon.apimgt.webapp.publisher.internal;
|
||||
|
||||
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
|
||||
import org.wso2.carbon.apimgt.webapp.publisher.APIConfig;
|
||||
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
|
||||
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||
@ -37,8 +36,6 @@ public class APIPublisherDataHolder {
|
||||
private RegistryService registryService;
|
||||
private boolean isServerStarted;
|
||||
private Stack<APIConfig> unpublishedApis = new Stack<>();
|
||||
private IntegrationClientService integrationClientService;
|
||||
|
||||
private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder();
|
||||
|
||||
private APIPublisherDataHolder() {
|
||||
@ -117,12 +114,4 @@ public class APIPublisherDataHolder {
|
||||
this.unpublishedApis = unpublishedApis;
|
||||
}
|
||||
|
||||
public IntegrationClientService getIntegrationClientService() {
|
||||
return integrationClientService;
|
||||
}
|
||||
|
||||
public void setIntegrationClientService(
|
||||
IntegrationClientService integrationClientService) {
|
||||
this.integrationClientService = integrationClientService;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
|
||||
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
|
||||
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherServiceImpl;
|
||||
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherStartupHandler;
|
||||
@ -45,11 +44,6 @@ import org.wso2.carbon.user.core.service.RealmService;
|
||||
* policy="dynamic"
|
||||
* bind="setRegistryService"
|
||||
* unbind="unsetRegistryService"
|
||||
* interface="org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setIntegrationClientService"
|
||||
* unbind="unsetIntegrationClientService"
|
||||
*/
|
||||
public class APIPublisherServiceComponent {
|
||||
|
||||
@ -120,14 +114,4 @@ public class APIPublisherServiceComponent {
|
||||
APIPublisherDataHolder.getInstance().setRegistryService(null);
|
||||
}
|
||||
|
||||
protected void setIntegrationClientService(IntegrationClientService integrationClientService) {
|
||||
if (integrationClientService != null && log.isDebugEnabled()) {
|
||||
log.debug("integrationClientService initialized");
|
||||
}
|
||||
APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService);
|
||||
}
|
||||
|
||||
protected void unsetIntegrationClientService(IntegrationClientService integrationClientService) {
|
||||
APIPublisherDataHolder.getInstance().setIntegrationClientService(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,25 +22,21 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - API Management Extensions Component</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<modules>
|
||||
<module>org.wso2.carbon.apimgt.integration.generated.client</module>
|
||||
<module>org.wso2.carbon.apimgt.integration.client</module>
|
||||
<module>org.wso2.carbon.apimgt.webapp.publisher</module>
|
||||
<module>org.wso2.carbon.apimgt.application.extension</module>
|
||||
<module>org.wso2.carbon.apimgt.application.extension.api</module>
|
||||
<module>org.wso2.carbon.apimgt.annotations</module>
|
||||
<module>org.wso2.carbon.apimgt.handlers</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
||||
@ -3,13 +3,12 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.application.mgt.addons</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<name>WSO2 Carbon - Application Management Add-Ons</name>
|
||||
<description>WSO2 Carbon - Application Management Add-Ons</description>
|
||||
<url>https://entgra.io</url>
|
||||
|
||||
@ -22,13 +22,12 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.application.mgt.api</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - Application Management API</name>
|
||||
<description>WSO2 Carbon - Application Management API</description>
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -21,13 +21,12 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Application Management Common</name>
|
||||
<description>WSO2 Carbon - Application Management Common</description>
|
||||
@ -56,7 +55,7 @@
|
||||
io.swagger.annotations.*;resolution:=optional,
|
||||
com.fasterxml.jackson.annotation,
|
||||
javax.validation.constraints,
|
||||
javax.xml.bind.annotation.*,
|
||||
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
org.wso2.carbon.device.application.mgt.common.*
|
||||
|
||||
@ -24,7 +24,7 @@ import java.sql.Timestamp;
|
||||
public class DeviceSubscriptionData {
|
||||
|
||||
private String action;
|
||||
private Timestamp actionTriggeredTimestamp;
|
||||
private long actionTriggeredTimestamp;
|
||||
private String actionTriggeredBy;
|
||||
private String actionType;
|
||||
private String status;
|
||||
@ -38,11 +38,11 @@ public class DeviceSubscriptionData {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Timestamp getActionTriggeredTimestamp() {
|
||||
public long getActionTriggeredTimestamp() {
|
||||
return actionTriggeredTimestamp;
|
||||
}
|
||||
|
||||
public void setActionTriggeredTimestamp(Timestamp actionTriggeredTimestamp) {
|
||||
public void setActionTriggeredTimestamp(long actionTriggeredTimestamp) {
|
||||
this.actionTriggeredTimestamp = actionTriggeredTimestamp;
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ public class ScheduledSubscriptionDTO {
|
||||
/**
|
||||
* Scheduled time of subscription.
|
||||
*/
|
||||
private LocalDateTime scheduledAt;
|
||||
private long scheduledAt;
|
||||
|
||||
/**
|
||||
* Username of the scheduler.
|
||||
@ -86,7 +86,7 @@ public class ScheduledSubscriptionDTO {
|
||||
|
||||
}
|
||||
|
||||
public ScheduledSubscriptionDTO(String taskName, String applicationUUID, LocalDateTime scheduledAt,
|
||||
public ScheduledSubscriptionDTO(String taskName, String applicationUUID, long scheduledAt,
|
||||
List<?> subscriberList, String scheduledBy) {
|
||||
this.taskName = taskName;
|
||||
this.applicationUUID = applicationUUID;
|
||||
@ -135,11 +135,11 @@ public class ScheduledSubscriptionDTO {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getScheduledAt() {
|
||||
public long getScheduledAt() {
|
||||
return scheduledAt;
|
||||
}
|
||||
|
||||
public void setScheduledAt(LocalDateTime scheduledAt) {
|
||||
public void setScheduledAt(long scheduledAt) {
|
||||
this.scheduledAt = scheduledAt;
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ import org.wso2.carbon.device.application.mgt.common.dto.ScheduledSubscriptionDT
|
||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.application.mgt.common.exception.SubscriptionManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
|
||||
import java.util.List;
|
||||
@ -127,14 +128,11 @@ public interface SubscriptionManager {
|
||||
* This method used to get the app id ,device ids and pass them to DM service method.
|
||||
*
|
||||
* @param appUUID UUID of the application release.
|
||||
* @param offsetValue offset value for get paginated request.
|
||||
* @param limitValue limit value for get paginated request.
|
||||
* @param status status of the devices.
|
||||
* @param request paginated request object.
|
||||
* @return deviceDetails - device details for given application release.
|
||||
* @throws {@link ApplicationManagementException} Exception of the application management
|
||||
*/
|
||||
PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID,
|
||||
List<String> status) throws ApplicationManagementException;
|
||||
PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID) throws ApplicationManagementException;
|
||||
|
||||
/***
|
||||
* This method used to get category details.
|
||||
@ -152,14 +150,15 @@ public interface SubscriptionManager {
|
||||
/**
|
||||
* This method is responsible to provide application subscription data for given application release UUID.
|
||||
*
|
||||
* @param offsetValue offset
|
||||
* @param limitValue limit
|
||||
* @param request paginated request object.
|
||||
* @param actionStatus status of the operation.
|
||||
* @param action action related to the device.
|
||||
* @param appUUID application release UUID
|
||||
* @return {@link PaginationResult}
|
||||
* @throws ApplicationManagementException if offset or limit contains incorrect values, if it couldn't find an
|
||||
* application release for given UUID, if an error occurred while getting device details of subscribed device ids,
|
||||
* if an error occurred while getting subscription details of given application release UUID.
|
||||
*/
|
||||
PaginationResult getAppSubscriptionDetails(int offsetValue, int limitValue, String appUUID)
|
||||
PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, String action)
|
||||
throws ApplicationManagementException;
|
||||
}
|
||||
|
||||
@ -21,13 +21,12 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.application.mgt.core</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Application Management Core</name>
|
||||
<description>WSO2 Carbon - Application Management Core</description>
|
||||
@ -51,8 +50,8 @@
|
||||
<Bundle-Description>Application Management Core Bundle</Bundle-Description>
|
||||
<Private-Package>org.wso2.carbon.device.application.mgt.core.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.apache.commons.logging,
|
||||
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
|
||||
org.wso2.carbon.context.*,
|
||||
@ -62,8 +61,8 @@
|
||||
javax.sql,
|
||||
com.google.gson.*,
|
||||
javax.naming,
|
||||
javax.xml.bind.annotation,
|
||||
javax.xml.bind,
|
||||
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
|
||||
javax.xml.bind; version="${javax.xml.bind.imp.pkg.version}",
|
||||
org.wso2.carbon.device.application.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.core.*,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
@ -87,8 +86,6 @@
|
||||
org.apache.commons.validator.routines
|
||||
</Import-Package>
|
||||
<Embed-Dependency>apk-parser;scope=compile|runtime;inline=false</Embed-Dependency>
|
||||
<!--<Embed-Transitive>true</Embed-Transitive>-->
|
||||
<!--<Embed-StripGroup>true</Embed-StripGroup>-->
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.application.mgt.core.internal.*,
|
||||
org.wso2.carbon.device.application.mgt.core.*
|
||||
@ -348,6 +345,10 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ public interface SubscriptionDAO {
|
||||
void addGroupSubscriptions(int tenantId, String subscribedBy, List<String> groups, int releaseId, String action)
|
||||
throws ApplicationManagementDAOException;
|
||||
|
||||
List<DeviceSubscriptionDTO> getDeviceSubscriptions(int appReleaseId, int tenantId) throws
|
||||
List<DeviceSubscriptionDTO> getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus, String action) throws
|
||||
ApplicationManagementDAOException;
|
||||
|
||||
Map<Integer, DeviceSubscriptionDTO> getDeviceSubscriptions(List<Integer> deviceIds, int appReleaseId, int tenantId)
|
||||
@ -124,7 +124,7 @@ public interface SubscriptionDAO {
|
||||
* @param scheduledBy username of the user who scheduled the subscription
|
||||
* @throws ApplicationManagementDAOException if error occurred while updating the entry
|
||||
*/
|
||||
boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy)
|
||||
boolean updateScheduledSubscription(int id, long scheduledAt, String scheduledBy)
|
||||
throws ApplicationManagementDAOException;
|
||||
|
||||
/**
|
||||
|
||||
@ -134,7 +134,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
||||
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
||||
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
||||
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
||||
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
||||
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT, "
|
||||
+ "NEW_AP_APP_LIFECYCLE_STATE.UPDATED_AT AS LATEST_UPDATE "
|
||||
+ "FROM AP_APP "
|
||||
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
|
||||
@ -181,7 +182,17 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
||||
if (filter.getLimit() != -1) {
|
||||
sql += "LIMIT ? OFFSET ? ";
|
||||
}
|
||||
sql += ") AS app_data ON app_data.ID = AP_APP.ID WHERE AP_APP.TENANT_ID = ? ORDER BY AP_APP.ID";
|
||||
sql += ") AS app_data ON app_data.ID = AP_APP.ID "
|
||||
+ "INNER JOIN ("
|
||||
+ "SELECT AP_APP_LIFECYCLE_STATE.UPDATED_AT, AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID "
|
||||
+ "FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_LIFECYCLE_STATE.ID "
|
||||
+ "IN(SELECT MAX(AP_APP_LIFECYCLE_STATE.ID) "
|
||||
+ "FROM AP_APP_LIFECYCLE_STATE "
|
||||
+ "GROUP BY AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID)) AS NEW_AP_APP_LIFECYCLE_STATE "
|
||||
+ "ON AP_APP_RELEASE.ID = NEW_AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID "
|
||||
+ "WHERE AP_APP.TENANT_ID = ? "
|
||||
+ "ORDER BY AP_APP.ID, LATEST_UPDATE DESC";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
@ -80,7 +80,8 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
||||
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
||||
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
||||
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
||||
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT, "
|
||||
+ "NEW_AP_APP_LIFECYCLE_STATE.UPDATED_AT AS LATEST_UPDATE "
|
||||
+ "FROM AP_APP "
|
||||
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
|
||||
@ -125,7 +126,17 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
if (filter.getLimit() != -1) {
|
||||
sql += "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ";
|
||||
}
|
||||
sql += ") AS app_data ON app_data.ID = AP_APP.ID WHERE AP_APP.TENANT_ID = ? ORDER BY AP_APP.ID";
|
||||
sql += ") AS app_data ON app_data.ID = AP_APP.ID "
|
||||
+ "INNER JOIN ("
|
||||
+ "SELECT AP_APP_LIFECYCLE_STATE.UPDATED_AT, AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID "
|
||||
+ "FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_LIFECYCLE_STATE.ID "
|
||||
+ "IN(SELECT MAX(AP_APP_LIFECYCLE_STATE.ID) "
|
||||
+ "FROM AP_APP_LIFECYCLE_STATE "
|
||||
+ "GROUP BY AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID)) AS NEW_AP_APP_LIFECYCLE_STATE "
|
||||
+ "ON AP_APP_RELEASE.ID = NEW_AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID "
|
||||
+ "WHERE AP_APP.TENANT_ID = ? "
|
||||
+ "ORDER BY AP_APP.ID, LATEST_UPDATE DESC";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
@ -79,7 +79,8 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
||||
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
||||
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
||||
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
||||
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT, "
|
||||
+ "NEW_AP_APP_LIFECYCLE_STATE.UPDATED_AT AS LATEST_UPDATE "
|
||||
+ "FROM AP_APP "
|
||||
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
|
||||
@ -124,7 +125,17 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
|
||||
if (filter.getLimit() != -1) {
|
||||
sql += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ";
|
||||
}
|
||||
sql += ") AS app_data ON app_data.ID = AP_APP.ID WHERE AP_APP.TENANT_ID = ? ORDER BY AP_APP.ID";
|
||||
sql += ") AS app_data ON app_data.ID = AP_APP.ID "
|
||||
+ "INNER JOIN ("
|
||||
+ "SELECT AP_APP_LIFECYCLE_STATE.UPDATED_AT, AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID "
|
||||
+ "FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_LIFECYCLE_STATE.ID "
|
||||
+ "IN(SELECT MAX(AP_APP_LIFECYCLE_STATE.ID) "
|
||||
+ "FROM AP_APP_LIFECYCLE_STATE "
|
||||
+ "GROUP BY AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID)) AS NEW_AP_APP_LIFECYCLE_STATE "
|
||||
+ "ON AP_APP_RELEASE.ID = NEW_AP_APP_LIFECYCLE_STATE.AP_APP_RELEASE_ID "
|
||||
+ "WHERE AP_APP.TENANT_ID = ? "
|
||||
+ "ORDER BY AP_APP.ID, LATEST_UPDATE DESC";
|
||||
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
|
||||
@ -332,12 +332,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceSubscriptionDTO> getDeviceSubscriptions(int appReleaseId, int tenantId) throws
|
||||
public List<DeviceSubscriptionDTO> getDeviceSubscriptions(int appReleaseId, int tenantId, String actionStatus, String action) throws
|
||||
ApplicationManagementDAOException {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Getting device subscriptions for the application release id " + appReleaseId
|
||||
+ " from the database");
|
||||
}
|
||||
boolean isActionStatusProvided = false;
|
||||
boolean isActionProvided = false;
|
||||
int index = 1;
|
||||
String sql = "SELECT "
|
||||
+ "DS.ID AS ID, "
|
||||
+ "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, "
|
||||
@ -350,11 +353,30 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
||||
+ "DS.DM_DEVICE_ID AS DEVICE_ID "
|
||||
+ "FROM AP_DEVICE_SUBSCRIPTION DS "
|
||||
+ "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.TENANT_ID=?";
|
||||
|
||||
if (actionStatus != null && !actionStatus.isEmpty()) {
|
||||
sql += " AND DS.STATUS= ?";
|
||||
isActionStatusProvided = true;
|
||||
}
|
||||
if (action != null && !action.isEmpty()) {
|
||||
sql += " AND DS.UNSUBSCRIBED= ?";
|
||||
isActionProvided = true;
|
||||
}
|
||||
try {
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
stmt.setInt(1, appReleaseId);
|
||||
stmt.setInt(2, tenantId);
|
||||
stmt.setInt(index++, appReleaseId);
|
||||
stmt.setInt(index++, tenantId);
|
||||
if (isActionStatusProvided) {
|
||||
stmt.setString(index++, actionStatus);
|
||||
}
|
||||
if (isActionProvided) {
|
||||
if (action.equals("SUBSCRIBED")) {
|
||||
stmt.setString(index, "FALSE");
|
||||
} else {
|
||||
stmt.setString(index, "TRUE");
|
||||
}
|
||||
}
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Successfully retrieved device subscriptions for application release id "
|
||||
@ -765,7 +787,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
||||
stmt.setString(2, subscriptionDTO.getApplicationUUID());
|
||||
stmt.setString(3, subscriptionDTO.getSubscribersString());
|
||||
stmt.setString(4, ExecutionStatus.PENDING.toString());
|
||||
stmt.setTimestamp(5, Timestamp.valueOf(subscriptionDTO.getScheduledAt()));
|
||||
stmt.setLong(5, subscriptionDTO.getScheduledAt());
|
||||
stmt.setTimestamp(6, new Timestamp(calendar.getTime().getTime()));
|
||||
stmt.setString(7, subscriptionDTO.getScheduledBy());
|
||||
stmt.setBoolean(8, false);
|
||||
@ -785,7 +807,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy)
|
||||
public boolean updateScheduledSubscription(int id, long scheduledAt, String scheduledBy)
|
||||
throws ApplicationManagementDAOException {
|
||||
String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION "
|
||||
+ "SET "
|
||||
@ -797,7 +819,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
||||
Connection conn = this.getDBConnection();
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
stmt.setTimestamp(1, Timestamp.valueOf(scheduledAt));
|
||||
stmt.setLong(1, scheduledAt);
|
||||
stmt.setString(2, scheduledBy);
|
||||
stmt.setTimestamp(3, new Timestamp(calendar.getTime().getTime()));
|
||||
stmt.setInt(4, id);
|
||||
@ -1037,7 +1059,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
stmt.setString(1, ExecutionStatus.PENDING.toString());
|
||||
stmt.setBoolean(2, false);
|
||||
stmt.setTimestamp(3, new Timestamp(Calendar.getInstance().getTime().getTime()));
|
||||
stmt.setLong(3, Calendar.getInstance().getTime().getTime() / 1000);
|
||||
try (ResultSet rs = stmt.executeQuery()) {
|
||||
return DAOUtil.loadScheduledSubscriptions(rs);
|
||||
}
|
||||
|
||||
@ -1445,7 +1445,7 @@ ApplicationManagerImpl implements ApplicationManager {
|
||||
log.error(msg);
|
||||
throw new ForbiddenException(msg);
|
||||
}
|
||||
if (!subscriptionDAO.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId).isEmpty()) {
|
||||
if (!subscriptionDAO.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null, null).isEmpty()) {
|
||||
String msg = "Application release which has UUID: " + applicationReleaseDTO.getUuid()
|
||||
+ " either subscribed to device/s or it had subscribed to device/s. Therefore you are not "
|
||||
+ "permitted to delete the application release.";
|
||||
@ -1580,7 +1580,7 @@ ApplicationManagerImpl implements ApplicationManager {
|
||||
try {
|
||||
ConnectionManagerUtil.beginDBTransaction();
|
||||
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS = subscriptionDAO
|
||||
.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId);
|
||||
.getDeviceSubscriptions(applicationReleaseDTO.getId(), tenantId, null, null);
|
||||
if (!deviceSubscriptionDTOS.isEmpty()) {
|
||||
String msg = "Application release which has UUID: " + applicationReleaseDTO.getUuid()
|
||||
+ " either subscribed to device/s or it had subscribed to device/s. Therefore you "
|
||||
|
||||
@ -65,10 +65,7 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
|
||||
import org.wso2.carbon.device.application.mgt.core.util.Constants;
|
||||
import org.wso2.carbon.device.application.mgt.core.util.HelperUtil;
|
||||
import org.wso2.carbon.device.application.mgt.core.util.OAuthUtils;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.MDMAppConstants;
|
||||
import org.wso2.carbon.device.mgt.common.*;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.App;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.MobileAppTypes;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.android.CustomApplication;
|
||||
@ -88,7 +85,6 @@ import org.wso2.carbon.device.mgt.core.util.MDMIOSOperationUtil;
|
||||
import org.wso2.carbon.device.mgt.core.util.MDMWindowsOperationUtil;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.BufferedReader;
|
||||
@ -381,7 +377,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
if (applicationDTO != null) {
|
||||
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS = this.subscriptionDAO
|
||||
.getDeviceSubscriptions(applicationDTO.getApplicationReleaseDTOs().get(0).getId(),
|
||||
tenantId);
|
||||
tenantId, null, null);
|
||||
|
||||
AtomicBoolean isAppSubscribable = new AtomicBoolean(true);
|
||||
for (DeviceSubscriptionDTO deviceSubscriptionDTO : deviceSubscriptionDTOS) {
|
||||
@ -1223,7 +1219,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getAppInstalledDevices(int offsetValue, int limitValue, String appUUID, List<String> status)
|
||||
public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID)
|
||||
throws ApplicationManagementException {
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
||||
@ -1235,7 +1231,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId();
|
||||
|
||||
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS = subscriptionDAO
|
||||
.getDeviceSubscriptions(applicationReleaseId, tenantId);
|
||||
.getDeviceSubscriptions(applicationReleaseId, tenantId, null, null);
|
||||
if (deviceSubscriptionDTOS.isEmpty()) {
|
||||
PaginationResult paginationResult = new PaginationResult();
|
||||
paginationResult.setData(new ArrayList<>());
|
||||
@ -1262,8 +1258,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
}
|
||||
//pass the device id list to device manager service method
|
||||
try {
|
||||
PaginationResult deviceDetails = deviceManagementProviderService
|
||||
.getAppSubscribedDevices(offsetValue, limitValue, deviceIdList, status);
|
||||
PaginationResult deviceDetails = deviceManagementProviderService.getAppSubscribedDevices
|
||||
(request, deviceIdList);
|
||||
|
||||
if (deviceDetails == null) {
|
||||
String msg = "Couldn't found an subscribed devices details for device ids: " + deviceIdList;
|
||||
@ -1342,8 +1338,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaginationResult getAppSubscriptionDetails(int offsetValue, int limitValue, String appUUID)
|
||||
throws ApplicationManagementException {
|
||||
public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus,
|
||||
String action) throws ApplicationManagementException {
|
||||
int limitValue = request.getRowCount();
|
||||
int offsetValue = request.getStartIndex();
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
||||
.getDeviceManagementProviderService();
|
||||
@ -1365,7 +1363,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId();
|
||||
|
||||
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS = subscriptionDAO
|
||||
.getDeviceSubscriptions(applicationReleaseId, tenantId);
|
||||
.getDeviceSubscriptions(applicationReleaseId, tenantId, actionStatus, action);
|
||||
if (deviceSubscriptionDTOS.isEmpty()) {
|
||||
PaginationResult paginationResult = new PaginationResult();
|
||||
paginationResult.setData(new ArrayList<>());
|
||||
@ -1377,8 +1375,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
.collect(Collectors.toList());
|
||||
try {
|
||||
//pass the device id list to device manager service method
|
||||
PaginationResult paginationResult = deviceManagementProviderService
|
||||
.getAppSubscribedDevices(offsetValue, limitValue, deviceIdList, null);
|
||||
PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices
|
||||
(request, deviceIdList);
|
||||
List<DeviceSubscriptionData> deviceSubscriptionDataList = new ArrayList<>();
|
||||
|
||||
if (!paginationResult.getData().isEmpty()) {
|
||||
@ -1392,12 +1390,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
||||
deviceSubscriptionData.setAction(Constants.UNSUBSCRIBED);
|
||||
deviceSubscriptionData.setActionTriggeredBy(subscription.getUnsubscribedBy());
|
||||
deviceSubscriptionData
|
||||
.setActionTriggeredTimestamp(subscription.getUnsubscribedTimestamp());
|
||||
.setActionTriggeredTimestamp(subscription.getUnsubscribedTimestamp().getTime() / 1000);
|
||||
} else {
|
||||
deviceSubscriptionData.setAction(Constants.SUBSCRIBED);
|
||||
deviceSubscriptionData.setActionTriggeredBy(subscription.getSubscribedBy());
|
||||
deviceSubscriptionData
|
||||
.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp());
|
||||
.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp().getTime() / 1000);
|
||||
}
|
||||
deviceSubscriptionData.setActionType(subscription.getActionTriggeredFrom());
|
||||
deviceSubscriptionData.setStatus(subscription.getStatus());
|
||||
|
||||
@ -40,7 +40,7 @@ public class ScheduledAppSubscriptionCleanupTask extends RandomlyAssignedSchedul
|
||||
@Override
|
||||
public void executeRandomlyAssignedTask() {
|
||||
try {
|
||||
if(super.isQualifiedToExecuteTask()) {
|
||||
if(isQualifiedToExecuteTask()) {
|
||||
subscriptionManager.cleanScheduledSubscriptions();
|
||||
}
|
||||
} catch (SubscriptionManagementException e) {
|
||||
|
||||
@ -68,7 +68,7 @@ public class ScheduledAppSubscriptionTask extends RandomlyAssignedScheduleTask {
|
||||
|
||||
@Override
|
||||
public void executeRandomlyAssignedTask() {
|
||||
if(super.isQualifiedToExecuteTask()) {
|
||||
if(isQualifiedToExecuteTask()) {
|
||||
try {
|
||||
ScheduledSubscriptionDTO subscriptionDTO = subscriptionManager.getPendingScheduledSubscription(
|
||||
this.taskName);
|
||||
|
||||
@ -40,6 +40,8 @@ import org.wso2.carbon.ntask.core.service.TaskService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -64,24 +66,27 @@ public class ScheduledAppSubscriptionTaskManager {
|
||||
* either {@link org.wso2.carbon.device.mgt.common.DeviceIdentifier} if {@param subType} is
|
||||
* equal to DEVICE or {@link String} if {@param subType} is USER, ROLE or GROUP
|
||||
* @param subscriptionType subscription type. E.g. <code>DEVICE, USER, ROLE, GROUP</code>
|
||||
* {@see {@link org.wso2.carbon.device.application.mgt.common.SubscriptionType}}
|
||||
* {@see {@link SubscriptionType}}
|
||||
* @param action action subscription action. E.g. {@code INSTALL/UNINSTALL}
|
||||
* {@see {@link org.wso2.carbon.device.application.mgt.common.SubAction}}
|
||||
* {@see {@link SubAction}}
|
||||
* @param timestamp timestamp to schedule the application subscription
|
||||
* @throws ApplicationOperationTaskException if error occurred while scheduling the subscription
|
||||
*/
|
||||
public void scheduleAppSubscriptionTask(String applicationUUID, List<?> subscribers,
|
||||
SubscriptionType subscriptionType, SubAction action, LocalDateTime timestamp)
|
||||
SubscriptionType subscriptionType, SubAction action, long timestamp)
|
||||
throws ApplicationOperationTaskException {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date(timestamp * 1000));
|
||||
String space = " ";
|
||||
String cronExpression =
|
||||
String.valueOf(timestamp.getSecond()) + space + timestamp.getMinute() + space + timestamp.getHour()
|
||||
+ space + timestamp.getDayOfMonth() + space + timestamp.getMonth().getDisplayName(TextStyle.SHORT,
|
||||
Locale.getDefault()).toUpperCase() + " ? " + timestamp.getYear();
|
||||
calendar.get(Calendar.SECOND) + space + calendar.get(Calendar.MINUTE) + space
|
||||
+ calendar.get(Calendar.HOUR_OF_DAY) + space + calendar.get(Calendar.DAY_OF_MONTH) + space
|
||||
+ calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault()).toUpperCase() + " ? "
|
||||
+ calendar.get(Calendar.YEAR);
|
||||
|
||||
if (!CronExpression.isValidExpression(cronExpression)) {
|
||||
String msg = "The cron expression [" + cronExpression + "] generated by the" + " timestamp [" + timestamp
|
||||
.toString() + "] is invalid";
|
||||
+ "] is invalid";
|
||||
log.error(msg);
|
||||
throw new ApplicationOperationTaskException(msg);
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ public class DAOUtil {
|
||||
}
|
||||
|
||||
subscription.setStatus(ExecutionStatus.valueOf(rs.getString("STATUS")));
|
||||
subscription.setScheduledAt(rs.getTimestamp("SCHEDULED_AT").toLocalDateTime());
|
||||
subscription.setScheduledAt(rs.getLong("SCHEDULED_AT"));
|
||||
subscription.setScheduledBy(rs.getString("SCHEDULED_BY"));
|
||||
subscription.setDeleted(rs.getBoolean("DELETED"));
|
||||
subscriptionDTOS.add(subscription);
|
||||
|
||||
@ -63,7 +63,7 @@ public class OAuthUtils {
|
||||
apiApplicationKeyInfo = apiManagementProviderService.
|
||||
generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(),
|
||||
registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE,
|
||||
registrationProfile.getApplicationName(), registrationProfile.isAllowedToAllDomains(),
|
||||
null, registrationProfile.isAllowedToAllDomains(),
|
||||
Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD);
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
|
||||
@ -22,13 +22,12 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.application.mgt.publisher.api</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - Application Management Publisher API</name>
|
||||
<description>WSO2 Carbon - Application Management Publisher API</description>
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -22,13 +22,12 @@
|
||||
<parent>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.application.mgt.store.api</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - Application Management Store API</name>
|
||||
<description>WSO2 Carbon - Application Management Store API</description>
|
||||
|
||||
@ -32,6 +32,7 @@ import org.wso2.carbon.device.application.mgt.common.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.Produces;
|
||||
@ -129,7 +130,7 @@ public interface SubscriptionManagementAPI {
|
||||
name = "timestamp",
|
||||
value = "Timestamp of scheduled install/uninstall operation"
|
||||
)
|
||||
@QueryParam("timestamp") String timestamp
|
||||
@QueryParam("timestamp") long timestamp
|
||||
);
|
||||
|
||||
@POST
|
||||
@ -182,7 +183,7 @@ public interface SubscriptionManagementAPI {
|
||||
name = "timestamp",
|
||||
value = "Timestamp of scheduled install/uninstall operation"
|
||||
)
|
||||
@QueryParam("timestamp") String timestamp
|
||||
@QueryParam("timestamp") long timestamp
|
||||
);
|
||||
|
||||
@POST
|
||||
@ -229,7 +230,7 @@ public interface SubscriptionManagementAPI {
|
||||
name = "timestamp",
|
||||
value = "Timestamp of scheduled ent. install operation"
|
||||
)
|
||||
@QueryParam("timestamp") String timestamp,
|
||||
@QueryParam("timestamp") long timestamp,
|
||||
@ApiParam(
|
||||
name = "requiresUpdatingExternal",
|
||||
value = "Should external system such as Google EMM APIs need to be updated."
|
||||
@ -287,7 +288,7 @@ public interface SubscriptionManagementAPI {
|
||||
name = "timestamp",
|
||||
value = "Timestamp of scheduled ent app install operation"
|
||||
)
|
||||
@QueryParam("timestamp") String timestamp,
|
||||
@QueryParam("timestamp") long timestamp,
|
||||
@ApiParam(
|
||||
name = "requiresUpdatingExternal",
|
||||
value = "Should external system such as Google EMM APIs need to be updated."
|
||||
@ -337,6 +338,28 @@ public interface SubscriptionManagementAPI {
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response getAppInstalledDevices(
|
||||
@ApiParam(
|
||||
name = "name",
|
||||
value = "The device name. For example, Nexus devices can have names, suhc as shamu, bullhead or angler.",
|
||||
required = false)
|
||||
@Size(max = 45)
|
||||
String name,
|
||||
@ApiParam(
|
||||
name = "user",
|
||||
value = "The username of the owner of the device.",
|
||||
required = false)
|
||||
@QueryParam("user")
|
||||
String user,
|
||||
@ApiParam(
|
||||
name = "ownership",
|
||||
allowableValues = "BYOD, COPE",
|
||||
value = "Provide the ownership status of the device. The following values can be assigned:\n" +
|
||||
"- BYOD: Bring Your Own Device\n" +
|
||||
"- COPE: Corporate-Owned, Personally-Enabled",
|
||||
required = false)
|
||||
@QueryParam("ownership")
|
||||
@Size(max = 45)
|
||||
String ownership,
|
||||
@ApiParam(
|
||||
name="uuid",
|
||||
value="uuid of the application release.",
|
||||
|
||||
@ -31,6 +31,7 @@ import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||
import org.wso2.carbon.device.application.mgt.common.ErrorResponse;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
@ -111,6 +112,32 @@ public interface SubscriptionManagementAdminAPI {
|
||||
response = ErrorResponse.class)
|
||||
})
|
||||
Response getAppInstalledDevices(
|
||||
@ApiParam(
|
||||
name = "name",
|
||||
value = "The device name. For example, Nexus devices can have names, suhc as shamu, bullhead or angler.",
|
||||
required = false)
|
||||
@Size(max = 45)
|
||||
String name,
|
||||
@ApiParam(
|
||||
name = "user",
|
||||
value = "The username of the owner of the device.",
|
||||
required = false)
|
||||
@QueryParam("user")
|
||||
String user,
|
||||
@ApiParam(
|
||||
name = "action",
|
||||
value = "The action, subscribed or unsubscribed.",
|
||||
required = false)
|
||||
@Size(max = 45)
|
||||
@QueryParam("action") String action,
|
||||
@ApiParam(
|
||||
name = "actionStatus",
|
||||
value = "Provide the action status details")
|
||||
@QueryParam("actionStatus") String actionStatus,
|
||||
@ApiParam(
|
||||
name = "status",
|
||||
value = "Provide the device status details, such as active or inactive.")
|
||||
@QueryParam("status") List<String> status,
|
||||
@ApiParam(
|
||||
name = "uuid",
|
||||
value = "uuid of the application release.",
|
||||
|
||||
@ -33,6 +33,8 @@ import org.wso2.carbon.device.application.mgt.common.BasicUserInfo;
|
||||
import org.wso2.carbon.device.application.mgt.common.BasicUserInfoList;
|
||||
import org.wso2.carbon.device.application.mgt.common.RoleList;
|
||||
import org.wso2.carbon.device.application.mgt.common.DeviceGroupList;
|
||||
import org.wso2.carbon.device.application.mgt.store.api.services.impl.util.RequestValidationUtil;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
||||
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
|
||||
@ -73,9 +75,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
@PathParam("uuid") String uuid,
|
||||
@PathParam("action") String action,
|
||||
@Valid List<DeviceIdentifier> deviceIdentifiers,
|
||||
@QueryParam("timestamp") String timestamp) {
|
||||
@QueryParam("timestamp") long timestamp) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(timestamp)) {
|
||||
if (0 == timestamp) {
|
||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||
ApplicationInstallResponse response = subscriptionManager
|
||||
.performBulkAppOperation(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(), action);
|
||||
@ -114,9 +116,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
@PathParam("subType") String subType,
|
||||
@PathParam("action") String action,
|
||||
@Valid List<String> subscribers,
|
||||
@QueryParam("timestamp") String timestamp) {
|
||||
@QueryParam("timestamp") long timestamp) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(timestamp)) {
|
||||
if (0 == timestamp) {
|
||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||
ApplicationInstallResponse response = subscriptionManager
|
||||
.performBulkAppOperation(uuid, subscribers, subType, action);
|
||||
@ -155,10 +157,10 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
@PathParam("uuid") String uuid,
|
||||
@PathParam("action") String action,
|
||||
@Valid List<DeviceIdentifier> deviceIdentifiers,
|
||||
@QueryParam("timestamp") String timestamp,
|
||||
@QueryParam("timestamp") long timestamp,
|
||||
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(timestamp)) {
|
||||
if (0 == timestamp) {
|
||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||
subscriptionManager
|
||||
.performEntAppSubscription(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(),
|
||||
@ -202,10 +204,10 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
@PathParam("subType") String subType,
|
||||
@PathParam("action") String action,
|
||||
@Valid List<String> subscribers,
|
||||
@QueryParam("timestamp") String timestamp,
|
||||
@QueryParam("timestamp") long timestamp,
|
||||
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) {
|
||||
try {
|
||||
if (StringUtils.isEmpty(timestamp)) {
|
||||
if (0 == timestamp) {
|
||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||
subscriptionManager.performEntAppSubscription(uuid, subscribers, subType, action, requiresUpdatingExternal);
|
||||
String msg = "Application release which has UUID " + uuid + " is installed to subscriber's valid device"
|
||||
@ -253,11 +255,11 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
* @return {@link Response} of the operation
|
||||
*/
|
||||
private Response scheduleApplicationOperationTask(String applicationUUID, List<?> subscribers,
|
||||
SubscriptionType subType, SubAction subAction, String timestamp) {
|
||||
SubscriptionType subType, SubAction subAction, long timestamp) {
|
||||
try {
|
||||
ScheduledAppSubscriptionTaskManager subscriptionTaskManager = new ScheduledAppSubscriptionTaskManager();
|
||||
subscriptionTaskManager.scheduleAppSubscriptionTask(applicationUUID, subscribers, subType, subAction,
|
||||
LocalDateTime.parse(timestamp, DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||||
timestamp);
|
||||
} catch (ApplicationOperationTaskException e) {
|
||||
String msg = "Error occurred while scheduling the application install operation";
|
||||
log.error(msg, e);
|
||||
@ -273,6 +275,9 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
@Produces("application/json")
|
||||
@Path("/{uuid}/devices")
|
||||
public Response getAppInstalledDevices(
|
||||
@QueryParam("name") String name,
|
||||
@QueryParam("user") String user,
|
||||
@QueryParam("ownership") String ownership,
|
||||
@PathParam("uuid") String uuid,
|
||||
@DefaultValue("0")
|
||||
@QueryParam("offset") int offset,
|
||||
@ -281,8 +286,31 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
@QueryParam("status") List<String> status) {
|
||||
try {
|
||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||
PaginationResult subscribedDeviceDetails = subscriptionManager
|
||||
.getAppInstalledDevices(offset, limit, uuid, status);
|
||||
PaginationRequest request = new PaginationRequest(offset, limit);
|
||||
if (name != null && !name.isEmpty()) {
|
||||
request.setDeviceName(name);
|
||||
}
|
||||
if (user != null && !user.isEmpty()) {
|
||||
request.setOwner(user);
|
||||
}
|
||||
if (ownership != null && !ownership.isEmpty()) {
|
||||
RequestValidationUtil.validateOwnershipType(ownership);
|
||||
request.setOwnership(ownership);
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
boolean isStatusEmpty = true;
|
||||
for (String statusString : status) {
|
||||
if (StringUtils.isNotBlank(statusString)) {
|
||||
isStatusEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isStatusEmpty) {
|
||||
RequestValidationUtil.validateStatus(status);
|
||||
request.setStatusList(status);
|
||||
}
|
||||
}
|
||||
PaginationResult subscribedDeviceDetails = subscriptionManager.getAppInstalledDevices(request, uuid);
|
||||
DeviceList devices = new DeviceList();
|
||||
devices.setList((List<Device>) subscribedDeviceDetails.getData());
|
||||
devices.setCount(subscribedDeviceDetails.getRecordsTotal());
|
||||
@ -292,8 +320,7 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||
} catch (BadRequestException e) {
|
||||
String msg = "Found invalid payload for getting application which has UUID: " + uuid
|
||||
+ ". Hence verify the payload";
|
||||
String msg = "User requested details are not valid";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
} catch (ForbiddenException e) {
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
package org.wso2.carbon.device.application.mgt.store.api.services.impl.admin;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||
@ -26,6 +27,8 @@ import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException
|
||||
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
|
||||
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
||||
import org.wso2.carbon.device.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI;
|
||||
import org.wso2.carbon.device.application.mgt.store.api.services.impl.util.RequestValidationUtil;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
@ -36,6 +39,7 @@ import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of Subscription Management related APIs.
|
||||
@ -51,6 +55,11 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
|
||||
@Produces("application/json")
|
||||
@Path("/{uuid}")
|
||||
public Response getAppInstalledDevices(
|
||||
@QueryParam("name") String name,
|
||||
@QueryParam("user") String user,
|
||||
@QueryParam("action") String action,
|
||||
@QueryParam("actionStatus") String actionStatus,
|
||||
@QueryParam("status") List<String> status,
|
||||
@PathParam("uuid") String uuid,
|
||||
@DefaultValue("0")
|
||||
@QueryParam("offset") int offset,
|
||||
@ -58,17 +67,44 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
|
||||
@QueryParam("limit") int limit) {
|
||||
|
||||
try {
|
||||
PaginationRequest request = new PaginationRequest(offset, limit);
|
||||
if (name != null && !name.isEmpty()) {
|
||||
request.setDeviceName(name);
|
||||
}
|
||||
if (user != null && !user.isEmpty()) {
|
||||
request.setOwner(user);
|
||||
}
|
||||
if (action != null && !action.isEmpty()) {
|
||||
RequestValidationUtil.validateAction(action);
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
boolean isStatusEmpty = true;
|
||||
for (String statusString : status) {
|
||||
if (StringUtils.isNotBlank(statusString)) {
|
||||
isStatusEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isStatusEmpty) {
|
||||
RequestValidationUtil.validateStatus(status);
|
||||
request.setStatusList(status);
|
||||
}
|
||||
}
|
||||
if (actionStatus != null && !actionStatus.isEmpty()) {
|
||||
if (StringUtils.isNotBlank(actionStatus)) {
|
||||
RequestValidationUtil.validateStatusFiltering(actionStatus);
|
||||
}
|
||||
}
|
||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||
PaginationResult subscriptionData = subscriptionManager
|
||||
.getAppSubscriptionDetails(offset, limit, uuid);
|
||||
PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails
|
||||
(request, uuid, actionStatus, action);
|
||||
return Response.status(Response.Status.OK).entity(subscriptionData).build();
|
||||
} catch (NotFoundException e) {
|
||||
String msg = "Application with application release UUID: " + uuid + " is not found";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||
} catch (BadRequestException e) {
|
||||
String msg = "Found invalid payload for getting application which has UUID: " + uuid
|
||||
+ ". Hence verify the payload";
|
||||
String msg = "User requested details are not valid";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
} catch (ApplicationManagementException e) {
|
||||
|
||||
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.device.application.mgt.store.api.services.impl.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
|
||||
import org.wso2.carbon.device.application.mgt.store.api.util.Constants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequestValidationUtil {
|
||||
|
||||
private static final Log log = LogFactory.getLog(RequestValidationUtil.class);
|
||||
|
||||
/**
|
||||
* Checks if user requested status codes are valid.
|
||||
*
|
||||
* @param statusList status codes upon to filter operation logs using status
|
||||
*/
|
||||
public static void validateStatus(List<String> statusList) throws BadRequestException {
|
||||
for (String status : statusList) {
|
||||
switch (status) {
|
||||
case "ACTIVE":
|
||||
case "INACTIVE":
|
||||
case "UNCLAIMED":
|
||||
case "UNREACHABLE":
|
||||
case "SUSPENDED":
|
||||
case "DISENROLLMENT_REQUESTED":
|
||||
case "REMOVED":
|
||||
case "BLOCKED":
|
||||
case "CREATED":
|
||||
break;
|
||||
default:
|
||||
String msg = "Invalid enrollment status type: " + status + ". \nValid status types " +
|
||||
"are ACTIVE | INACTIVE | UNCLAIMED | UNREACHABLE | SUSPENDED | " +
|
||||
"DISENROLLMENT_REQUESTED | REMOVED | BLOCKED | CREATED";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user requested action is valid.
|
||||
*
|
||||
* @param action action upon to filter devices using action
|
||||
*/
|
||||
public static void validateAction(String action) throws BadRequestException {
|
||||
if (action.equals("SUBSCRIBED") || action.equals("UNSUBSCRIBED")) {
|
||||
} else {
|
||||
String msg = "Invalid action type received.Valid action types are SUBSCRIBED | UNSUBSCRIBED";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user requested ownerships are valid.
|
||||
*
|
||||
* @param ownership ownerships upon to filter devices using ownership
|
||||
*/
|
||||
public static void validateOwnershipType(String ownership) throws BadRequestException {
|
||||
switch (ownership) {
|
||||
case "BYOD":
|
||||
case "COPE":
|
||||
case "WORK_PROFILE":
|
||||
case "GOOGLE_ENTERPRISE":
|
||||
case "COSU":
|
||||
case "FULLY_MANAGED":
|
||||
case "DEDICATED_DEVICE":
|
||||
break;
|
||||
default:
|
||||
String msg = "Invalid ownership type received.Valid ownership types are BYOD | COPE | WORK_PROFILE |" +
|
||||
"GOOGLE_ENTERPRISE | COSU | FULLY_MANAGED | DEDICATED_DEVICE";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user requested Action status codes are valid.
|
||||
*
|
||||
* @param status status codes upon to filter operation logs using status
|
||||
*/
|
||||
public static void validateStatusFiltering(String status) throws BadRequestException {
|
||||
if (Constants.OperationStatus.COMPLETED.toUpperCase().equals(status)
|
||||
|| Constants.OperationStatus.ERROR.toUpperCase().equals(status)
|
||||
|| Constants.OperationStatus.NOTNOW.toUpperCase().equals(status)
|
||||
|| Constants.OperationStatus.REPEATED.toUpperCase().equals(status)
|
||||
|| Constants.OperationStatus.PENDING.toUpperCase().equals(status)
|
||||
|| Constants.OperationStatus.IN_PROGRESS.toUpperCase().equals(status)) {
|
||||
} else {
|
||||
String msg = "Invalid status type: " + status + ". \nValid status types are COMPLETED | ERROR | " +
|
||||
"IN_PROGRESS | NOTNOW | PENDING | REPEATED";
|
||||
log.error(msg);
|
||||
throw new BadRequestException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.application.mgt.store.api.util;
|
||||
|
||||
/**
|
||||
* Holds the constants used by DeviceImpl Management Admin web application.
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final String USER_CLAIM_EMAIL_ADDRESS = "http://wso2.org/claims/emailaddress";
|
||||
public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname";
|
||||
public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname";
|
||||
public static final String USER_CLAIM_CREATED = "http://wso2.org/claims/created";
|
||||
public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified";
|
||||
public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices";
|
||||
public static final String PRIMARY_USER_STORE = "PRIMARY";
|
||||
public static final String DEFAULT_STREAM_VERSION = "1.0.0";
|
||||
public static final String SCOPE = "scope";
|
||||
public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager";
|
||||
public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||
public static final int DEFAULT_PAGE_LIMIT = 50;
|
||||
public static final String FORWARD_SLASH = "/";
|
||||
public static final String ANDROID = "android";
|
||||
public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.platform.android." +
|
||||
"core.polcy.AndroidPolicyPayloadValidator";
|
||||
public static final String IOS = "ios";
|
||||
public static final String WINDOWS = "windows";
|
||||
|
||||
|
||||
public final class OperationStatus {
|
||||
private OperationStatus () { throw new AssertionError(); }
|
||||
public static final String COMPLETED = "completed";
|
||||
public static final String ERROR = "error";
|
||||
public static final String IN_PROGRESS = "in_progress";
|
||||
public static final String PENDING = "pending";
|
||||
public static final String NOTNOW = "notnow";
|
||||
public static final String REPEATED = "repeated";
|
||||
}
|
||||
public static final String DEVICES = "devices";
|
||||
public static final String ATTRIBUTE_DISPLAY_NAME = "DisplayName";
|
||||
public static final String ATTRIBUTE_DESCRIPTION = "Description";
|
||||
public static final String EXTERNAL_DEVICE_CLAIM_DISPLAY_NAME = "Devices";
|
||||
public static final String EXTERNAL_DEVICE_CLAIM_DESCRIPTION = "Device list";
|
||||
|
||||
public final class ErrorMessages {
|
||||
private ErrorMessages () { throw new AssertionError(); }
|
||||
|
||||
public static final String STATUS_BAD_REQUEST_MESSAGE_DEFAULT = "Bad Request";
|
||||
|
||||
}
|
||||
|
||||
public final class DeviceConstants {
|
||||
private DeviceConstants () { throw new AssertionError(); }
|
||||
|
||||
public static final String APPLICATION_JSON = "application/json";
|
||||
public static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||
}
|
||||
|
||||
public final class Permission {
|
||||
private Permission() { throw new AssertionError(); }
|
||||
|
||||
public static final String ADMIN = "/permission/admin";
|
||||
public static final String LOGIN = "/permission/admin/login";
|
||||
public static final String DEVICE_MGT = "/permission/admin/device-mgt";
|
||||
public static final String APP_MGT = "/permission/admin/app-mgt";
|
||||
}
|
||||
|
||||
}
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -22,13 +22,12 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>application-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - Application Management Component</name>
|
||||
<description>WSO2 Carbon - Application Management Component</description>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -134,9 +134,16 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<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>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec.wso2</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
@ -147,24 +154,11 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
@ -207,11 +201,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -133,9 +133,15 @@
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<artifactId>cxf-bundle-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec.wso2</groupId>
|
||||
@ -147,14 +153,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@ -204,11 +202,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -38,13 +38,12 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 Carbon - Certificate Management Core</name>
|
||||
<description>WSO2 Carbon - Certificate Management Core</description>
|
||||
@ -72,8 +71,8 @@
|
||||
org.wso2.carbon.certificate.mgt.core.util
|
||||
</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
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.collections.map,
|
||||
javax.security.auth.x500,
|
||||
|
||||
@ -22,14 +22,13 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>certificate-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 Carbon - Certificate Management Component</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -140,8 +140,8 @@
|
||||
org.apache.axis2.deployment.*,
|
||||
org.apache.commons.lang;version="${commons-lang.wso2.osgi.version.range}",
|
||||
org.apache.commons.logging,
|
||||
org.osgi.framework,
|
||||
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.wso2.carbon.context,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -82,8 +82,8 @@
|
||||
org.wso2.carbon.device.mgt.extensions.pull.notification.*
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.apache.commons.logging,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.core.service
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -135,7 +135,8 @@
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
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.push.notification,
|
||||
org.apache.commons.logging,
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -126,13 +126,13 @@
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
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.device.mgt.common.operation.mgt,
|
||||
org.wso2.carbon.device.mgt.common.push.notification,
|
||||
org.wso2.carbon.device.mgt.common,
|
||||
org.wso2.carbon.device.mgt.core.service,
|
||||
org.osgi.framework,
|
||||
org.wso2.carbon.device.mgt.core.operation.mgt,
|
||||
org.wso2.carbon.core,
|
||||
com.google.gson,
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -148,7 +148,8 @@
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
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.device.mgt.common.operation.mgt,
|
||||
org.wso2.carbon.device.mgt.common.push.notification,
|
||||
@ -157,7 +158,6 @@
|
||||
org.wso2.carbon.device.mgt.core.service,
|
||||
org.wso2.carbon.event.output.adapter.core,
|
||||
org.wso2.carbon.event.output.adapter.core.exception,
|
||||
org.osgi.framework,
|
||||
org.wso2.carbon.device.mgt.core.operation.mgt,
|
||||
org.wso2.carbon.core,
|
||||
org.wso2.carbon.device.application.mgt.common.*,
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -135,14 +135,14 @@
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
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.device.mgt.common.operation.mgt,
|
||||
org.wso2.carbon.device.mgt.common.push.notification,
|
||||
org.wso2.carbon.device.mgt.core.service,
|
||||
org.wso2.carbon.device.mgt.core.*,
|
||||
org.wso2.carbon.event.output.adapter.core,
|
||||
org.wso2.carbon.event.output.adapter.core.exception,
|
||||
org.osgi.framework,
|
||||
org.wso2.carbon.core,
|
||||
org.wso2.carbon.device.mgt.common.*
|
||||
</Import-Package>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -146,13 +146,13 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<artifactId>cxf-bundle-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -107,8 +107,8 @@
|
||||
org.wso2.carbon.device.mgt.analytics.data.publisher.*;version="${carbon.device.mgt.version}"
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.apache.commons.logging.*,
|
||||
org.wso2.carbon.utils.multitenancy,
|
||||
org.wso2.carbon.context;version="${carbon.kernel.version.range}",
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -146,18 +146,13 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</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>
|
||||
<artifactId>cxf-bundle-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -165,11 +160,6 @@
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
@ -199,11 +189,6 @@
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
@ -340,6 +325,12 @@
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.commons</groupId>
|
||||
@ -350,11 +341,6 @@
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
@ -402,11 +388,6 @@
|
||||
<artifactId>org.wso2.carbon.event.stream.persistence.stub</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.integration.client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-testng</artifactId>
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate;
|
||||
|
||||
public class GeoCluster {
|
||||
private final GeoCoordinate coordinates;
|
||||
private final GeoCoordinate southWestBound;
|
||||
private final GeoCoordinate northEastBound;
|
||||
private final long count;
|
||||
private final String geohashPrefix;
|
||||
private final String deviceIdentification;
|
||||
private final String deviceName;
|
||||
private final String deviceType;
|
||||
private final String lastSeen;
|
||||
|
||||
public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound,
|
||||
long count, String geohashPrefix, String deviceIdentification, String deviceName,
|
||||
String deviceType, String lastSeen) {
|
||||
this.coordinates = coordinates;
|
||||
this.southWestBound = southWestBound;
|
||||
this.northEastBound = northEastBound;
|
||||
this.count = count;
|
||||
this.geohashPrefix = geohashPrefix;
|
||||
this.deviceIdentification = deviceIdentification;
|
||||
this.deviceName = deviceName;
|
||||
this.deviceType = deviceType;
|
||||
this.lastSeen = lastSeen;
|
||||
}
|
||||
|
||||
public String getGeohashPrefix() {
|
||||
return geohashPrefix;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public GeoCoordinate getCoordinates() {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public GeoCoordinate getSouthWestBound() {
|
||||
return southWestBound;
|
||||
}
|
||||
|
||||
public GeoCoordinate getNorthEastBound() {
|
||||
return northEastBound;
|
||||
}
|
||||
|
||||
public String getDeviceIdentification() {
|
||||
return deviceIdentification;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public String getLastSeen() {
|
||||
return lastSeen;
|
||||
}
|
||||
|
||||
}
|
||||
@ -67,64 +67,65 @@ import javax.ws.rs.core.Response;
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface DeviceEventManagementService {
|
||||
|
||||
@POST
|
||||
@Path("/{type}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Adding the Event Type Definition",
|
||||
notes = "Add the event definition for a device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully added the event defintion.",
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response deployDeviceTypeEventDefinition(
|
||||
@ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
|
||||
@PathParam("type")String deviceType,
|
||||
@ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
|
||||
@QueryParam("skipPersist") boolean skipPersist,
|
||||
@ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
|
||||
@QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
|
||||
@ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.",
|
||||
required = true)
|
||||
@Valid DeviceTypeEvent deviceTypeEvent);
|
||||
//todo:amalka
|
||||
// @POST
|
||||
// @Path("/{type}")
|
||||
// @ApiOperation(
|
||||
// produces = MediaType.APPLICATION_JSON,
|
||||
// httpMethod = "POST",
|
||||
// value = "Adding the Event Type Definition",
|
||||
// notes = "Add the event definition for a device.",
|
||||
// tags = "Device Event Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(
|
||||
// value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK. \n Successfully added the event defintion.",
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "ETag",
|
||||
// description = "Entity Tag of the response resource.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description =
|
||||
// "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// }
|
||||
// ),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message =
|
||||
// "Bad Request. \n"),
|
||||
// @ApiResponse(
|
||||
// code = 406,
|
||||
// message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
// "list of supported device types.",
|
||||
// response = ErrorResponse.class)
|
||||
// }
|
||||
// )
|
||||
// Response deployDeviceTypeEventDefinition(
|
||||
// @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
|
||||
// @PathParam("type")String deviceType,
|
||||
// @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
|
||||
// @QueryParam("skipPersist") boolean skipPersist,
|
||||
// @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
|
||||
// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
|
||||
// @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.",
|
||||
// required = true)
|
||||
// @Valid DeviceTypeEvent deviceTypeEvent);
|
||||
|
||||
@DELETE
|
||||
@Path("/{type}")
|
||||
@ -178,183 +179,186 @@ public interface DeviceEventManagementService {
|
||||
"ios, and windows.", required = false)
|
||||
@PathParam("type")String deviceType);
|
||||
|
||||
@GET
|
||||
@Path("/{type}/{deviceId}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Device Events",
|
||||
notes = "Get the events for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event definition.",
|
||||
response = EventRecords.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(name = "from", value = "unix timestamp to retrieve", required = false)
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(name = "to", value = "unix time to retrieve", required = false)
|
||||
@QueryParam("to") long to,
|
||||
@ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
@PathParam("type") String deviceType,
|
||||
@ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false)
|
||||
@QueryParam("offset") int offset,
|
||||
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
|
||||
@QueryParam("limit") int limit);
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("/{type}/{deviceId}")
|
||||
// @ApiOperation(
|
||||
// produces = MediaType.APPLICATION_JSON,
|
||||
// httpMethod = "GET",
|
||||
// value = "Getting Device Events",
|
||||
// notes = "Get the events for the device.",
|
||||
// tags = "Device Event Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(
|
||||
// value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK. \n Successfully fetched the event definition.",
|
||||
// response = EventRecords.class,
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "ETag",
|
||||
// description = "Entity Tag of the response resource.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description =
|
||||
// "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// }
|
||||
// ),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message =
|
||||
// "Bad Request. \n"),
|
||||
// @ApiResponse(
|
||||
// code = 406,
|
||||
// message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
// "list of supported device types.",
|
||||
// response = ErrorResponse.class)
|
||||
// }
|
||||
// )
|
||||
// Response getData(@ApiParam(name = "deviceId", value = "id of the device ", required = false)
|
||||
// @PathParam("deviceId") String deviceId,
|
||||
// @ApiParam(name = "from", value = "unix timestamp to retrieve", required = false)
|
||||
// @QueryParam("from") long from,
|
||||
// @ApiParam(name = "to", value = "unix time to retrieve", required = false)
|
||||
// @QueryParam("to") long to,
|
||||
// @ApiParam(name = "type", value = "name of the device type", required = false)
|
||||
// @PathParam("type") String deviceType,
|
||||
// @ApiParam(name = "offset", value = "offset of the records that needs to be picked up", required = false)
|
||||
// @QueryParam("offset") int offset,
|
||||
// @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
|
||||
// @QueryParam("limit") int limit);
|
||||
|
||||
@GET
|
||||
@Path("last-known/{type}/{deviceId}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Last Known Device Events",
|
||||
notes = "Get the last known events for the device.",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event.",
|
||||
response = EventRecords.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(name = "type", value = "name of the device type", required = true)
|
||||
@PathParam("type") String deviceType,
|
||||
@ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
|
||||
@QueryParam("limit") int limit);
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("last-known/{type}/{deviceId}")
|
||||
// @ApiOperation(
|
||||
// produces = MediaType.APPLICATION_JSON,
|
||||
// httpMethod = "GET",
|
||||
// value = "Getting Last Known Device Events",
|
||||
// notes = "Get the last known events for the device.",
|
||||
// tags = "Device Event Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(
|
||||
// value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK. \n Successfully fetched the event.",
|
||||
// response = EventRecords.class,
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "ETag",
|
||||
// description = "Entity Tag of the response resource.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description =
|
||||
// "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// }
|
||||
// ),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message =
|
||||
// "Bad Request. \n"),
|
||||
// @ApiResponse(
|
||||
// code = 406,
|
||||
// message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
// "list of supported device types.",
|
||||
// response = ErrorResponse.class)
|
||||
// }
|
||||
// )
|
||||
// Response getLastKnownData(@ApiParam(name = "deviceId", value = "id of the device ", required = true)
|
||||
// @PathParam("deviceId") String deviceId,
|
||||
// @ApiParam(name = "type", value = "name of the device type", required = true)
|
||||
// @PathParam("type") String deviceType,
|
||||
// @ApiParam(name = "limit", value = "limit of the records that needs to be picked up", required = false)
|
||||
// @QueryParam("limit") int limit);
|
||||
|
||||
@GET
|
||||
@Path("filter/{type}/{parameter}")
|
||||
@ApiOperation(
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting the filtered devices",
|
||||
notes = "Get the list of devices based on the filter parameter",
|
||||
tags = "Device Event Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK. \n Successfully fetched the event.",
|
||||
response = EventRecords.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "ETag",
|
||||
description = "Entity Tag of the response resource.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description =
|
||||
"Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}
|
||||
),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message =
|
||||
"Bad Request. \n"),
|
||||
@ApiResponse(
|
||||
code = 406,
|
||||
message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
"list of supported device types.",
|
||||
response = ErrorResponse.class)
|
||||
}
|
||||
)
|
||||
Response getFilteredDevices(
|
||||
@ApiParam(name = "type", value = "name of the device type", required = true)
|
||||
@PathParam("type") String deviceType,
|
||||
@ApiParam(name = "type", value = "name of the parameter", required = true)
|
||||
@PathParam("type") String parameter,
|
||||
@ApiParam(name = "limit", value = "minimum value the parameter can have", required = false)
|
||||
@QueryParam("min") double min,
|
||||
@ApiParam(name = "max", value = "max value the parameter can have", required = false)
|
||||
@QueryParam("max") double max
|
||||
);
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("filter/{type}/{parameter}")
|
||||
// @ApiOperation(
|
||||
// produces = MediaType.APPLICATION_JSON,
|
||||
// httpMethod = "GET",
|
||||
// value = "Getting the filtered devices",
|
||||
// notes = "Get the list of devices based on the filter parameter",
|
||||
// tags = "Device Event Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events:view")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(
|
||||
// value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK. \n Successfully fetched the event.",
|
||||
// response = EventRecords.class,
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "ETag",
|
||||
// description = "Entity Tag of the response resource.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description =
|
||||
// "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// }
|
||||
// ),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message =
|
||||
// "Bad Request. \n"),
|
||||
// @ApiResponse(
|
||||
// code = 406,
|
||||
// message = "Not Acceptable.\n The requested media type is not supported"),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Server error occurred while fetching the " +
|
||||
// "list of supported device types.",
|
||||
// response = ErrorResponse.class)
|
||||
// }
|
||||
// )
|
||||
// Response getFilteredDevices(
|
||||
// @ApiParam(name = "type", value = "name of the device type", required = true)
|
||||
// @PathParam("type") String deviceType,
|
||||
// @ApiParam(name = "type", value = "name of the parameter", required = true)
|
||||
// @PathParam("type") String parameter,
|
||||
// @ApiParam(name = "limit", value = "minimum value the parameter can have", required = false)
|
||||
// @QueryParam("min") double min,
|
||||
// @ApiParam(name = "max", value = "max value the parameter can have", required = false)
|
||||
// @QueryParam("max") double max
|
||||
// );
|
||||
|
||||
@GET
|
||||
@Path("/{type}")
|
||||
|
||||
@ -269,6 +269,12 @@ public interface DeviceManagementService {
|
||||
@QueryParam("ownership")
|
||||
@Size(max = 45)
|
||||
String ownership,
|
||||
@ApiParam(
|
||||
name = "serialNumber",
|
||||
value = "The serial number of the device.",
|
||||
required = false)
|
||||
@QueryParam("serialNumber")
|
||||
String serialNumber,
|
||||
@ApiParam(
|
||||
name = "status",
|
||||
value = "Provide the device status details, such as active or inactive.",
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.api;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
@ -32,6 +31,7 @@ import io.swagger.annotations.SwaggerDefinition;
|
||||
import io.swagger.annotations.Tag;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scope;
|
||||
import org.wso2.carbon.apimgt.annotations.api.Scopes;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.Alert;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.GeofenceWrapper;
|
||||
@ -41,7 +41,6 @@ import javax.validation.Valid;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
@ -51,7 +50,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
@ -97,71 +96,72 @@ public interface GeoLocationBasedService {
|
||||
/**
|
||||
* Retrieve Analytics for the device type
|
||||
*/
|
||||
@GET
|
||||
@Path("stats/{deviceType}/{deviceId}")
|
||||
@ApiOperation(
|
||||
consumes = "application/json",
|
||||
produces = "application/json",
|
||||
httpMethod = "GET",
|
||||
value = "Getting the Location Details of a Device",
|
||||
notes = "Get the location details of a device during a define time period.",
|
||||
response = Response.class,
|
||||
tags = "Geo Service Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK.",
|
||||
response = Response.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
response = Response.class),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized. \n Unauthorized request."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Error on retrieving stats",
|
||||
response = Response.class)
|
||||
})
|
||||
Response getGeoDeviceStats(
|
||||
@ApiParam(
|
||||
name = "deviceId",
|
||||
value = "The device ID.",
|
||||
required = true)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(
|
||||
name = "device-type",
|
||||
value = "The device type, such as ios, android, or windows.",
|
||||
required = true)
|
||||
@PathParam("deviceType")
|
||||
@Size(max = 45)
|
||||
String deviceType,
|
||||
@ApiParam(
|
||||
name = "from",
|
||||
value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
required = true)
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(
|
||||
name = "to",
|
||||
value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
required = true)
|
||||
@QueryParam("to") long to);
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("stats/{deviceType}/{deviceId}")
|
||||
// @ApiOperation(
|
||||
// consumes = "application/json",
|
||||
// produces = "application/json",
|
||||
// httpMethod = "GET",
|
||||
// value = "Getting the Location Details of a Device",
|
||||
// notes = "Get the location details of a device during a define time period.",
|
||||
// response = Response.class,
|
||||
// tags = "Geo Service Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK.",
|
||||
// response = Response.class,
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description = "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests."),
|
||||
// }),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
// response = Response.class),
|
||||
// @ApiResponse(
|
||||
// code = 401,
|
||||
// message = "Unauthorized. \n Unauthorized request."),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Error on retrieving stats",
|
||||
// response = Response.class)
|
||||
// })
|
||||
// Response getGeoDeviceStats(
|
||||
// @ApiParam(
|
||||
// name = "deviceId",
|
||||
// value = "The device ID.",
|
||||
// required = true)
|
||||
// @PathParam("deviceId") String deviceId,
|
||||
// @ApiParam(
|
||||
// name = "device-type",
|
||||
// value = "The device type, such as ios, android, or windows.",
|
||||
// required = true)
|
||||
// @PathParam("deviceType")
|
||||
// @Size(max = 45)
|
||||
// String deviceType,
|
||||
// @ApiParam(
|
||||
// name = "from",
|
||||
// value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
// required = true)
|
||||
// @QueryParam("from") long from,
|
||||
// @ApiParam(
|
||||
// name = "to",
|
||||
// value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
// required = true)
|
||||
// @QueryParam("to") long to);
|
||||
|
||||
/**
|
||||
* Get data to show device locations in a map
|
||||
@ -208,6 +208,7 @@ public interface GeoLocationBasedService {
|
||||
message = "Internal Server Error. \n Error on retrieving stats",
|
||||
response = Response.class)
|
||||
})
|
||||
@Deprecated
|
||||
Response getGeoDeviceLocations(
|
||||
@ApiParam(
|
||||
name = "deviceType",
|
||||
@ -244,6 +245,124 @@ public interface GeoLocationBasedService {
|
||||
defaultValue ="2")
|
||||
@QueryParam("zoom") int zoom);
|
||||
|
||||
@Path("stats/geo-view")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
@ApiOperation(
|
||||
consumes = "application/json",
|
||||
produces = "application/json",
|
||||
httpMethod = "GET",
|
||||
value = "Getting geo view of devices",
|
||||
notes = "Get the details of the devices that are within the map. The map area is enclosed with four " +
|
||||
"coordinates in the shape of a square or rectangle. This is done by defining two points of the " +
|
||||
"map. The other two points are automatically created using the given points. " +
|
||||
"You can define the zoom level or scale of the map too.",
|
||||
response = Response.class,
|
||||
tags = "Geo Service Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:analytics-view")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK.",
|
||||
response = Response.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests."),
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid parameters found.",
|
||||
response = Response.class),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized. \n Unauthorized request."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Error on retrieving stats",
|
||||
response = Response.class)
|
||||
})
|
||||
Response getGeoDeviceView(
|
||||
@ApiParam(
|
||||
name = "minLat",
|
||||
value = "Define the minimum latitude of the geofence.",
|
||||
required = true,
|
||||
defaultValue ="79.85213577747345")
|
||||
@QueryParam("minLat") double minLat,
|
||||
@ApiParam(
|
||||
name = "maxLat",
|
||||
value = "Define the maximum latitude of the geofence.",
|
||||
required = true,
|
||||
defaultValue ="79.85266149044037")
|
||||
@QueryParam("maxLat") double maxLat,
|
||||
@ApiParam(
|
||||
name = "minLong",
|
||||
value = "Define the minimum longitude of the geofence.",
|
||||
required = true,
|
||||
defaultValue ="6.909673257977737")
|
||||
@QueryParam("minLong") double minLong,
|
||||
@ApiParam(
|
||||
name = "maxLong",
|
||||
value = "Define the maximum longitude of the geofence",
|
||||
required = true,
|
||||
defaultValue ="6.909673257977737")
|
||||
@QueryParam("maxLong") double maxLong,
|
||||
@ApiParam(
|
||||
name = "zoom",
|
||||
value = "Define the level to zoom or scale the map. You can define any value between 1 to 14.",
|
||||
required = true,
|
||||
defaultValue ="2")
|
||||
@QueryParam("zoom") int zoom,
|
||||
@ApiParam(
|
||||
name = "deviceType",
|
||||
value = "Optional Device type name.")
|
||||
@QueryParam("deviceType") List<String> deviceTypes,
|
||||
@ApiParam(
|
||||
name = "deviceIdentifier",
|
||||
value = "Optional Device Identifier.")
|
||||
@QueryParam("deviceIdentifier") List<String> deviceIdentifiers,
|
||||
@ApiParam(
|
||||
name = "status",
|
||||
value = "Optional Device status.")
|
||||
@QueryParam("status") List<EnrolmentInfo.Status> statuses,
|
||||
@ApiParam(
|
||||
name = "ownership",
|
||||
value = "Optional Device ownership.")
|
||||
@QueryParam("ownership") List<String> ownerships,
|
||||
@ApiParam(
|
||||
name = "owner",
|
||||
value = "Optional Device owner.")
|
||||
@QueryParam("owner") List<String> owners,
|
||||
@ApiParam(
|
||||
name = "noClusters",
|
||||
value = "Optional include devices only.")
|
||||
@QueryParam("noClusters") boolean noClusters,
|
||||
@ApiParam(
|
||||
name = "createdBefore",
|
||||
value = "Optional Device created before timestamp.")
|
||||
@QueryParam("createdBefore") long createdBefore,
|
||||
@ApiParam(
|
||||
name = "createdAfter",
|
||||
value = "Optional Device created after timestamp..")
|
||||
@QueryParam("createdAfter") long createdAfter,
|
||||
@ApiParam(
|
||||
name = "updatedBefore",
|
||||
value = "Optional Device updated before timestamp.")
|
||||
@QueryParam("updatedBefore") long updatedBefore,
|
||||
@ApiParam(
|
||||
name = "updatedAfter",
|
||||
value = "Optional Device updated after timestamp.")
|
||||
@QueryParam("updatedAfter") long updatedAfter);
|
||||
|
||||
/**
|
||||
* Create Geo alerts
|
||||
@ -602,128 +721,130 @@ public interface GeoLocationBasedService {
|
||||
/**
|
||||
* Retrieve Geo alerts history
|
||||
*/
|
||||
@GET
|
||||
@Path("alerts/history/{deviceType}/{deviceId}")
|
||||
@ApiOperation(
|
||||
consumes = "application/json",
|
||||
produces = "application/json",
|
||||
httpMethod = "GET",
|
||||
value = "Getting the Geo Service Alert History of a Device",
|
||||
notes = "Get the geo alert history of a device during the defined time period.",
|
||||
response = Response.class,
|
||||
tags = "Geo Service Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK.",
|
||||
response = Response.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests.")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
response = Response.class),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized. \n Unauthorized request."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Error on retrieving stats",
|
||||
response = Response.class)
|
||||
})
|
||||
Response getGeoAlertsHistory(
|
||||
@ApiParam(
|
||||
name = "deviceId",
|
||||
value = "The device ID.",
|
||||
required = true)
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(
|
||||
name = "device-type",
|
||||
value = "The device type, such as ios, android, or windows.",
|
||||
required = true)
|
||||
@PathParam("deviceType")
|
||||
@Size(max = 45)
|
||||
String deviceType,
|
||||
@ApiParam(
|
||||
name = "from",
|
||||
value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
required = true)
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(
|
||||
name = "to",
|
||||
value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
required = true)
|
||||
@QueryParam("to") long to);
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("alerts/history/{deviceType}/{deviceId}")
|
||||
// @ApiOperation(
|
||||
// consumes = "application/json",
|
||||
// produces = "application/json",
|
||||
// httpMethod = "GET",
|
||||
// value = "Getting the Geo Service Alert History of a Device",
|
||||
// notes = "Get the geo alert history of a device during the defined time period.",
|
||||
// response = Response.class,
|
||||
// tags = "Geo Service Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK.",
|
||||
// response = Response.class,
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description = "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests.")
|
||||
// }),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
// response = Response.class),
|
||||
// @ApiResponse(
|
||||
// code = 401,
|
||||
// message = "Unauthorized. \n Unauthorized request."),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Error on retrieving stats",
|
||||
// response = Response.class)
|
||||
// })
|
||||
// Response getGeoAlertsHistory(
|
||||
// @ApiParam(
|
||||
// name = "deviceId",
|
||||
// value = "The device ID.",
|
||||
// required = true)
|
||||
// @PathParam("deviceId") String deviceId,
|
||||
// @ApiParam(
|
||||
// name = "device-type",
|
||||
// value = "The device type, such as ios, android, or windows.",
|
||||
// required = true)
|
||||
// @PathParam("deviceType")
|
||||
// @Size(max = 45)
|
||||
// String deviceType,
|
||||
// @ApiParam(
|
||||
// name = "from",
|
||||
// value = "Define the time to start getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
// required = true)
|
||||
// @QueryParam("from") long from,
|
||||
// @ApiParam(
|
||||
// name = "to",
|
||||
// value = "Define the time to finish getting the geo location history of the device in the Epoch or UNIX format.",
|
||||
// required = true)
|
||||
// @QueryParam("to") long to);
|
||||
|
||||
/**
|
||||
* Retrieve Geo alerts history for geo clusters
|
||||
*/
|
||||
@GET
|
||||
@Path("alerts/history")
|
||||
@ApiOperation(
|
||||
consumes = "application/json",
|
||||
produces = "application/json",
|
||||
httpMethod = "GET",
|
||||
value = "Retrieve Geo alerts history for geo clusters",
|
||||
notes = "Retrieving geo alert history of all defined alerts for geo clusters",
|
||||
response = Response.class,
|
||||
tags = "Geo Service Management",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
|
||||
})
|
||||
}
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(
|
||||
code = 200,
|
||||
message = "OK.",
|
||||
response = Response.class,
|
||||
responseHeaders = {
|
||||
@ResponseHeader(
|
||||
name = "Content-Type",
|
||||
description = "The content type of the body"),
|
||||
@ResponseHeader(
|
||||
name = "Last-Modified",
|
||||
description = "Date and time the resource was last modified.\n" +
|
||||
"Used by caches, or in conditional requests.")
|
||||
}),
|
||||
@ApiResponse(
|
||||
code = 400,
|
||||
message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
response = Response.class),
|
||||
@ApiResponse(
|
||||
code = 401,
|
||||
message = "Unauthorized. \n Unauthorized request."),
|
||||
@ApiResponse(
|
||||
code = 500,
|
||||
message = "Internal Server Error. \n Error on retrieving stats",
|
||||
response = Response.class)
|
||||
})
|
||||
Response getGeoAlertsHistoryForGeoClusters(
|
||||
@ApiParam(
|
||||
name = "from",
|
||||
value = "Get stats from what time",
|
||||
required = true)
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(
|
||||
name = "to",
|
||||
value = "Get stats up to what time",
|
||||
required = true)
|
||||
@QueryParam("to") long to);
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("alerts/history")
|
||||
// @ApiOperation(
|
||||
// consumes = "application/json",
|
||||
// produces = "application/json",
|
||||
// httpMethod = "GET",
|
||||
// value = "Retrieve Geo alerts history for geo clusters",
|
||||
// notes = "Retrieving geo alert history of all defined alerts for geo clusters",
|
||||
// response = Response.class,
|
||||
// tags = "Geo Service Management",
|
||||
// extensions = {
|
||||
// @Extension(properties = {
|
||||
// @ExtensionProperty(name = Constants.SCOPE, value = "perm:geo-service:alerts-manage")
|
||||
// })
|
||||
// }
|
||||
// )
|
||||
// @ApiResponses(value = {
|
||||
// @ApiResponse(
|
||||
// code = 200,
|
||||
// message = "OK.",
|
||||
// response = Response.class,
|
||||
// responseHeaders = {
|
||||
// @ResponseHeader(
|
||||
// name = "Content-Type",
|
||||
// description = "The content type of the body"),
|
||||
// @ResponseHeader(
|
||||
// name = "Last-Modified",
|
||||
// description = "Date and time the resource was last modified.\n" +
|
||||
// "Used by caches, or in conditional requests.")
|
||||
// }),
|
||||
// @ApiResponse(
|
||||
// code = 400,
|
||||
// message = "Bad Request. \n Invalid Device Identifiers found.",
|
||||
// response = Response.class),
|
||||
// @ApiResponse(
|
||||
// code = 401,
|
||||
// message = "Unauthorized. \n Unauthorized request."),
|
||||
// @ApiResponse(
|
||||
// code = 500,
|
||||
// message = "Internal Server Error. \n Error on retrieving stats",
|
||||
// response = Response.class)
|
||||
// })
|
||||
// Response getGeoAlertsHistoryForGeoClusters(
|
||||
// @ApiParam(
|
||||
// name = "from",
|
||||
// value = "Get stats from what time",
|
||||
// required = true)
|
||||
// @QueryParam("from") long from,
|
||||
// @ApiParam(
|
||||
// name = "to",
|
||||
// value = "Get stats up to what time",
|
||||
// required = true)
|
||||
// @QueryParam("to") long to);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -26,7 +26,6 @@ import org.apache.axis2.AxisFault;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
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.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
@ -36,7 +35,6 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.InvalidConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
@ -52,7 +50,6 @@ import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto;
|
||||
import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
|
||||
@ -280,19 +277,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
|
||||
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
|
||||
, Constants.DEFAULT_STREAM_VERSION, metaData
|
||||
, null, payloadData)) {
|
||||
// todo: amalka: commented data publishing
|
||||
// if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
|
||||
// , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
|
||||
// , Constants.DEFAULT_STREAM_VERSION, metaData
|
||||
// , null, payloadData)) {
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
// } else {
|
||||
// String msg = "Error occurred while publishing the event.";
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
// }
|
||||
// } catch (DataPublisherConfigurationException e) {
|
||||
// String msg = "Error occurred while publishing the event.";
|
||||
// log.error(msg, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
String msg = "Error occurred when checking for authorization";
|
||||
log.error(msg, e);
|
||||
@ -380,19 +378,20 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
|
||||
, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
|
||||
, Constants.DEFAULT_STREAM_VERSION, metaData
|
||||
, null, payloadData)) {
|
||||
// todo: amalka: commented data publishing
|
||||
// if (DeviceMgtAPIUtils.getEventPublisherService().publishEvent(DeviceMgtAPIUtils.getStreamDefinition(type
|
||||
// , PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain())
|
||||
// , Constants.DEFAULT_STREAM_VERSION, metaData
|
||||
// , null, payloadData)) {
|
||||
return Response.status(Response.Status.OK).build();
|
||||
} else {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
String msg = "Error occurred while publishing the event.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
// } else {
|
||||
// String msg = "Error occurred while publishing the event.";
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
// }
|
||||
// } catch (DataPublisherConfigurationException e) {
|
||||
// String msg = "Error occurred while publishing the event.";
|
||||
// log.error(msg, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
String msg = "Error occurred when checking for authorization";
|
||||
log.error(msg, e);
|
||||
|
||||
@ -4,29 +4,13 @@ import org.apache.axis2.AxisFault;
|
||||
import org.apache.axis2.client.Stub;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SortType;
|
||||
import org.wso2.carbon.analytics.datasource.commons.Record;
|
||||
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.EventStreamPersistenceAdminServiceStub;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord;
|
||||
import org.wso2.carbon.base.MultitenantConstants;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.DeviceTypeEvent;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventAttributeList;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventRecords;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.TransportType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceEventManagementService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||
@ -43,21 +27,14 @@ import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@ -81,49 +58,50 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
||||
private static final String MQTT_CONTENT_VALIDATOR = "default";
|
||||
private static final String TIMESTAMP_FIELD_NAME = "_timestamp";
|
||||
|
||||
private static AnalyticsDataAPI getAnalyticsDataAPI() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
AnalyticsDataAPI analyticsDataAPI =
|
||||
(AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
|
||||
if (analyticsDataAPI == null) {
|
||||
String msg = "Analytics api service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return analyticsDataAPI;
|
||||
}
|
||||
//todo:amalka
|
||||
// private static AnalyticsDataAPI getAnalyticsDataAPI() {
|
||||
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
// AnalyticsDataAPI analyticsDataAPI =
|
||||
// (AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
|
||||
// if (analyticsDataAPI == null) {
|
||||
// String msg = "Analytics api service has not initialized.";
|
||||
// log.error(msg);
|
||||
// throw new IllegalStateException(msg);
|
||||
// }
|
||||
// return analyticsDataAPI;
|
||||
// }
|
||||
|
||||
private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
|
||||
, int offset, int limit) throws AnalyticsException {
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
|
||||
EventRecords eventRecords = new EventRecords();
|
||||
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
|
||||
if (eventCount == 0) {
|
||||
eventRecords.setCount(0);
|
||||
}
|
||||
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
|
||||
sortByFields);
|
||||
List<String> recordIds = getRecordIds(resultEntries);
|
||||
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
|
||||
eventRecords.setCount(eventCount);
|
||||
List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
|
||||
records.sort(new Comparator<Record>() {
|
||||
@Override public int compare(Record r1, Record r2) {
|
||||
return Long.compare(r2.getTimestamp(), r1.getTimestamp());
|
||||
}
|
||||
});
|
||||
eventRecords.setList(records);
|
||||
return eventRecords;
|
||||
}
|
||||
// private static EventRecords getAllEventsForDevice(String tableName, String query, List<SortByField> sortByFields
|
||||
// , int offset, int limit) throws AnalyticsException {
|
||||
// int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
// AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
|
||||
// EventRecords eventRecords = new EventRecords();
|
||||
// int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
|
||||
// if (eventCount == 0) {
|
||||
// eventRecords.setCount(0);
|
||||
// }
|
||||
// List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, offset, limit,
|
||||
// sortByFields);
|
||||
// List<String> recordIds = getRecordIds(resultEntries);
|
||||
// AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
|
||||
// eventRecords.setCount(eventCount);
|
||||
// List<Record> records = AnalyticsDataAPIUtil.listRecords(analyticsDataAPI, response);
|
||||
// records.sort(new Comparator<Record>() {
|
||||
// @Override public int compare(Record r1, Record r2) {
|
||||
// return Long.compare(r2.getTimestamp(), r1.getTimestamp());
|
||||
// }
|
||||
// });
|
||||
// eventRecords.setList(records);
|
||||
// return eventRecords;
|
||||
// }
|
||||
|
||||
private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (SearchResultEntry searchResult : searchResults) {
|
||||
ids.add(searchResult.getId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
// private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
|
||||
// List<String> ids = new ArrayList<>();
|
||||
// for (SearchResultEntry searchResult : searchResults) {
|
||||
// ids.add(searchResult.getId());
|
||||
// }
|
||||
// return ids;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieves the stream definition from das for the given device type.
|
||||
@ -195,65 +173,66 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
||||
/**
|
||||
* Deploy Event Stream, Receiver, Publisher and Store Configuration.
|
||||
*/
|
||||
@POST
|
||||
@Path("/{type}")
|
||||
@Override
|
||||
public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
|
||||
@QueryParam("skipPersist") boolean skipPersist,
|
||||
@QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
|
||||
@Valid DeviceTypeEvent deviceTypeEvent) {
|
||||
TransportType transportType = deviceTypeEvent.getTransportType();
|
||||
EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
try {
|
||||
if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
|
||||
deviceType == null || transportType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid Payload";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
|
||||
String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
|
||||
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
|
||||
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
|
||||
if (!skipPersist) {
|
||||
publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
|
||||
}
|
||||
publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
|
||||
try {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
|
||||
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
|
||||
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
|
||||
publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
|
||||
}
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
return Response.ok().build();
|
||||
} catch (AxisFault e) {
|
||||
log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (RemoteException e) {
|
||||
log.error("Failed to connect with the remote services:" + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (JWTClientException e) {
|
||||
log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (UserStoreException e) {
|
||||
log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
|
||||
log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
|
||||
e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
//todo:amalka
|
||||
// @POST
|
||||
// @Path("/{type}")
|
||||
// @Override
|
||||
// public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
|
||||
// @QueryParam("skipPersist") boolean skipPersist,
|
||||
// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
|
||||
// @Valid DeviceTypeEvent deviceTypeEvent) {
|
||||
// TransportType transportType = deviceTypeEvent.getTransportType();
|
||||
// EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
|
||||
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
// try {
|
||||
// if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
|
||||
// deviceType == null || transportType == null ||
|
||||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
// String errorMessage = "Invalid Payload";
|
||||
// log.error(errorMessage);
|
||||
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
// }
|
||||
// String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
|
||||
// String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
|
||||
// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
|
||||
// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
|
||||
// if (!skipPersist) {
|
||||
// publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
|
||||
// }
|
||||
// publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
|
||||
// try {
|
||||
// PrivilegedCarbonContext.startTenantFlow();
|
||||
// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
|
||||
// MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
|
||||
// if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||
// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
|
||||
// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
|
||||
// }
|
||||
// } finally {
|
||||
// PrivilegedCarbonContext.endTenantFlow();
|
||||
// }
|
||||
// return Response.ok().build();
|
||||
// } catch (AxisFault e) {
|
||||
// log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (RemoteException e) {
|
||||
// log.error("Failed to connect with the remote services:" + tenantDomain, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (JWTClientException e) {
|
||||
// log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (UserStoreException e) {
|
||||
// log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (DeviceManagementException e) {
|
||||
// log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
|
||||
// log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
|
||||
// e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Delete device type specific artifacts from DAS.
|
||||
@ -349,175 +328,178 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
||||
/**
|
||||
* Returns device specific data for the give period of time.
|
||||
*/
|
||||
@GET
|
||||
@Path("/{type}/{deviceId}")
|
||||
@Override
|
||||
public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
||||
@QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset")
|
||||
int offset, @QueryParam("limit") int limit) {
|
||||
if (from == 0 || to == 0) {
|
||||
String errorMessage = "Invalid values for from/to";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
if (limit == 0) {
|
||||
String errorMessage = "Invalid values for offset/limit";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
String fromDate = String.valueOf(from);
|
||||
String toDate = String.valueOf(to);
|
||||
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId
|
||||
+ " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
new DeviceIdentifier(deviceId, deviceType))) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
List<SortByField> sortByFields = new ArrayList<>();
|
||||
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
sortByFields.add(sortByField);
|
||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit);
|
||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
} catch (AnalyticsException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
}
|
||||
}
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("/{type}/{deviceId}")
|
||||
// @Override
|
||||
// public Response getData(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
||||
// @QueryParam("to") long to, @PathParam("type") String deviceType, @QueryParam("offset")
|
||||
// int offset, @QueryParam("limit") int limit) {
|
||||
// if (from == 0 || to == 0) {
|
||||
// String errorMessage = "Invalid values for from/to";
|
||||
// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
// }
|
||||
// if (limit == 0) {
|
||||
// String errorMessage = "Invalid values for offset/limit";
|
||||
// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
// }
|
||||
// String fromDate = String.valueOf(from);
|
||||
// String toDate = String.valueOf(to);
|
||||
// String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId
|
||||
// + " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
|
||||
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
// try {
|
||||
// if (deviceType == null ||
|
||||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
// String errorMessage = "Invalid device type";
|
||||
// log.error(errorMessage);
|
||||
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
// }
|
||||
// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
// new DeviceIdentifier(deviceId, deviceType))) {
|
||||
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
// }
|
||||
// List<SortByField> sortByFields = new ArrayList<>();
|
||||
// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
// sortByFields.add(sortByField);
|
||||
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, offset, limit);
|
||||
// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
// } catch (AnalyticsException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
// } catch (DeviceAccessAuthorizationException e) {
|
||||
// log.error(e.getErrorMessage(), e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (DeviceManagementException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// 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.
|
||||
* Limit parameter needs to be zero or positive.
|
||||
*/
|
||||
@GET
|
||||
@Path("/last-known/{type}/{deviceId}")
|
||||
@Override
|
||||
public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) {
|
||||
String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId;
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
new DeviceIdentifier(deviceId, deviceType))) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
List<SortByField> sortByFields = new ArrayList<>();
|
||||
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
sortByFields.add(sortByField);
|
||||
if (limit == 0) {
|
||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
} else if (limit > 0) {
|
||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
|
||||
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
} else {
|
||||
String errorMessage = "Invalid limit value";
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
}
|
||||
} catch (AnalyticsException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
}
|
||||
}
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("/last-known/{type}/{deviceId}")
|
||||
// @Override
|
||||
// public Response getLastKnownData(@PathParam("deviceId") String deviceId, @PathParam("type") String deviceType, @QueryParam("limit") int limit) {
|
||||
// String query = DEFAULT_META_DEVICE_ID_ATTRIBUTE + ":" + deviceId;
|
||||
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
// try {
|
||||
// if (deviceType == null ||
|
||||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
// String errorMessage = "Invalid device type";
|
||||
// log.error(errorMessage);
|
||||
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
// }
|
||||
// if (!DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
// new DeviceIdentifier(deviceId, deviceType))) {
|
||||
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
// }
|
||||
// List<SortByField> sortByFields = new ArrayList<>();
|
||||
// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
// sortByFields.add(sortByField);
|
||||
// if (limit == 0) {
|
||||
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
||||
// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
// } else if (limit > 0) {
|
||||
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
|
||||
// return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
||||
// } else {
|
||||
// String errorMessage = "Invalid limit value";
|
||||
// return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
||||
// }
|
||||
// } catch (AnalyticsException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
// } catch (DeviceAccessAuthorizationException e) {
|
||||
// log.error(e.getErrorMessage(), e);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
// } catch (DeviceManagementException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// 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.
|
||||
* parameter should given as a range.
|
||||
*/
|
||||
@GET
|
||||
@Path("filter/{type}/{parameter}")
|
||||
@Override
|
||||
public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter,
|
||||
@QueryParam("min") double min, @QueryParam("max") double max) {
|
||||
String query;
|
||||
Calendar c = java.util.Calendar.getInstance();
|
||||
long currentTimestamp = c.getTimeInMillis();
|
||||
long previousTimestamp = currentTimestamp - 300 * 1000;
|
||||
String fromDate = String.valueOf(previousTimestamp);
|
||||
String toDate = String.valueOf(currentTimestamp);
|
||||
if (min != 0 & max != 0) {
|
||||
query = parameter + " : [" + min + " TO " + max + "]" +
|
||||
" AND _timestamp : [" + fromDate + " TO " + toDate + "]";
|
||||
} else {
|
||||
String errorMessage = "The of range values need to be given";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
try {
|
||||
if (deviceType == null ||
|
||||
!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
String errorMessage = "Invalid device type";
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
List<SortByField> sortByFields = new ArrayList<>();
|
||||
SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
sortByFields.add(sortByField);
|
||||
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100);
|
||||
List<Record> filterdEvents = eventRecords.getRecord();
|
||||
List<Record> uniqueFilterdEvents = new ArrayList<Record>();
|
||||
Set<String> devices = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < filterdEvents.size(); i++) {
|
||||
String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId");
|
||||
if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
new DeviceIdentifier(deviceid, deviceType))) {
|
||||
devices.add(deviceid);
|
||||
uniqueFilterdEvents.add(filterdEvents.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
EventRecords filterdRecords = new EventRecords();
|
||||
filterdRecords.setList(uniqueFilterdEvents);
|
||||
return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build();
|
||||
|
||||
} catch (AnalyticsException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
//todo:amalka
|
||||
// @GET
|
||||
// @Path("filter/{type}/{parameter}")
|
||||
// @Override
|
||||
// public Response getFilteredDevices(@PathParam("type") String deviceType, @PathParam("parameter") String parameter,
|
||||
// @QueryParam("min") double min, @QueryParam("max") double max) {
|
||||
// String query;
|
||||
// Calendar c = java.util.Calendar.getInstance();
|
||||
// long currentTimestamp = c.getTimeInMillis();
|
||||
// long previousTimestamp = currentTimestamp - 300 * 1000;
|
||||
// String fromDate = String.valueOf(previousTimestamp);
|
||||
// String toDate = String.valueOf(currentTimestamp);
|
||||
// if (min != 0 & max != 0) {
|
||||
// query = parameter + " : [" + min + " TO " + max + "]" +
|
||||
// " AND _timestamp : [" + fromDate + " TO " + toDate + "]";
|
||||
// } else {
|
||||
// String errorMessage = "The of range values need to be given";
|
||||
// log.error(errorMessage);
|
||||
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
// }
|
||||
//
|
||||
// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
// String sensorTableName = getTableName(DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain));
|
||||
// try {
|
||||
// if (deviceType == null ||
|
||||
// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
|
||||
// String errorMessage = "Invalid device type";
|
||||
// log.error(errorMessage);
|
||||
// return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
// }
|
||||
//
|
||||
// List<SortByField> sortByFields = new ArrayList<>();
|
||||
// SortByField sortByField = new SortByField(TIMESTAMP_FIELD_NAME, SortType.DESC);
|
||||
// sortByFields.add(sortByField);
|
||||
// EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 100);
|
||||
// List<Record> filterdEvents = eventRecords.getRecord();
|
||||
// List<Record> uniqueFilterdEvents = new ArrayList<Record>();
|
||||
// Set<String> devices = new HashSet<>();
|
||||
//
|
||||
// for (int i = 0; i < filterdEvents.size(); i++) {
|
||||
// String deviceid = (String) filterdEvents.get(i).getValue("meta_deviceId");
|
||||
// if (!devices.contains(deviceid) && DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized(
|
||||
// new DeviceIdentifier(deviceid, deviceType))) {
|
||||
// devices.add(deviceid);
|
||||
// uniqueFilterdEvents.add(filterdEvents.get(i));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// EventRecords filterdRecords = new EventRecords();
|
||||
// filterdRecords.setList(uniqueFilterdEvents);
|
||||
// return Response.status(Response.Status.OK.getStatusCode()).entity(filterdRecords).build();
|
||||
//
|
||||
// } catch (AnalyticsException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
// } catch (DeviceManagementException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
// } catch (DeviceAccessAuthorizationException e) {
|
||||
// String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
// log.error(errorMsg);
|
||||
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private void publishEventReceivers(String streamNameWithVersion, TransportType transportType
|
||||
@ -613,47 +595,48 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
||||
}
|
||||
}
|
||||
|
||||
private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
|
||||
throws RemoteException, UserStoreException, JWTClientException,
|
||||
EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
|
||||
EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
|
||||
DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
|
||||
try {
|
||||
AnalyticsTable analyticsTable = new AnalyticsTable();
|
||||
analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
|
||||
analyticsTable.setStreamVersion(version);
|
||||
analyticsTable.setTableName(streamName);
|
||||
analyticsTable.setMergeSchema(false);
|
||||
analyticsTable.setPersist(true);
|
||||
AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
|
||||
int i = 0;
|
||||
for (Attribute attribute : eventAttributes.getList()) {
|
||||
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
|
||||
analyticsTableRecord.setColumnName(attribute.getName());
|
||||
analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
|
||||
analyticsTableRecord.setFacet(false);
|
||||
analyticsTableRecord.setIndexed(false);
|
||||
analyticsTableRecord.setPersist(true);
|
||||
analyticsTableRecord.setPrimaryKey(false);
|
||||
analyticsTableRecord.setScoreParam(false);
|
||||
analyticsTableRecords[i] = analyticsTableRecord;
|
||||
i++;
|
||||
}
|
||||
AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
|
||||
analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
|
||||
analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
|
||||
analyticsTableRecord.setFacet(false);
|
||||
analyticsTableRecord.setIndexed(true);
|
||||
analyticsTableRecord.setPersist(true);
|
||||
analyticsTableRecord.setPrimaryKey(false);
|
||||
analyticsTableRecord.setScoreParam(false);
|
||||
analyticsTableRecords[i] = analyticsTableRecord;
|
||||
analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
|
||||
eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
|
||||
} finally {
|
||||
cleanup(eventStreamPersistenceAdminServiceStub);
|
||||
}
|
||||
}
|
||||
//todo:amalka
|
||||
// private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
|
||||
// throws RemoteException, UserStoreException, JWTClientException,
|
||||
// EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
|
||||
// EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
|
||||
// DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
|
||||
// try {
|
||||
// AnalyticsTable analyticsTable = new AnalyticsTable();
|
||||
// analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
|
||||
// analyticsTable.setStreamVersion(version);
|
||||
// analyticsTable.setTableName(streamName);
|
||||
// analyticsTable.setMergeSchema(false);
|
||||
// analyticsTable.setPersist(true);
|
||||
// AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
|
||||
// int i = 0;
|
||||
// for (Attribute attribute : eventAttributes.getList()) {
|
||||
// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
|
||||
// analyticsTableRecord.setColumnName(attribute.getName());
|
||||
// analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
|
||||
// analyticsTableRecord.setFacet(false);
|
||||
// analyticsTableRecord.setIndexed(false);
|
||||
// analyticsTableRecord.setPersist(true);
|
||||
// analyticsTableRecord.setPrimaryKey(false);
|
||||
// analyticsTableRecord.setScoreParam(false);
|
||||
// analyticsTableRecords[i] = analyticsTableRecord;
|
||||
// i++;
|
||||
// }
|
||||
// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
|
||||
// analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
|
||||
// analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
|
||||
// analyticsTableRecord.setFacet(false);
|
||||
// analyticsTableRecord.setIndexed(true);
|
||||
// analyticsTableRecord.setPersist(true);
|
||||
// analyticsTableRecord.setPrimaryKey(false);
|
||||
// analyticsTableRecord.setScoreParam(false);
|
||||
// analyticsTableRecords[i] = analyticsTableRecord;
|
||||
// analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
|
||||
// eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
|
||||
// } finally {
|
||||
// cleanup(eventStreamPersistenceAdminServiceStub);
|
||||
// }
|
||||
// }
|
||||
|
||||
private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType)
|
||||
throws RemoteException, UserStoreException, JWTClientException {
|
||||
|
||||
@ -172,6 +172,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
@QueryParam("userPattern") String userPattern,
|
||||
@QueryParam("role") String role,
|
||||
@QueryParam("ownership") String ownership,
|
||||
@QueryParam("serialNumber") String serialNumber,
|
||||
@QueryParam("status") List<String> status,
|
||||
@QueryParam("groupId") int groupId,
|
||||
@QueryParam("since") String since,
|
||||
@ -205,6 +206,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
RequestValidationUtil.validateOwnershipType(ownership);
|
||||
request.setOwnership(ownership);
|
||||
}
|
||||
if (StringUtils.isNotBlank(serialNumber)) {
|
||||
request.setSerialNumber(serialNumber);
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
boolean isStatusEmpty = true;
|
||||
for (String statusString : status){
|
||||
|
||||
@ -38,6 +38,7 @@ import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants.GeoServices;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
@ -47,13 +48,14 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.Alert;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.AlertAlreadyExistException;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.Event;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoFence;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeofenceData;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
|
||||
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy.GeoHashLengthStrategy;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy.ZoomGeoHashLengthStrategy;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
@ -81,7 +83,10 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -91,7 +96,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
|
||||
private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class);
|
||||
private static final Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class);
|
||||
|
||||
@Path("stats/{deviceType}/{deviceId}")
|
||||
@GET
|
||||
@ -155,6 +160,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
@Deprecated
|
||||
public Response getGeoDeviceLocations(
|
||||
@QueryParam("deviceType") String deviceType,
|
||||
@QueryParam("minLat") double minLat,
|
||||
@ -162,6 +168,64 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
@QueryParam("minLong") double minLong,
|
||||
@QueryParam("maxLong") double maxLong,
|
||||
@QueryParam("zoom") int zoom) {
|
||||
GeoHashLengthStrategy geoHashLengthStrategy = new ZoomGeoHashLengthStrategy();
|
||||
GeoCoordinate southWest = new GeoCoordinate(minLat, minLong);
|
||||
GeoCoordinate northEast = new GeoCoordinate(maxLat, maxLong);
|
||||
int geohashLength = geoHashLengthStrategy.getGeohashLength(southWest, northEast, zoom);
|
||||
DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
GeoQuery geoQuery = new GeoQuery(southWest, northEast, geohashLength);
|
||||
if (deviceType != null) {
|
||||
geoQuery.setDeviceTypes(Collections.singletonList(deviceType));
|
||||
}
|
||||
List<org.wso2.carbon.device.mgt.jaxrs.beans.GeoCluster> geoClusters = new ArrayList<>();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
|
||||
try {
|
||||
List<GeoCluster> newClusters = deviceManagementService.findGeoClusters(geoQuery);
|
||||
org.wso2.carbon.device.mgt.jaxrs.beans.GeoCluster geoCluster;
|
||||
String deviceIdentification = null;
|
||||
String deviceName = null;
|
||||
String lastSeen = null;
|
||||
for (GeoCluster gc : newClusters) {
|
||||
if (gc.getDevice() != null) {
|
||||
deviceIdentification = gc.getDevice().getDeviceIdentifier();
|
||||
deviceName = gc.getDevice().getName();
|
||||
deviceType = gc.getDevice().getType();
|
||||
lastSeen = simpleDateFormat.format(new Date(gc.getDevice()
|
||||
.getEnrolmentInfo().getDateOfLastUpdate()));
|
||||
}
|
||||
geoCluster = new org.wso2.carbon.device.mgt.jaxrs.beans.GeoCluster(gc.getCoordinates(),
|
||||
gc.getSouthWestBound(), gc.getNorthEastBound(), gc.getCount(), gc.getGeohashPrefix(),
|
||||
deviceIdentification, deviceName, deviceType, lastSeen);
|
||||
geoClusters.add(geoCluster);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while retrieving geo clusters query: " + new Gson().toJson(geoQuery);
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
return Response.ok().entity(geoClusters).build();
|
||||
}
|
||||
|
||||
@Path("stats/geo-view")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public Response getGeoDeviceView(
|
||||
@QueryParam("minLat") double minLat,
|
||||
@QueryParam("maxLat") double maxLat,
|
||||
@QueryParam("minLong") double minLong,
|
||||
@QueryParam("maxLong") double maxLong,
|
||||
@QueryParam("zoom") int zoom,
|
||||
@QueryParam("deviceType") List<String> deviceTypes,
|
||||
@QueryParam("deviceIdentifier") List<String> deviceIdentifiers,
|
||||
@QueryParam("status") List<EnrolmentInfo.Status> statuses,
|
||||
@QueryParam("ownership") List<String> ownerships,
|
||||
@QueryParam("owner") List<String> owners,
|
||||
@QueryParam("noClusters") boolean noClusters,
|
||||
@QueryParam("createdBefore") long createdBefore,
|
||||
@QueryParam("createdAfter") long createdAfter,
|
||||
@QueryParam("updatedBefore") long updatedBefore,
|
||||
@QueryParam("updatedAfter") long updatedAfter) {
|
||||
|
||||
GeoHashLengthStrategy geoHashLengthStrategy = new ZoomGeoHashLengthStrategy();
|
||||
GeoCoordinate southWest = new GeoCoordinate(minLat, minLong);
|
||||
@ -169,15 +233,25 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
|
||||
int geohashLength = geoHashLengthStrategy.getGeohashLength(southWest, northEast, zoom);
|
||||
DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
List<GeoCluster> geoClusters;
|
||||
GeoQuery geoQuery = new GeoQuery(southWest, northEast, geohashLength);
|
||||
geoQuery.setDeviceTypes(deviceTypes);
|
||||
geoQuery.setDeviceIdentifiers(deviceIdentifiers);
|
||||
geoQuery.setStatuses(statuses);
|
||||
geoQuery.setOwners(owners);
|
||||
geoQuery.setOwnerships(ownerships);
|
||||
geoQuery.setNoClusters(noClusters);
|
||||
geoQuery.setCreatedBefore(createdBefore);
|
||||
geoQuery.setCreatedAfter(createdAfter);
|
||||
geoQuery.setUpdatedBefore(updatedBefore);
|
||||
geoQuery.setUpdatedAfter(updatedAfter);
|
||||
try {
|
||||
geoClusters = deviceManagementService.findGeoClusters(deviceType, southWest, northEast, geohashLength);
|
||||
geoClusters = deviceManagementService.findGeoClusters(geoQuery);
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while retrieving geo clusters ";
|
||||
String msg = "Error occurred while retrieving geo clusters for query: " + new Gson().toJson(geoQuery);
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
return Response.ok().entity(geoClusters).build();
|
||||
|
||||
}
|
||||
|
||||
@Path("alerts/{alertType}/{deviceType}/{deviceId}")
|
||||
|
||||
@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.util;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper;
|
||||
@ -64,8 +63,9 @@ public class CredentialManagementResponseBuilder {
|
||||
username = CarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
userStoreManager.updateCredential(username, credentials.getNewPassword(),
|
||||
credentials.getOldPassword());
|
||||
DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
|
||||
//todo:amalka
|
||||
// DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
|
||||
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
|
||||
return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
|
||||
username + " was successfully changed.").build();
|
||||
} catch (UserStoreException e) {
|
||||
@ -108,8 +108,9 @@ public class CredentialManagementResponseBuilder {
|
||||
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build();
|
||||
}
|
||||
userStoreManager.updateCredentialByAdmin(username, credentials.getNewPassword());
|
||||
DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
|
||||
//todo:amalka
|
||||
// DeviceMgtAPIUtils.getIntegrationClientService().resetUserInfo(username,
|
||||
// PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
|
||||
return Response.status(Response.Status.OK).entity("UserImpl password by username: " +
|
||||
username + " was successfully changed.").build();
|
||||
} catch (UserStoreException e) {
|
||||
|
||||
@ -45,31 +45,28 @@ import org.apache.commons.httpclient.protocol.Protocol;
|
||||
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
|
||||
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
|
||||
import org.wso2.carbon.base.ServerConfiguration;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
|
||||
import org.wso2.carbon.base.ServerConfiguration;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.core.util.Utils;
|
||||
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.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
|
||||
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
|
||||
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper;
|
||||
import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationProviderService;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.UnAuthorizedException;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||
@ -171,7 +168,7 @@ public class DeviceMgtAPIUtils {
|
||||
private static KeyStore trustStore;
|
||||
private static char[] keyStorePassword;
|
||||
|
||||
private static IntegrationClientService integrationClientService;
|
||||
// private static IntegrationClientService integrationClientService;
|
||||
private static MetadataManagementService metadataManagementService;
|
||||
private static OTPManagementService otpManagementService;
|
||||
|
||||
@ -373,24 +370,6 @@ public class DeviceMgtAPIUtils {
|
||||
return privacyComplianceProvider;
|
||||
}
|
||||
|
||||
|
||||
public static IntegrationClientService getIntegrationClientService() {
|
||||
if (integrationClientService == null) {
|
||||
synchronized (DeviceMgtAPIUtils.class) {
|
||||
if (integrationClientService == null) {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
integrationClientService = (IntegrationClientService) ctx.getOSGiService(IntegrationClientService.class, null);
|
||||
if (integrationClientService == null) {
|
||||
String msg = "IntegrationClientService is not initialized";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return integrationClientService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializing and accessing method for OTPManagementService.
|
||||
*
|
||||
@ -626,17 +605,18 @@ public class DeviceMgtAPIUtils {
|
||||
return username;
|
||||
}
|
||||
|
||||
public static EventsPublisherService getEventPublisherService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
EventsPublisherService eventsPublisherService =
|
||||
(EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
|
||||
if (eventsPublisherService == null) {
|
||||
String msg = "Event Publisher service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return eventsPublisherService;
|
||||
}
|
||||
// todo: amalka: commented
|
||||
// public static EventsPublisherService getEventPublisherService() {
|
||||
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
// EventsPublisherService eventsPublisherService =
|
||||
// (EventsPublisherService) ctx.getOSGiService(EventsPublisherService.class, null);
|
||||
// if (eventsPublisherService == null) {
|
||||
// String msg = "Event Publisher service has not initialized.";
|
||||
// log.error(msg);
|
||||
// throw new IllegalStateException(msg);
|
||||
// }
|
||||
// return eventsPublisherService;
|
||||
// }
|
||||
|
||||
public static String getStreamDefinition(String deviceType, String tenantDomain) {
|
||||
return STREAM_DEFINITION_PREFIX + tenantDomain + "." + deviceType.replace(" ", ".");
|
||||
|
||||
@ -31,5 +31,5 @@
|
||||
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.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
<Environments>CXF3,Carbon</Environments>
|
||||
</Classloading>
|
||||
|
||||
@ -175,7 +175,8 @@ public class DeviceManagementServiceImplTest {
|
||||
.toReturn(this.deviceAccessAuthorizationService);
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
|
||||
}
|
||||
|
||||
@ -194,19 +195,23 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, null, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, true, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, true,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
}
|
||||
|
||||
@ -319,7 +324,7 @@ public class DeviceManagementServiceImplTest {
|
||||
.toReturn(this.deviceManagementProviderService);
|
||||
Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true);
|
||||
deviceManagementService.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null,
|
||||
DEFAULT_ROLE, DEFAULT_OWNERSHIP, DEFAULT_STATUS_LIST, 1,
|
||||
DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, DEFAULT_STATUS_LIST, 1,
|
||||
null, null, false, 10, 5);
|
||||
}
|
||||
|
||||
@ -339,11 +344,11 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP
|
||||
, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, null, DEFAULT_USERNAME, DEFAULT_ROLE, DEFAULT_OWNERSHIP
|
||||
, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
}
|
||||
|
||||
@ -365,7 +370,8 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode());
|
||||
Mockito.reset(this.deviceAccessAuthorizationService);
|
||||
}
|
||||
@ -386,15 +392,18 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, true, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, true,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, null, "ErrorModifiedSince", false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, null, "ErrorModifiedSince",
|
||||
false, 10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
|
||||
}
|
||||
|
||||
@ -414,15 +423,18 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, since, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, since, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, since, null, true, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, since, null, true,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
|
||||
response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 0, "ErrorSince", null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 0, "ErrorSince", null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
|
||||
}
|
||||
|
||||
@ -444,7 +456,8 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
Mockito.reset(this.deviceManagementProviderService);
|
||||
}
|
||||
@ -466,7 +479,8 @@ public class DeviceManagementServiceImplTest {
|
||||
|
||||
Response response = this.deviceManagementService
|
||||
.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP,
|
||||
DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5);
|
||||
null, DEFAULT_STATUS_LIST, 1, null, null, false,
|
||||
10, 5);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
Mockito.reset(this.deviceAccessAuthorizationService);
|
||||
}
|
||||
|
||||
@ -7,8 +7,9 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.service.api.GeoLocationBasedService;
|
||||
|
||||
@ -33,8 +34,9 @@ public class GeoLocationBasedServiceImplTest {
|
||||
@Test(description = "This method tests the behaviour of getGeoDeviceLocations when there are no devices" +
|
||||
"in the given map boundaries")
|
||||
public void testGetGeoDeviceLocations1() throws DeviceManagementException {
|
||||
GeoQuery geoQuery = new GeoQuery(Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt());
|
||||
Mockito.doReturn(new ArrayList<GeoCluster>()).when(deviceManagementProviderService)
|
||||
.findGeoClusters(null, Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt());
|
||||
.findGeoClusters(geoQuery);
|
||||
Response response = geoLocationBasedService.getGeoDeviceLocations(null, 0.4, 15, 75.6,
|
||||
90.1, 6);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
||||
@ -47,12 +49,14 @@ public class GeoLocationBasedServiceImplTest {
|
||||
List<GeoCluster> geoClusters = new ArrayList<>();
|
||||
geoClusters.add(new GeoCluster(new GeoCoordinate(1.5, 80.7),
|
||||
new GeoCoordinate(1.1, 79.5), new GeoCoordinate(1.9, 82.1), 3,
|
||||
"tb32", "aegtew234", "test1", "android", "1234"));
|
||||
"tb32", null));
|
||||
geoClusters.add(new GeoCluster(new GeoCoordinate(10.2, 86.1),
|
||||
new GeoCoordinate(9.8, 84.7), new GeoCoordinate(11.1, 88.1), 4,
|
||||
"t1gd", "swerty12s", "t2test", "android", "1234"));
|
||||
"t1gd", null));
|
||||
|
||||
GeoQuery geoQuery = new GeoQuery(Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt());
|
||||
Mockito.doReturn(geoClusters).when(deviceManagementProviderService)
|
||||
.findGeoClusters(null, Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt());
|
||||
.findGeoClusters(geoQuery);
|
||||
Response response = geoLocationBasedService.getGeoDeviceLocations(null, 0.4, 15, 75.6,
|
||||
90.1, 6);
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<parent>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -50,7 +50,6 @@
|
||||
<Import-Package>
|
||||
javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}",
|
||||
com.fasterxml.jackson.annotation;version="${jackson-annotations.version}",
|
||||
org.wso2.carbon.analytics.datasource.commons;version="${carbon.analytics.version.range}",
|
||||
io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional,
|
||||
com.google.gson
|
||||
</Import-Package>
|
||||
@ -96,14 +95,6 @@
|
||||
<groupId>org.wso2.orbit.com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
|
||||
@ -40,6 +40,7 @@ public class PaginationRequest {
|
||||
private String ownerRole;
|
||||
private Date since;
|
||||
private String filter;
|
||||
private String serialNumber;
|
||||
private Map<String, Object> property = new HashMap<>();
|
||||
private List<String> statusList = new ArrayList<>();
|
||||
private OperationLogFilters operationLogFilters = new OperationLogFilters();
|
||||
@ -153,6 +154,10 @@ public class PaginationRequest {
|
||||
return this.property.get(key);
|
||||
}
|
||||
|
||||
public String getSerialNumber() { return serialNumber; }
|
||||
|
||||
public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; }
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
Map<String, Object> temp = new HashMap<>();
|
||||
temp.putAll(property);
|
||||
|
||||
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.common.geo.service;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
|
||||
public class GeoCluster {
|
||||
|
||||
private final GeoCoordinate coordinates;
|
||||
private final GeoCoordinate southWestBound;
|
||||
private final GeoCoordinate northEastBound;
|
||||
private final long count;
|
||||
private final String geohashPrefix;
|
||||
private final Device device;
|
||||
|
||||
public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound,
|
||||
long count, String geohashPrefix, Device device) {
|
||||
this.coordinates = coordinates;
|
||||
this.southWestBound = southWestBound;
|
||||
this.northEastBound = northEastBound;
|
||||
this.count = count;
|
||||
this.geohashPrefix = geohashPrefix;
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
public String getGeohashPrefix() {
|
||||
return geohashPrefix;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public GeoCoordinate getCoordinates() {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
public GeoCoordinate getSouthWestBound() {
|
||||
return southWestBound;
|
||||
}
|
||||
|
||||
public GeoCoordinate getNorthEastBound() {
|
||||
return northEastBound;
|
||||
}
|
||||
|
||||
public Device getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.common.geo.service;
|
||||
|
||||
public class GeoCoordinate {
|
||||
|
||||
private final double latitude;
|
||||
private final double longitude;
|
||||
|
||||
public GeoCoordinate(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.common.geo.service;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GeoQuery {
|
||||
|
||||
private final GeoCoordinate southWest;
|
||||
private final GeoCoordinate northEast;
|
||||
private final int geohashLength;
|
||||
private List<String> deviceTypes;
|
||||
private List<String> deviceIdentifiers;
|
||||
private List<EnrolmentInfo.Status> statuses;
|
||||
private List<String> ownerships;
|
||||
private List<String> owners;
|
||||
private boolean noClusters;
|
||||
private long createdBefore;
|
||||
private long createdAfter;
|
||||
private long updatedBefore;
|
||||
private long updatedAfter;
|
||||
|
||||
public GeoQuery(GeoCoordinate southWest, GeoCoordinate northEast, int geohashLength) {
|
||||
this.southWest = southWest;
|
||||
this.northEast = northEast;
|
||||
this.geohashLength = geohashLength;
|
||||
}
|
||||
|
||||
public GeoCoordinate getSouthWest() {
|
||||
return southWest;
|
||||
}
|
||||
|
||||
public GeoCoordinate getNorthEast() {
|
||||
return northEast;
|
||||
}
|
||||
|
||||
public int getGeohashLength() {
|
||||
return geohashLength;
|
||||
}
|
||||
|
||||
public List<String> getDeviceTypes() {
|
||||
return deviceTypes;
|
||||
}
|
||||
|
||||
public void setDeviceTypes(List<String> deviceTypes) {
|
||||
this.deviceTypes = deviceTypes;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIdentifiers() {
|
||||
return deviceIdentifiers;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifiers(List<String> deviceIdentifiers) {
|
||||
this.deviceIdentifiers = deviceIdentifiers;
|
||||
}
|
||||
|
||||
public List<EnrolmentInfo.Status> getStatuses() {
|
||||
return statuses;
|
||||
}
|
||||
|
||||
public void setStatuses(List<EnrolmentInfo.Status> statuses) {
|
||||
this.statuses = statuses;
|
||||
}
|
||||
|
||||
public List<String> getOwnerships() {
|
||||
return ownerships;
|
||||
}
|
||||
|
||||
public void setOwnerships(List<String> ownerships) {
|
||||
this.ownerships = ownerships;
|
||||
}
|
||||
|
||||
public List<String> getOwners() {
|
||||
return owners;
|
||||
}
|
||||
|
||||
public void setOwners(List<String> owners) {
|
||||
this.owners = owners;
|
||||
}
|
||||
|
||||
public boolean isNoClusters() {
|
||||
return noClusters;
|
||||
}
|
||||
|
||||
public void setNoClusters(boolean noClusters) {
|
||||
this.noClusters = noClusters;
|
||||
}
|
||||
|
||||
public long getCreatedBefore() {
|
||||
return createdBefore;
|
||||
}
|
||||
|
||||
public void setCreatedBefore(long createdBefore) {
|
||||
this.createdBefore = createdBefore;
|
||||
}
|
||||
|
||||
public long getCreatedAfter() {
|
||||
return createdAfter;
|
||||
}
|
||||
|
||||
public void setCreatedAfter(long createdAfter) {
|
||||
this.createdAfter = createdAfter;
|
||||
}
|
||||
|
||||
public long getUpdatedBefore() {
|
||||
return updatedBefore;
|
||||
}
|
||||
|
||||
public void setUpdatedBefore(long updatedBefore) {
|
||||
this.updatedBefore = updatedBefore;
|
||||
}
|
||||
|
||||
public long getUpdatedAfter() {
|
||||
return updatedAfter;
|
||||
}
|
||||
|
||||
public void setUpdatedAfter(long updatedAfter) {
|
||||
this.updatedAfter = updatedAfter;
|
||||
}
|
||||
|
||||
}
|
||||
@ -30,7 +30,7 @@ import java.util.List;
|
||||
public class ActivityStatus {
|
||||
|
||||
public enum Status {
|
||||
IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED
|
||||
IN_PROGRESS, PENDING, COMPLETED, ERROR, REPEATED, INVALID, UNAUTHORIZED, NOTNOW
|
||||
}
|
||||
|
||||
@ApiModelProperty(
|
||||
|
||||
@ -27,6 +27,7 @@ public class Item {
|
||||
|
||||
private String label;
|
||||
private String tooltip;
|
||||
private String docLink;
|
||||
private String key;
|
||||
private String value;
|
||||
private boolean isRequired;
|
||||
@ -65,6 +66,16 @@ public class Item {
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
@XmlElement(name = "DocLink")
|
||||
public String getDocLink() {
|
||||
return docLink;
|
||||
}
|
||||
|
||||
public void setDocLink(String docLink) {
|
||||
this.docLink = docLink;
|
||||
}
|
||||
|
||||
|
||||
@XmlElement(name = "Key", required = true)
|
||||
public String getKey() {
|
||||
return key;
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>device-mgt</artifactId>
|
||||
<version>4.1.16-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@ -78,8 +78,8 @@
|
||||
<Private-Package>org.wso2.carbon.device.mgt.core.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.apache.axis2.*;version="${axis2.osgi.version.range}",
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
|
||||
org.osgi.service.*;version="${imp.package.version.osgi.service}",
|
||||
org.apache.commons.logging,
|
||||
javax.naming,
|
||||
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
|
||||
@ -90,7 +90,6 @@
|
||||
org.wso2.carbon.core,
|
||||
org.wso2.carbon.utils.*,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.analytics.data.publisher.service,
|
||||
org.wso2.carbon.user.api,
|
||||
org.wso2.carbon.user.core.*,
|
||||
org.wso2.carbon.registry.core.service,
|
||||
@ -104,8 +103,6 @@
|
||||
org.wso2.carbon.ndatasource.core,
|
||||
org.wso2.carbon.ntask.core.*,
|
||||
org.wso2.carbon.ntask.common,
|
||||
org.apache.catalina,
|
||||
org.apache.catalina.core,
|
||||
org.apache.commons.collections;version="${commons-collections.version.range}",
|
||||
org.wso2.carbon.email.sender.*,
|
||||
io.swagger.annotations.*;resolution:=optional,
|
||||
@ -122,9 +119,7 @@
|
||||
org.wso2.carbon.device.mgt.core.*
|
||||
</Export-Package>
|
||||
<Embed-Dependency>
|
||||
javax.ws.rs-api,
|
||||
scribe;scope=compile|runtime;inline=false,
|
||||
javassist;inline=false
|
||||
</Embed-Dependency>
|
||||
<DynamicImport-Package>*</DynamicImport-Package>
|
||||
</instructions>
|
||||
@ -166,32 +161,6 @@
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon.registry</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.indexing</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon.identity.framework</groupId>
|
||||
<artifactId>org.wso2.carbon.user.mgt</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
|
||||
@ -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 IOT_GATEWAY_HOST = "iot.gateway.host";
|
||||
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 =
|
||||
"/api-application-registration/register";
|
||||
public static final String AUTHORIZATION_HEADER = "authorization";
|
||||
|
||||
@ -31,6 +31,7 @@ public class UIConfiguration {
|
||||
private AppRegistration appRegistration;
|
||||
private List<String> scopes;
|
||||
private boolean isSsoEnable;
|
||||
private int sessionTimeOut;
|
||||
|
||||
@XmlElement(name = "AppRegistration", required=true)
|
||||
public AppRegistration getAppRegistration() {
|
||||
@ -59,4 +60,13 @@ public class UIConfiguration {
|
||||
public void setSsoEnable(boolean ssoEnable) {
|
||||
isSsoEnable = ssoEnable;
|
||||
}
|
||||
|
||||
@XmlElement(name = "SessionTimeOut")
|
||||
public int getSessionTimeOut() {
|
||||
return sessionTimeOut;
|
||||
}
|
||||
|
||||
public void setSessionTimeOut(int sessionTimeOut) {
|
||||
this.sessionTimeOut = sessionTimeOut;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,9 +46,10 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceData;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceMonitoringData;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
@ -555,14 +556,11 @@ public interface DeviceDAO {
|
||||
* This method is used to retrieve the details of geoclusters formed relatively to the zoom level and map
|
||||
* boundaries.
|
||||
*
|
||||
* @param deviceType Optional device type name.
|
||||
* @param southWest the coordinates of southWest corner of the map.
|
||||
* @param northEast the coordinates of northEast corner of the map.
|
||||
* @param geoQuery the query to determine the geo data.
|
||||
* @param tenantId tenant id.
|
||||
* @return returns a list of enrolment info objects.
|
||||
*/
|
||||
List<GeoCluster> findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast,
|
||||
int geohashLength,int tenantId) throws DeviceManagementDAOException;
|
||||
List<GeoCluster> findGeoClusters(GeoQuery geoQuery, int tenantId) throws DeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* This method is used to identify whether given device ids are exist or not.
|
||||
@ -653,14 +651,12 @@ public interface DeviceDAO {
|
||||
*
|
||||
* @param deviceIds device ids of the subscribed devices.
|
||||
* @param tenantId Id of the current tenant.
|
||||
* @param offsetValue offset value for get paginated request.
|
||||
* @param limitValue limit value for get paginated request.
|
||||
* @param status status of the devices.
|
||||
* @param request paginated request object.
|
||||
* @return devices - subscribed device details list
|
||||
* @throws DeviceManagementDAOException if connections establishment fails.
|
||||
*/
|
||||
List<Device> getSubscribedDevices(int offsetValue, int limitValue, List<Integer> deviceIds,
|
||||
int tenantId, List<String> status) throws DeviceManagementDAOException;
|
||||
List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
|
||||
throws DeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* @param deviceIds device ids of the subscribed devices.
|
||||
|
||||
@ -48,13 +48,14 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.DevicePropertyInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceData;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshot;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceMonitoringData;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoQuery;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -64,6 +65,7 @@ import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -1850,59 +1852,158 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
||||
return tenants;
|
||||
}
|
||||
|
||||
public List<GeoCluster> findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast,
|
||||
int geohashLength, int tenantId) throws DeviceManagementDAOException {
|
||||
public List<GeoCluster> findGeoClusters(GeoQuery geoQuery, int tenantId) throws DeviceManagementDAOException {
|
||||
Connection conn;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
List<GeoCluster> geoClusters = new ArrayList<>();
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String sql = "SELECT AVG(DEVICE_LOCATION.LATITUDE) AS LATITUDE,AVG(DEVICE_LOCATION.LONGITUDE) AS LONGITUDE," +
|
||||
" MIN(DEVICE_LOCATION.LATITUDE) AS MIN_LATITUDE, MAX(DEVICE_LOCATION.LATITUDE) AS MAX_LATITUDE," +
|
||||
String sql = "SELECT AVG(DEVICE_LOCATION.LATITUDE) AS LATITUDE, " +
|
||||
"AVG(DEVICE_LOCATION.LONGITUDE) AS LONGITUDE, " +
|
||||
"MIN(DEVICE_LOCATION.LATITUDE) AS MIN_LATITUDE, " +
|
||||
"MAX(DEVICE_LOCATION.LATITUDE) AS MAX_LATITUDE, " +
|
||||
"MIN(DEVICE_LOCATION.LONGITUDE) AS MIN_LONGITUDE, " +
|
||||
"MAX(DEVICE_LOCATION.LONGITUDE) AS MAX_LONGITUDE, " +
|
||||
" SUBSTRING(DEVICE_LOCATION.GEO_HASH,1,?) AS GEOHASH_PREFIX, COUNT(*) AS COUNT," +
|
||||
"SUBSTRING(DEVICE_LOCATION.GEO_HASH,1,?) AS GEOHASH_PREFIX, " +
|
||||
"COUNT(DEVICE_LOCATION.ID) AS COUNT, " +
|
||||
"MIN(DEVICE.ID) AS DEVICE_ID, " +
|
||||
"MIN(DEVICE.NAME) AS DEVICE_NAME, " +
|
||||
"MIN(DEVICE.DESCRIPTION) AS DESCRIPTION, " +
|
||||
"MIN(DEVICE_TYPE.NAME) AS DEVICE_TYPE, " +
|
||||
"MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION, " +
|
||||
" MIN(DEVICE.NAME) AS NAME," +
|
||||
" MIN(DEVICE_TYPE.NAME) AS TYPE, " +
|
||||
" MIN(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP " +
|
||||
"FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION,DM_DEVICE AS DEVICE, DM_DEVICE_TYPE AS DEVICE_TYPE " +
|
||||
"WHERE DEVICE_LOCATION.LATITUDE BETWEEN ? AND ? AND " +
|
||||
"DEVICE_LOCATION.LONGITUDE BETWEEN ? AND ? AND " +
|
||||
"DEVICE.TENANT_ID=? AND " +
|
||||
"DEVICE.ID=DEVICE_LOCATION.DEVICE_ID AND DEVICE.DEVICE_TYPE_ID=DEVICE_TYPE.ID";
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
sql += " AND DEVICE_TYPE.NAME=?";
|
||||
"MIN(ENROLMENT.ID) AS ENROLMENT_ID, " +
|
||||
"MIN(ENROLMENT.OWNER) AS OWNER, " +
|
||||
"MIN(ENROLMENT.OWNERSHIP) AS OWNERSHIP, " +
|
||||
"MIN(ENROLMENT.IS_TRANSFERRED) AS IS_TRANSFERRED, " +
|
||||
"MIN(ENROLMENT.DATE_OF_ENROLMENT) AS DATE_OF_ENROLMENT, " +
|
||||
"MIN(ENROLMENT.DATE_OF_LAST_UPDATE) AS DATE_OF_LAST_UPDATE, " +
|
||||
"MIN(ENROLMENT.STATUS) AS STATUS " +
|
||||
"FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION, DM_DEVICE AS DEVICE, " +
|
||||
"DM_DEVICE_TYPE AS DEVICE_TYPE, DM_ENROLMENT AS ENROLMENT " +
|
||||
"WHERE DEVICE_LOCATION.LATITUDE BETWEEN ? AND ? " +
|
||||
"AND DEVICE_LOCATION.LONGITUDE BETWEEN ? AND ? ";
|
||||
if (geoQuery.getDeviceTypes() != null && !geoQuery.getDeviceTypes().isEmpty()) {
|
||||
sql += "AND DEVICE_TYPE.NAME IN (";
|
||||
sql += String.join(", ",
|
||||
Collections.nCopies(geoQuery.getDeviceTypes().size(), "?"));
|
||||
sql += ") ";
|
||||
}
|
||||
sql += " GROUP BY GEOHASH_PREFIX";
|
||||
if (geoQuery.getDeviceIdentifiers() != null && !geoQuery.getDeviceIdentifiers().isEmpty()) {
|
||||
sql += "AND DEVICE.DEVICE_IDENTIFICATION IN (";
|
||||
sql += String.join(", ",
|
||||
Collections.nCopies(geoQuery.getDeviceIdentifiers().size(), "?"));
|
||||
sql += ") ";
|
||||
}
|
||||
if (geoQuery.getOwners() != null && !geoQuery.getOwners().isEmpty()) {
|
||||
sql += "AND ENROLMENT.OWNER IN (";
|
||||
sql += String.join(", ",
|
||||
Collections.nCopies(geoQuery.getOwners().size(), "?"));
|
||||
sql += ") ";
|
||||
}
|
||||
if (geoQuery.getOwnerships() != null && !geoQuery.getOwnerships().isEmpty()) {
|
||||
sql += "AND ENROLMENT.OWNERSHIP IN (";
|
||||
sql += String.join(", ",
|
||||
Collections.nCopies(geoQuery.getOwnerships().size(), "?"));
|
||||
sql += ") ";
|
||||
}
|
||||
if (geoQuery.getStatuses() != null && !geoQuery.getStatuses().isEmpty()) {
|
||||
sql += "AND ENROLMENT.STATUS IN (";
|
||||
sql += String.join(", ",
|
||||
Collections.nCopies(geoQuery.getStatuses().size(), "?"));
|
||||
sql += ") ";
|
||||
} else {
|
||||
sql += "AND ENROLMENT.STATUS != 'REMOVED' ";
|
||||
}
|
||||
if (geoQuery.getCreatedBefore() != 0 || geoQuery.getCreatedAfter() != 0) {
|
||||
sql += "AND ENROLMENT.DATE_OF_ENROLMENT BETWEEN ? AND ? ";
|
||||
}
|
||||
if (geoQuery.getUpdatedBefore() != 0 || geoQuery.getUpdatedAfter() != 0) {
|
||||
sql += "AND ENROLMENT.DATE_OF_LAST_UPDATE BETWEEN ? AND ? ";
|
||||
}
|
||||
sql += "AND DEVICE.ID = DEVICE_LOCATION.DEVICE_ID AND DEVICE.DEVICE_TYPE_ID = DEVICE_TYPE.ID " +
|
||||
"AND DEVICE.ID = ENROLMENT.DEVICE_ID " +
|
||||
"AND DEVICE.TENANT_ID = ? AND DEVICE.TENANT_ID = ENROLMENT.TENANT_ID GROUP BY GEOHASH_PREFIX";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, geohashLength);
|
||||
stmt.setDouble(2, southWest.getLatitude());
|
||||
stmt.setDouble(3, northEast.getLatitude());
|
||||
stmt.setDouble(4, southWest.getLongitude());
|
||||
stmt.setDouble(5, northEast.getLongitude());
|
||||
stmt.setDouble(6, tenantId);
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
stmt.setString(7, deviceType);
|
||||
|
||||
int index = 1;
|
||||
stmt.setInt(index++, geoQuery.getGeohashLength());
|
||||
stmt.setDouble(index++, geoQuery.getSouthWest().getLatitude());
|
||||
stmt.setDouble(index++, geoQuery.getNorthEast().getLatitude());
|
||||
stmt.setDouble(index++, geoQuery.getSouthWest().getLongitude());
|
||||
stmt.setDouble(index++, geoQuery.getNorthEast().getLongitude());
|
||||
if (geoQuery.getDeviceTypes() != null) {
|
||||
for (String s: geoQuery.getDeviceTypes()) {
|
||||
stmt.setString(index++, s);
|
||||
}
|
||||
}
|
||||
if (geoQuery.getDeviceIdentifiers() != null) {
|
||||
for (String s: geoQuery.getDeviceIdentifiers()) {
|
||||
stmt.setString(index++, s);
|
||||
}
|
||||
}
|
||||
if (geoQuery.getOwners() != null) {
|
||||
for (String s: geoQuery.getOwners()) {
|
||||
stmt.setString(index++, s);
|
||||
}
|
||||
}
|
||||
if (geoQuery.getOwnerships() != null) {
|
||||
for (String s: geoQuery.getOwnerships()) {
|
||||
stmt.setString(index++, s);
|
||||
}
|
||||
}
|
||||
if (geoQuery.getStatuses() != null) {
|
||||
for (Status s: geoQuery.getStatuses()) {
|
||||
stmt.setString(index++, s.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (geoQuery.getCreatedBefore() != 0 || geoQuery.getCreatedAfter() != 0) {
|
||||
stmt.setTimestamp(index++, new Timestamp(geoQuery.getCreatedAfter()));
|
||||
if (geoQuery.getCreatedBefore() == 0) {
|
||||
stmt.setTimestamp(index++, new Timestamp(System.currentTimeMillis()));
|
||||
} else {
|
||||
stmt.setTimestamp(index++, new Timestamp(geoQuery.getCreatedBefore()));
|
||||
}
|
||||
}
|
||||
if (geoQuery.getUpdatedBefore() != 0 || geoQuery.getUpdatedAfter() != 0) {
|
||||
stmt.setTimestamp(index++, new Timestamp(geoQuery.getUpdatedAfter()));
|
||||
if (geoQuery.getUpdatedBefore() == 0) {
|
||||
stmt.setTimestamp(index++, new Timestamp(System.currentTimeMillis()));
|
||||
} else {
|
||||
stmt.setTimestamp(index++, new Timestamp(geoQuery.getUpdatedBefore()));
|
||||
}
|
||||
}
|
||||
stmt.setInt(index, tenantId);
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
double latitude;
|
||||
double longitude;
|
||||
double minLatitude;
|
||||
double maxLatitude;
|
||||
double minLongitude;
|
||||
double maxLongitude;
|
||||
long count;
|
||||
String geohashPrefix;
|
||||
Device device;
|
||||
while (rs.next()) {
|
||||
double latitude = rs.getDouble("LATITUDE");
|
||||
double longitude = rs.getDouble("LONGITUDE");
|
||||
double min_latitude = rs.getDouble("MIN_LATITUDE");
|
||||
double max_latitude = rs.getDouble("MAX_LATITUDE");
|
||||
double min_longitude = rs.getDouble("MIN_LONGITUDE");
|
||||
double max_longitude = rs.getDouble("MAX_LONGITUDE");
|
||||
String device_identification = rs.getString("DEVICE_IDENTIFICATION");
|
||||
String device_name = rs.getString("NAME");
|
||||
String device_type = rs.getString("TYPE");
|
||||
String last_seen = rs.getString("LAST_UPDATED_TIMESTAMP");
|
||||
long count = rs.getLong("COUNT");
|
||||
String geohashPrefix = rs.getString("GEOHASH_PREFIX");
|
||||
latitude = rs.getDouble("LATITUDE");
|
||||
longitude = rs.getDouble("LONGITUDE");
|
||||
minLatitude = rs.getDouble("MIN_LATITUDE");
|
||||
maxLatitude = rs.getDouble("MAX_LATITUDE");
|
||||
minLongitude = rs.getDouble("MIN_LONGITUDE");
|
||||
maxLongitude = rs.getDouble("MAX_LONGITUDE");
|
||||
count = rs.getLong("COUNT");
|
||||
geohashPrefix = rs.getString("GEOHASH_PREFIX");
|
||||
if (count == 1) {
|
||||
device = DeviceManagementDAOUtil.loadDevice(rs);
|
||||
} else {
|
||||
device = null;
|
||||
}
|
||||
geoClusters.add(new GeoCluster(new GeoCoordinate(latitude, longitude),
|
||||
new GeoCoordinate(min_latitude, min_longitude), new GeoCoordinate(max_latitude, max_longitude),
|
||||
count, geohashPrefix, device_identification, device_name, device_type, last_seen));
|
||||
new GeoCoordinate(minLatitude, minLongitude), new GeoCoordinate(maxLatitude, maxLongitude),
|
||||
count, geohashPrefix, device));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new DeviceManagementDAOException("Error occurred while retrieving information of " +
|
||||
|
||||
@ -67,6 +67,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
String serial = request.getSerialNumber();
|
||||
boolean isSerialProvided = false;
|
||||
|
||||
|
||||
try {
|
||||
Connection conn = getConnection();
|
||||
@ -87,10 +90,19 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"d.DESCRIPTION, " +
|
||||
"d.NAME, " +
|
||||
"d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE " +
|
||||
"FROM DM_DEVICE d, DM_DEVICE_TYPE t ";
|
||||
"t.NAME AS DEVICE_TYPE ";
|
||||
|
||||
sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
if (serial != null) {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " +
|
||||
"WHERE DEVICE_TYPE_ID = t.ID " +
|
||||
"AND d.ID= i.DEVICE_ID " +
|
||||
"AND i.KEY_FIELD = 'serial' " +
|
||||
"AND i.VALUE_FIELD = ? " +
|
||||
"AND d.TENANT_ID = ? ";
|
||||
isSerialProvided = true;
|
||||
} else {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ";
|
||||
}
|
||||
//Add query for last updated timestamp
|
||||
if (since != null) {
|
||||
sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?";
|
||||
@ -128,6 +140,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIdx = 1;
|
||||
if (isSerialProvided) {
|
||||
stmt.setString(paramIdx++, serial);
|
||||
}
|
||||
stmt.setInt(paramIdx++, tenantId);
|
||||
if (isSinceProvided) {
|
||||
stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime()));
|
||||
@ -877,11 +892,15 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
||||
List<Integer> deviceIds, int tenantId, List<String> status)
|
||||
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
|
||||
throws DeviceManagementDAOException {
|
||||
Connection conn;
|
||||
|
||||
int limitValue = request.getRowCount();
|
||||
int offsetValue = request.getStartIndex();
|
||||
List<String> status = request.getStatusList();
|
||||
String name = request.getDeviceName();
|
||||
String user = request.getOwner();
|
||||
String ownership = request.getOwnership();
|
||||
try {
|
||||
List<Device> devices = new ArrayList<>();
|
||||
if (deviceIds.isEmpty()) {
|
||||
@ -891,6 +910,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
int index = 1;
|
||||
|
||||
boolean isStatusProvided = false;
|
||||
boolean isDeviceNameProvided = false;
|
||||
boolean isOwnerProvided = false;
|
||||
boolean isOwnershipProvided = false;
|
||||
|
||||
StringJoiner joiner = new StringJoiner(",",
|
||||
"SELECT "
|
||||
+ "DM_DEVICE.ID AS DEVICE_ID, "
|
||||
@ -918,6 +941,18 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
||||
String query = joiner.toString();
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
query += " AND DM_DEVICE.NAME LIKE ?";
|
||||
isDeviceNameProvided = true;
|
||||
}
|
||||
if (ownership != null && !ownership.isEmpty()) {
|
||||
query += " AND e.OWNERSHIP = ?";
|
||||
isOwnershipProvided = true;
|
||||
}
|
||||
if (user != null && !user.isEmpty()) {
|
||||
query += " AND e.OWNER = ?";
|
||||
isOwnerProvided = true;
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
query += buildStatusQuery(status);
|
||||
isStatusProvided = true;
|
||||
@ -930,8 +965,16 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
for (Integer deviceId : deviceIds) {
|
||||
ps.setObject(index++, deviceId);
|
||||
}
|
||||
|
||||
ps.setInt(index++, tenantId);
|
||||
if (isDeviceNameProvided) {
|
||||
ps.setString(index++, name + "%");
|
||||
}
|
||||
if (isOwnershipProvided) {
|
||||
ps.setString(index++, ownership);
|
||||
}
|
||||
if (isOwnerProvided) {
|
||||
ps.setString(index++, user);
|
||||
}
|
||||
if (isStatusProvided) {
|
||||
for (String deviceStatus : status) {
|
||||
ps.setString(index++, deviceStatus);
|
||||
|
||||
@ -68,6 +68,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
String serial = request.getSerialNumber();
|
||||
boolean isSerialProvided = false;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
@ -88,9 +90,19 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"d.DESCRIPTION, " +
|
||||
"d.NAME, " +
|
||||
"d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE " +
|
||||
"FROM DM_DEVICE d, " +
|
||||
"DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
"t.NAME AS DEVICE_TYPE ";
|
||||
|
||||
if (serial != null) {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " +
|
||||
"WHERE DEVICE_TYPE_ID = t.ID " +
|
||||
"AND d.ID= i.DEVICE_ID " +
|
||||
"AND i.KEY_FIELD = 'serial' " +
|
||||
"AND i.VALUE_FIELD = ? " +
|
||||
"AND d.TENANT_ID = ? ";
|
||||
isSerialProvided = true;
|
||||
} else {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ";
|
||||
}
|
||||
//Add query for last updated timestamp
|
||||
if (since != null) {
|
||||
sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?";
|
||||
@ -128,6 +140,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIdx = 1;
|
||||
if (isSerialProvided) {
|
||||
stmt.setString(paramIdx++, serial);
|
||||
}
|
||||
stmt.setInt(paramIdx++, tenantId);
|
||||
if (isSinceProvided) {
|
||||
stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime()));
|
||||
@ -847,11 +862,15 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
||||
List<Integer> deviceIds, int tenantId, List<String> status)
|
||||
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
|
||||
throws DeviceManagementDAOException {
|
||||
Connection conn;
|
||||
|
||||
int limitValue = request.getRowCount();
|
||||
int offsetValue = request.getStartIndex();
|
||||
List<String> status = request.getStatusList();
|
||||
String name = request.getDeviceName();
|
||||
String user = request.getOwner();
|
||||
String ownership = request.getOwnership();
|
||||
try {
|
||||
List<Device> devices = new ArrayList<>();
|
||||
if (deviceIds.isEmpty()) {
|
||||
@ -861,6 +880,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
int index = 1;
|
||||
|
||||
boolean isStatusProvided = false;
|
||||
boolean isDeviceNameProvided = false;
|
||||
boolean isOwnerProvided = false;
|
||||
boolean isOwnershipProvided = false;
|
||||
StringJoiner joiner = new StringJoiner(",",
|
||||
"SELECT "
|
||||
+ "DM_DEVICE.ID AS DEVICE_ID, "
|
||||
@ -888,6 +910,18 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
||||
String query = joiner.toString();
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
query += " AND DM_DEVICE.NAME LIKE ?";
|
||||
isDeviceNameProvided = true;
|
||||
}
|
||||
if (ownership != null && !ownership.isEmpty()) {
|
||||
query += " AND e.OWNERSHIP = ?";
|
||||
isOwnershipProvided = true;
|
||||
}
|
||||
if (user != null && !user.isEmpty()) {
|
||||
query += " AND e.OWNER = ?";
|
||||
isOwnerProvided = true;
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
query += buildStatusQuery(status);
|
||||
isStatusProvided = true;
|
||||
@ -902,6 +936,15 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
ps.setInt(index++, tenantId);
|
||||
if (isDeviceNameProvided) {
|
||||
ps.setString(index++, name + "%");
|
||||
}
|
||||
if (isOwnershipProvided) {
|
||||
ps.setString(index++, ownership);
|
||||
}
|
||||
if (isOwnerProvided) {
|
||||
ps.setString(index++, user);
|
||||
}
|
||||
if (isStatusProvided) {
|
||||
for (String deviceStatus : status) {
|
||||
ps.setString(index++, deviceStatus);
|
||||
|
||||
@ -67,6 +67,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
String serial = request.getSerialNumber();
|
||||
boolean isSerialProvided = false;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
@ -87,11 +89,19 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"d.DESCRIPTION, " +
|
||||
"d.NAME, " +
|
||||
"d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE " +
|
||||
"FROM DM_DEVICE d, " +
|
||||
"DM_DEVICE_TYPE t " +
|
||||
"t.NAME AS DEVICE_TYPE ";
|
||||
|
||||
if (serial != null) {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " +
|
||||
"WHERE DEVICE_TYPE_ID = t.ID " +
|
||||
"AND d.ID= i.DEVICE_ID " +
|
||||
"AND i.KEY_FIELD = 'serial' " +
|
||||
"AND i.VALUE_FIELD = ? " +
|
||||
"AND d.TENANT_ID = ? ";
|
||||
isSerialProvided = true;
|
||||
} else {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ";
|
||||
}
|
||||
//Add the query for device-type
|
||||
if (deviceType != null && !deviceType.isEmpty()) {
|
||||
sql = sql + " AND t.NAME = ?";
|
||||
@ -124,6 +134,9 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIdx = 1;
|
||||
if (isSerialProvided) {
|
||||
stmt.setString(paramIdx++, serial);
|
||||
}
|
||||
stmt.setInt(paramIdx++, tenantId);
|
||||
if (isDeviceTypeProvided) {
|
||||
stmt.setString(paramIdx++, deviceType);
|
||||
@ -827,11 +840,15 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
||||
List<Integer> deviceIds, int tenantId, List<String> status)
|
||||
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
|
||||
throws DeviceManagementDAOException {
|
||||
Connection conn;
|
||||
|
||||
int limitValue = request.getRowCount();
|
||||
int offsetValue = request.getStartIndex();
|
||||
List<String> status = request.getStatusList();
|
||||
String name = request.getDeviceName();
|
||||
String user = request.getOwner();
|
||||
String ownership = request.getOwnership();
|
||||
try {
|
||||
List<Device> devices = new ArrayList<>();
|
||||
if (deviceIds.isEmpty()) {
|
||||
@ -841,6 +858,9 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
int index = 1;
|
||||
|
||||
boolean isStatusProvided = false;
|
||||
boolean isDeviceNameProvided = false;
|
||||
boolean isOwnerProvided = false;
|
||||
boolean isOwnershipProvided = false;
|
||||
StringJoiner joiner = new StringJoiner(",",
|
||||
"SELECT "
|
||||
+ "DM_DEVICE.ID AS DEVICE_ID, "
|
||||
@ -868,6 +888,18 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
||||
String query = joiner.toString();
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
query += " AND DM_DEVICE.NAME LIKE ?";
|
||||
isDeviceNameProvided = true;
|
||||
}
|
||||
if (ownership != null && !ownership.isEmpty()) {
|
||||
query += " AND e.OWNERSHIP = ?";
|
||||
isOwnershipProvided = true;
|
||||
}
|
||||
if (user != null && !user.isEmpty()) {
|
||||
query += " AND e.OWNER = ?";
|
||||
isOwnerProvided = true;
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
query += buildStatusQuery(status);
|
||||
isStatusProvided = true;
|
||||
@ -882,6 +914,15 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
ps.setInt(index++, tenantId);
|
||||
if (isDeviceNameProvided) {
|
||||
ps.setString(index++, name + "%");
|
||||
}
|
||||
if (isOwnershipProvided) {
|
||||
ps.setString(index++, ownership);
|
||||
}
|
||||
if (isOwnerProvided) {
|
||||
ps.setString(index++, user);
|
||||
}
|
||||
if (isStatusProvided) {
|
||||
for (String deviceStatus : status) {
|
||||
ps.setString(index++, deviceStatus);
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.core.dao.impl.device;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.Count;
|
||||
@ -29,8 +28,8 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.core.dao.impl.AbstractDeviceDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCluster;
|
||||
import org.wso2.carbon.device.mgt.common.geo.service.GeoCoordinate;
|
||||
import org.wso2.carbon.device.mgt.core.report.mgt.Constants;
|
||||
|
||||
import java.sql.Connection;
|
||||
@ -69,6 +68,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
boolean isStatusProvided = false;
|
||||
Date since = request.getSince();
|
||||
boolean isSinceProvided = false;
|
||||
String serial = request.getSerialNumber();
|
||||
boolean isSerialProvided = false;
|
||||
|
||||
try {
|
||||
conn = getConnection();
|
||||
@ -89,8 +90,19 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
"d.DESCRIPTION, " +
|
||||
"d.NAME, " +
|
||||
"d.DEVICE_IDENTIFICATION, " +
|
||||
"t.NAME AS DEVICE_TYPE " +
|
||||
"FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?";
|
||||
"t.NAME AS DEVICE_TYPE ";
|
||||
|
||||
if (serial != null) {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t, DM_DEVICE_INFO i " +
|
||||
"WHERE DEVICE_TYPE_ID = t.ID " +
|
||||
"AND d.ID= i.DEVICE_ID " +
|
||||
"AND i.KEY_FIELD = 'serial' " +
|
||||
"AND i.VALUE_FIELD = ? " +
|
||||
"AND d.TENANT_ID = ? ";
|
||||
isSerialProvided = true;
|
||||
} else {
|
||||
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ";
|
||||
}
|
||||
//Add query for last updated timestamp
|
||||
if (since != null) {
|
||||
sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?";
|
||||
@ -128,6 +140,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
|
||||
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
|
||||
int paramIdx = 1;
|
||||
if (isSerialProvided) {
|
||||
stmt.setString(paramIdx++, serial);
|
||||
}
|
||||
stmt.setInt(paramIdx++, tenantId);
|
||||
if (isSinceProvided) {
|
||||
stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime()));
|
||||
@ -693,11 +708,15 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
||||
List<Integer> deviceIds, int tenantId, List<String> status)
|
||||
public List<Device> getSubscribedDevices(PaginationRequest request, List<Integer> deviceIds, int tenantId)
|
||||
throws DeviceManagementDAOException {
|
||||
Connection conn;
|
||||
|
||||
int limitValue = request.getRowCount();
|
||||
int offsetValue = request.getStartIndex();
|
||||
List<String> status = request.getStatusList();
|
||||
String name = request.getDeviceName();
|
||||
String user = request.getOwner();
|
||||
String ownership = request.getOwnership();
|
||||
try {
|
||||
List<Device> devices = new ArrayList<>();
|
||||
if (deviceIds.isEmpty()) {
|
||||
@ -707,6 +726,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
int index = 1;
|
||||
|
||||
boolean isStatusProvided = false;
|
||||
boolean isDeviceNameProvided = false;
|
||||
boolean isOwnerProvided = false;
|
||||
boolean isOwnershipProvided = false;
|
||||
StringJoiner joiner = new StringJoiner(",",
|
||||
"SELECT "
|
||||
+ "DM_DEVICE.ID AS DEVICE_ID, "
|
||||
@ -734,6 +756,18 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
||||
String query = joiner.toString();
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
query += " AND DM_DEVICE.NAME LIKE ?";
|
||||
isDeviceNameProvided = true;
|
||||
}
|
||||
if (ownership != null && !ownership.isEmpty()) {
|
||||
query += " AND e.OWNERSHIP = ?";
|
||||
isOwnershipProvided = true;
|
||||
}
|
||||
if (user != null && !user.isEmpty()) {
|
||||
query += " AND e.OWNER = ?";
|
||||
isOwnerProvided = true;
|
||||
}
|
||||
if (status != null && !status.isEmpty()) {
|
||||
query += buildStatusQuery(status);
|
||||
isStatusProvided = true;
|
||||
@ -748,6 +782,15 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
|
||||
ps.setInt(index++, tenantId);
|
||||
if (isDeviceNameProvided) {
|
||||
ps.setString(index++, name + "%");
|
||||
}
|
||||
if (isOwnershipProvided) {
|
||||
ps.setString(index++, ownership);
|
||||
}
|
||||
if (isOwnerProvided) {
|
||||
ps.setString(index++, user);
|
||||
}
|
||||
if (isStatusProvided) {
|
||||
for (String deviceStatus : status) {
|
||||
ps.setString(index++, deviceStatus);
|
||||
@ -1089,6 +1132,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Override for MSSQL
|
||||
/*
|
||||
@Override
|
||||
public List<GeoCluster> findGeoClusters(String deviceType, GeoCoordinate southWest, GeoCoordinate northEast,
|
||||
int geohashLength, int tenantId) throws DeviceManagementDAOException {
|
||||
@ -1163,4 +1208,5 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
||||
}
|
||||
return geoClusters;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@ -22,22 +22,17 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
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.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceData;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceDetailsWrapper;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.EventPublishingException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.core.config.tenant.PlatformConfigurationManagementServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||
@ -46,18 +41,14 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManag
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException;
|
||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||
|
||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.report.mgt.Constants;
|
||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||
import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil;
|
||||
import org.wso2.carbon.user.api.UserRealm;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -178,9 +169,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
deviceInfo.getAvailableRAMMemory(),
|
||||
deviceInfo.isPluggedIn()
|
||||
};
|
||||
DeviceManagerUtil.getEventPublisherService().publishEvent(
|
||||
DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
|
||||
);
|
||||
//todo:amalka
|
||||
// DeviceManagerUtil.getEventPublisherService().publishEvent(
|
||||
// DEVICE_INFO_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
|
||||
// );
|
||||
}
|
||||
} catch (TransactionManagementException e) {
|
||||
throw new DeviceDetailsMgtException("Transactional error occurred while adding the device information.", e);
|
||||
@ -193,8 +185,9 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
DeviceManagementDAOFactory.rollbackTransaction();
|
||||
throw new DeviceDetailsMgtException("Error occurred while updating the last update timestamp of the " +
|
||||
"device", e);
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
|
||||
//todo:amalka
|
||||
// } catch (DataPublisherConfigurationException e) {
|
||||
// throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
|
||||
} finally {
|
||||
DeviceManagementDAOFactory.closeConnection();
|
||||
}
|
||||
@ -389,9 +382,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
deviceLocation.getBearing(),
|
||||
deviceLocation.getDistance()
|
||||
};
|
||||
DeviceManagerUtil.getEventPublisherService().publishEvent(
|
||||
LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
|
||||
);
|
||||
//todo:amalka
|
||||
// DeviceManagerUtil.getEventPublisherService().publishEvent(
|
||||
// LOCATION_EVENT_STREAM_DEFINITION, "1.0.0", metaData, new Object[0], payload
|
||||
// );
|
||||
}
|
||||
DeviceManagementDAOFactory.commitTransaction();
|
||||
} catch (TransactionManagementException e) {
|
||||
@ -403,9 +397,10 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
|
||||
} catch (DeviceManagementException e) {
|
||||
DeviceManagementDAOFactory.rollbackTransaction();
|
||||
throw new DeviceDetailsMgtException("Error occurred while getting the device information.", e);
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
DeviceManagementDAOFactory.rollbackTransaction();
|
||||
throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
|
||||
//todo:amalka
|
||||
// } catch (DataPublisherConfigurationException e) {
|
||||
// DeviceManagementDAOFactory.rollbackTransaction();
|
||||
// throw new DeviceDetailsMgtException("Error occurred while publishing the device location information.", e);
|
||||
} finally {
|
||||
DeviceManagementDAOFactory.closeConnection();
|
||||
}
|
||||
|
||||
@ -22,6 +22,10 @@ public class CommandOperation extends Operation {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
public CommandOperation() {
|
||||
setControl(Control.NO_REPEAT);
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
@ -34,8 +38,4 @@ public class CommandOperation extends Operation {
|
||||
return Type.COMMAND;
|
||||
}
|
||||
|
||||
public Control getControl(){
|
||||
return Control.NO_REPEAT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,10 +23,11 @@ import java.util.List;
|
||||
|
||||
public class ConfigOperation extends Operation {
|
||||
|
||||
private List<Property> properties;
|
||||
private final List<Property> properties;
|
||||
|
||||
public ConfigOperation() {
|
||||
properties = new ArrayList<Property>();
|
||||
properties = new ArrayList<>();
|
||||
setControl(Control.REPEAT);
|
||||
}
|
||||
|
||||
public List<Property> getConfigProperties() {
|
||||
@ -37,6 +38,10 @@ public class ConfigOperation extends Operation {
|
||||
properties.add(new Property(name, value, type));
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return Type.CONFIG;
|
||||
}
|
||||
|
||||
public static class Property {
|
||||
private String name;
|
||||
private Object value;
|
||||
@ -73,13 +78,4 @@ public class ConfigOperation extends Operation {
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return Type.CONFIG;
|
||||
}
|
||||
|
||||
|
||||
public Control getControl(){
|
||||
return Control.REPEAT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,6 +21,12 @@ import java.util.List;
|
||||
|
||||
public class PolicyOperation extends Operation {
|
||||
|
||||
private List<ProfileOperation> profileOperations;
|
||||
|
||||
public PolicyOperation() {
|
||||
setControl(Control.REPEAT);
|
||||
}
|
||||
|
||||
public List<ProfileOperation> getProfileOperations() {
|
||||
return profileOperations;
|
||||
}
|
||||
@ -29,10 +35,4 @@ public class PolicyOperation extends Operation{
|
||||
this.profileOperations = profileOperations;
|
||||
}
|
||||
|
||||
private List<ProfileOperation> profileOperations;
|
||||
|
||||
public Control getControl(){
|
||||
return Control.REPEAT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user