Merge branch 'master' of https://gitlab.com/entgra/carbon-device-mgt into billing-api-1226

feature/traccar-sync
osh 3 years ago
commit 8872d1baeb

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>grafana-mgt</artifactId> <artifactId>grafana-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -112,7 +112,7 @@ public interface GrafanaAPIProxyService {
@Path("/dashboards/uid/{uid}") @Path("/dashboards/uid/{uid}")
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "GET",
value = "Grafana dashboard details API proxy", value = "Grafana dashboard details API proxy",
tags = "Analytics", tags = "Analytics",
extensions = { extensions = {
@ -145,7 +145,7 @@ public interface GrafanaAPIProxyService {
@Path("/alerts/states-for-dashboard") @Path("/alerts/states-for-dashboard")
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "GET",
value = "Get Grafana alert states for dashboard details API proxy", value = "Get Grafana alert states for dashboard details API proxy",
tags = "Analytics", tags = "Analytics",
extensions = { extensions = {

@ -46,6 +46,7 @@ import javax.ws.rs.core.UriInfo;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -138,7 +139,7 @@ public class GrafanaRequestHandlerUtil {
} }
public static void setRequestEntity(HttpPost postRequest, JsonObject body) throws UnsupportedEncodingException { public static void setRequestEntity(HttpPost postRequest, JsonObject body) throws UnsupportedEncodingException {
StringEntity bodyEntity = new StringEntity(body.toString()); StringEntity bodyEntity = new StringEntity(body.toString(), StandardCharsets.UTF_8);
bodyEntity.setContentType(MediaType.APPLICATION_JSON); bodyEntity.setContentType(MediaType.APPLICATION_JSON);
postRequest.setEntity(bodyEntity); postRequest.setEntity(bodyEntity);
} }

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>grafana-mgt</artifactId> <artifactId>grafana-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>grafana-mgt</artifactId> <artifactId>grafana-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -60,7 +60,7 @@ public class GrafanaConstants {
public static final String DASHBOARD_PANEL_DETAIL_QUERIES_KEY = "targets"; public static final String DASHBOARD_PANEL_DETAIL_QUERIES_KEY = "targets";
public static final String QUERY_REF_ID_KEY = "refId"; public static final String QUERY_REF_ID_KEY = "refId";
public static final String PANEL_ID_QUERY_PARAM = "panelId"; public static final String PANEL_ID_QUERY_PARAM = "panelId";
public static final String ORG_ID_QUERY_PARAM = "panelId"; public static final String ORG_ID_QUERY_PARAM = "orgId";
public static final String ID_KEY = "id"; public static final String ID_KEY = "id";
public static final String WS_LIVE_API = "/api/live/ws"; public static final String WS_LIVE_API = "/api/live/ws";

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>analytics-mgt</artifactId> <artifactId>analytics-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>apimgt-extensions</artifactId> <artifactId>apimgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -20,7 +20,7 @@
<parent> <parent>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -29,6 +29,7 @@ public class DeviceSubscriptionData {
private String actionType; private String actionType;
private String status; private String status;
private Device device; private Device device;
private String currentInstalledVersion;
public String getAction() { public String getAction() {
return action; return action;
@ -77,4 +78,8 @@ public class DeviceSubscriptionData {
public void setDevice(Device device) { public void setDevice(Device device) {
this.device = device; this.device = device;
} }
public String getCurrentInstalledVersion() { return currentInstalledVersion; }
public void setCurrentInstalledVersion(String currentInstalledVersion) { this.currentInstalledVersion = currentInstalledVersion; }
} }

@ -51,19 +51,20 @@ public interface ApplicationManager {
* *
* @param applicationWrapper Application that need to be created. * @param applicationWrapper Application that need to be created.
* @param applicationArtifact contains artifact data. i.e image name and stream, icon name and stream etc. * @param applicationArtifact contains artifact data. i.e image name and stream, icon name and stream etc.
* @param isPublished checks if application should be published
* @return {@link Application} * @return {@link Application}
* @throws ApplicationManagementException Catch all other throwing exceptions and throw {@link ApplicationManagementException} * @throws ApplicationManagementException Catch all other throwing exceptions and throw {@link ApplicationManagementException}
*/ */
Application createEntApp(ApplicationWrapper applicationWrapper, ApplicationArtifact applicationArtifact) Application createEntApp(ApplicationWrapper applicationWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException; throws ApplicationManagementException;
Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact) Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException; throws ApplicationManagementException;
Application createPublicApp(PublicAppWrapper publicAppWrapper, ApplicationArtifact applicationArtifact) Application createPublicApp(PublicAppWrapper publicAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException; throws ApplicationManagementException;
Application createCustomApp(CustomAppWrapper customAppWrapper, ApplicationArtifact applicationArtifact) Application createCustomApp(CustomAppWrapper customAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**
@ -180,6 +181,17 @@ public interface ApplicationManager {
ApplicationRelease changeLifecycleState(String releaseUuid, LifecycleChanger lifecycleChanger) ApplicationRelease changeLifecycleState(String releaseUuid, LifecycleChanger lifecycleChanger)
throws ApplicationManagementException; throws ApplicationManagementException;
/**
* To get all the releases of a particular ApplicationDTO.
*
* @param applicationReleaseDTO of the ApplicationDTO Release.
* @param lifecycleChanger Lifecycle changer that contains the action and the reason for the change.
* @throws ApplicationManagementException ApplicationDTO Management Exception.
* @return
*/
ApplicationRelease changeLifecycleState(ApplicationReleaseDTO applicationReleaseDTO, LifecycleChanger lifecycleChanger)
throws ApplicationManagementException;
/** /**
* To update release images such as icons, banner and screenshots. * To update release images such as icons, banner and screenshots.
* *
@ -207,10 +219,11 @@ public interface ApplicationManager {
* *
* @param applicationId ID of the ApplicationDTO * @param applicationId ID of the ApplicationDTO
* @param entAppReleaseWrapper ApplicatonRelease that need to be be created. * @param entAppReleaseWrapper ApplicatonRelease that need to be be created.
* @param isPublished checks if application should be published
* @return the unique id of the application release, if the application release succeeded else -1 * @return the unique id of the application release, if the application release succeeded else -1
*/ */
ApplicationRelease createEntAppRelease(int applicationId, EntAppReleaseWrapper entAppReleaseWrapper, ApplicationRelease createEntAppRelease(int applicationId, EntAppReleaseWrapper entAppReleaseWrapper,
ApplicationArtifact applicationArtifact) throws ApplicationManagementException; ApplicationArtifact applicationArtifact, boolean isPublished) throws ApplicationManagementException;
/*** /***
* *
@ -304,5 +317,4 @@ public interface ApplicationManager {
String getPlistArtifact(String uuid) throws ApplicationManagementException; String getPlistArtifact(String uuid) throws ApplicationManagementException;
List<ApplicationReleaseDTO> getReleaseByPackageNames(List<String> packageIds) throws ApplicationManagementException; List<ApplicationReleaseDTO> getReleaseByPackageNames(List<String> packageIds) throws ApplicationManagementException;
} }

@ -175,12 +175,13 @@ public interface SubscriptionManager {
* @param actionStatus status of the operation. * @param actionStatus status of the operation.
* @param action action related to the device. * @param action action related to the device.
* @param appUUID application release UUID * @param appUUID application release UUID
* @param installedVersion installed version
* @return {@link PaginationResult} * @return {@link PaginationResult}
* @throws ApplicationManagementException if offset or limit contains incorrect values, if it couldn't find an * @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, * 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. * if an error occurred while getting subscription details of given application release UUID.
*/ */
PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, String action) PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, String action, String installedVersion)
throws ApplicationManagementException; throws ApplicationManagementException;
/*** /***

@ -21,7 +21,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -239,4 +239,13 @@ public interface SubscriptionDAO {
*/ */
List<Integer> getAppSubscribedDevicesForGroups(int appReleaseId, String subtype, int tenantId) List<Integer> getAppSubscribedDevicesForGroups(int appReleaseId, String subtype, int tenantId)
throws ApplicationManagementDAOException; throws ApplicationManagementDAOException;
/**
* This method is used to get the currently installed version for given app release id
* @param appId id of the application
* @param deviceIdList id list of devices
* @return Map with device id as a key and currently installed version as value
* @throws {@link ApplicationManagementDAOException} if connections establishment fails.
*/
Map<Integer,String> getCurrentInstalledAppVersion(int appId, List<Integer> deviceIdList, String installedVersion) throws ApplicationManagementDAOException;
} }

@ -1311,4 +1311,66 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
throw new ApplicationManagementDAOException(msg, e); throw new ApplicationManagementDAOException(msg, e);
} }
} }
@Override
public Map<Integer,String> getCurrentInstalledAppVersion(int appId, List<Integer> deviceIdList, String installedVersion ) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get current installed version of the app for " +
"given app release id.");
}
try {
Map<Integer,String> installedVersionsMap = new HashMap<>();
Connection conn = this.getDBConnection();
int index = 1;
boolean isInstalledVersionAvailable = false;
StringJoiner joiner = new StringJoiner(",",
" SELECT DM_DEVICE_ID AS DEVICE,VERSION FROM " +
" (SELECT AP_APP.ID, VERSION FROM AP_APP_RELEASE AP_APP " +
" WHERE ID IN (SELECT ID FROM AP_APP_RELEASE " +
" WHERE AP_APP_ID = ?) " +
" ) AP_APP_V" +
" INNER JOIN " +
" (SELECT AP_APP_RELEASE_ID, DM_DEVICE_ID FROM AP_DEVICE_SUBSCRIPTION AP_DEV_1 " +
" INNER JOIN (" +
" SELECT MAX(ID) AS ID FROM AP_DEVICE_SUBSCRIPTION " +
" WHERE STATUS = 'COMPLETED' AND DM_DEVICE_ID IN (",
") GROUP BY DM_DEVICE_ID " +
") AP_DEV_2 " +
"ON AP_DEV_2.ID = AP_DEV_1.ID ) AP_APP_R " +
"ON AP_APP_R.AP_APP_RELEASE_ID = AP_APP_V.ID");
deviceIdList.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString();
if(installedVersion != null && !installedVersion.isEmpty()){
query += " WHERE VERSION = ? ";
isInstalledVersionAvailable = true;
}
try (PreparedStatement ps = conn.prepareStatement(query)) {
ps.setInt(index++, appId);
for (int deviceId : deviceIdList) {
ps.setInt(index++, deviceId);
}
if(isInstalledVersionAvailable){
ps.setString(index++, installedVersion);
}
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
installedVersionsMap.put(rs.getInt("DEVICE"),rs.getString("VERSION"));
}
}
return installedVersionsMap;
}
}catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get current installed version of the app for " +
"given app id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while getting current installed version of the app for given " +
"app id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
} }

@ -135,7 +135,7 @@ ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public Application createEntApp(ApplicationWrapper applicationWrapper, public Application createEntApp(ApplicationWrapper applicationWrapper,
ApplicationArtifact applicationArtifact) throws ApplicationManagementException { ApplicationArtifact applicationArtifact, boolean isPublished) throws ApplicationManagementException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Ent. Application create request is received. Application name: " + applicationWrapper.getName() log.debug("Ent. Application create request is received. Application name: " + applicationWrapper.getName()
+ " Device type: " + applicationWrapper.getDeviceType()); + " Device type: " + applicationWrapper.getDeviceType());
@ -149,11 +149,11 @@ ApplicationManagerImpl implements ApplicationManager {
applicationWrapper.getDeviceType(), tenantId, false); applicationWrapper.getDeviceType(), tenantId, false);
applicationDTO.getApplicationReleaseDTOs().clear(); applicationDTO.getApplicationReleaseDTOs().clear();
applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO); applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO);
return addAppDataIntoDB(applicationDTO, tenantId); return addAppDataIntoDB(applicationDTO, tenantId, isPublished);
} }
@Override @Override
public Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact) public Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException { throws ApplicationManagementException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Web clip create request is received. App name: " + webAppWrapper.getName() + " Device type: " log.debug("Web clip create request is received. App name: " + webAppWrapper.getName() + " Device type: "
@ -175,11 +175,11 @@ ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} }
//insert application data into database //insert application data into database
return addAppDataIntoDB(applicationDTO, tenantId); return addAppDataIntoDB(applicationDTO, tenantId, isPublished);
} }
@Override @Override
public Application createPublicApp(PublicAppWrapper publicAppWrapper, ApplicationArtifact applicationArtifact) public Application createPublicApp(PublicAppWrapper publicAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
@ -231,11 +231,11 @@ ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} }
//insert application data into database //insert application data into database
return addAppDataIntoDB(applicationDTO, tenantId); return addAppDataIntoDB(applicationDTO, tenantId, isPublished);
} }
@Override @Override
public Application createCustomApp(CustomAppWrapper customAppWrapper, ApplicationArtifact applicationArtifact) public Application createCustomApp(CustomAppWrapper customAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException { throws ApplicationManagementException {
try { try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
@ -282,7 +282,7 @@ ApplicationManagerImpl implements ApplicationManager {
applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact, tenantId); applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact, tenantId);
applicationDTO.getApplicationReleaseDTOs().clear(); applicationDTO.getApplicationReleaseDTOs().clear();
applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO); applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO);
return addAppDataIntoDB(applicationDTO, tenantId); return addAppDataIntoDB(applicationDTO, tenantId, isPublished);
} catch (ResourceManagementException e) { } catch (ResourceManagementException e) {
String msg = "Error occurred while uploading application artifact into the server. Application name: " String msg = "Error occurred while uploading application artifact into the server. Application name: "
+ customAppWrapper.getName() + " Device type: " + customAppWrapper.getDeviceType(); + customAppWrapper.getName() + " Device type: " + customAppWrapper.getDeviceType();
@ -872,7 +872,7 @@ ApplicationManagerImpl implements ApplicationManager {
* @return {@link Application} * @return {@link Application}
* @throws ApplicationManagementException which throws if error occurs while during application management. * @throws ApplicationManagementException which throws if error occurs while during application management.
*/ */
private Application addAppDataIntoDB(ApplicationDTO applicationDTO, int tenantId) throws ApplicationManagementException { private Application addAppDataIntoDB(ApplicationDTO applicationDTO, int tenantId, boolean isPublished) throws ApplicationManagementException {
ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager();
List<String> unrestrictedRoles = applicationDTO.getUnrestrictedRoles(); List<String> unrestrictedRoles = applicationDTO.getUnrestrictedRoles();
ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0); ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
@ -939,12 +939,24 @@ ApplicationManagerImpl implements ApplicationManager {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Creating a new release. App Id:" + appId); log.debug("Creating a new release. App Id:" + appId);
} }
String initialLifecycleState = lifecycleStateManager.getInitialState();
applicationReleaseDTO.setCurrentState(initialLifecycleState); String lifeCycleState = lifecycleStateManager.getInitialState();
applicationReleaseDTO = this.applicationReleaseDAO String[] publishStates= {"IN-REVIEW", "APPROVED", "PUBLISHED"};
.createRelease(applicationReleaseDTO, appId, tenantId);
LifecycleState lifecycleState = getLifecycleStateInstance(initialLifecycleState, initialLifecycleState); applicationReleaseDTO.setCurrentState(lifeCycleState);
applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId);
LifecycleState lifecycleState = getLifecycleStateInstance(lifeCycleState, lifeCycleState);
this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId); this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
if(isPublished){
for (String state: publishStates) {
LifecycleChanger lifecycleChanger = new LifecycleChanger();
lifecycleChanger.setAction(state);
lifecycleChanger.setReason("Updated to " + state);
this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger);
}
}
applicationReleaseEntities.add(applicationReleaseDTO); applicationReleaseEntities.add(applicationReleaseDTO);
applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities);
Application application = APIUtil.appDtoToAppResponse(applicationDTO); Application application = APIUtil.appDtoToAppResponse(applicationDTO);
@ -1004,7 +1016,7 @@ ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public ApplicationRelease createEntAppRelease(int applicationId, EntAppReleaseWrapper entAppReleaseWrapper, public ApplicationRelease createEntAppRelease(int applicationId, EntAppReleaseWrapper entAppReleaseWrapper,
ApplicationArtifact applicationArtifact) throws ApplicationManagementException { ApplicationArtifact applicationArtifact, boolean isPublished) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Application release creating request is received for the application id: " + applicationId); log.debug("Application release creating request is received for the application id: " + applicationId);
@ -1030,15 +1042,28 @@ ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO applicationReleaseDTO = uploadEntAppReleaseArtifacts( ApplicationReleaseDTO applicationReleaseDTO = uploadEntAppReleaseArtifacts(
APIUtil.releaseWrapperToReleaseDTO(entAppReleaseWrapper), applicationArtifact, deviceType.getName(), APIUtil.releaseWrapperToReleaseDTO(entAppReleaseWrapper), applicationArtifact, deviceType.getName(),
tenantId, true); tenantId, true);
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
String initialstate = lifecycleStateManager.getInitialState(); String lifeCycleState = lifecycleStateManager.getInitialState();
applicationReleaseDTO.setCurrentState(initialstate); String[] publishStates= {"IN-REVIEW", "APPROVED", "PUBLISHED"};
LifecycleState lifecycleState = getLifecycleStateInstance(initialstate, initialstate);
applicationReleaseDTO.setCurrentState(lifeCycleState);
LifecycleState lifecycleState = getLifecycleStateInstance(lifeCycleState, lifeCycleState);
applicationReleaseDTO = this.applicationReleaseDAO applicationReleaseDTO = this.applicationReleaseDAO
.createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId); .createRelease(applicationReleaseDTO, applicationDTO.getId(), tenantId);
this.lifecycleStateDAO this.lifecycleStateDAO
.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId); .addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
if(isPublished){
for (String state: publishStates) {
LifecycleChanger lifecycleChanger = new LifecycleChanger();
lifecycleChanger.setAction(state);
lifecycleChanger.setReason("Updated to " + state);
this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger);
}
}
ApplicationRelease applicationRelease = APIUtil.releaseDtoToRelease(applicationReleaseDTO); ApplicationRelease applicationRelease = APIUtil.releaseDtoToRelease(applicationReleaseDTO);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return applicationRelease; return applicationRelease;
@ -1884,6 +1909,61 @@ ApplicationManagerImpl implements ApplicationManager {
} }
} }
public ApplicationRelease changeLifecycleState(ApplicationReleaseDTO applicationReleaseDTO, LifecycleChanger lifecycleChanger) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (lifecycleChanger == null || StringUtils.isEmpty(lifecycleChanger.getAction())) {
String msg = "The Action is null or empty. Please verify the request.";
log.error(msg);
throw new BadRequestException(msg);
}
try{
if (lifecycleStateManager
.isValidStateChange(applicationReleaseDTO.getCurrentState(), lifecycleChanger.getAction(), userName,
tenantId)) {
if (lifecycleStateManager.isInstallableState(lifecycleChanger.getAction()) && applicationReleaseDAO
.hasExistInstallableAppRelease(applicationReleaseDTO.getUuid(),
lifecycleStateManager.getInstallableState(), tenantId)) {
String msg = "Installable application release is already registered for the application. "
+ "Therefore it is not permitted to change the lifecycle state from "
+ applicationReleaseDTO.getCurrentState() + " to " + lifecycleChanger.getAction();
log.error(msg);
throw new ForbiddenException(msg);
}
LifecycleState lifecycleState = new LifecycleState();
lifecycleState.setCurrentState(lifecycleChanger.getAction());
lifecycleState.setPreviousState(applicationReleaseDTO.getCurrentState());
lifecycleState.setUpdatedBy(userName);
lifecycleState.setReasonForChange(lifecycleChanger.getReason());
applicationReleaseDTO.setCurrentState(lifecycleChanger.getAction());
if (this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId) == null) {
String msg = "Application release updating is failed/.";
log.error(msg);
throw new ApplicationManagementException(msg);
}
this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId);
return APIUtil.releaseDtoToRelease(applicationReleaseDTO);
} else {
String msg = "Invalid lifecycle state transition from '" + applicationReleaseDTO.getCurrentState() + "'"
+ " to '" + lifecycleChanger.getAction() + "'";
log.error(msg);
throw new ApplicationManagementException(msg);
}
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred when accessing application release data of application release which has the "
+ "application release UUID: " + applicationReleaseDTO.getUuid();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (LifeCycleManagementDAOException e) {
String msg = "Failed to add lifecycle state for Application release UUID: " + applicationReleaseDTO.getUuid();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
@Override @Override
public void addApplicationCategories(List<String> categories) throws ApplicationManagementException { public void addApplicationCategories(List<String> categories) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);

@ -1361,7 +1361,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
@Override @Override
public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus,
String action) throws ApplicationManagementException { String action, String installedVersion) throws ApplicationManagementException {
int limitValue = request.getRowCount(); int limitValue = request.getRowCount();
int offsetValue = request.getStartIndex(); int offsetValue = request.getStartIndex();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
@ -1395,6 +1395,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
List<Integer> deviceIdList = deviceSubscriptionDTOS.stream().map(DeviceSubscriptionDTO::getDeviceId) List<Integer> deviceIdList = deviceSubscriptionDTOS.stream().map(DeviceSubscriptionDTO::getDeviceId)
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<Integer,String> currentVersionsMap = subscriptionDAO.getCurrentInstalledAppVersion(applicationDTO.getId(),deviceIdList, installedVersion);
try { try {
//pass the device id list to device manager service method //pass the device id list to device manager service method
PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices
@ -1404,7 +1405,15 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (!paginationResult.getData().isEmpty()) { if (!paginationResult.getData().isEmpty()) {
List<Device> devices = (List<Device>) paginationResult.getData(); List<Device> devices = (List<Device>) paginationResult.getData();
for (Device device : devices) { for (Device device : devices) {
if(installedVersion != null && !installedVersion.isEmpty() && !currentVersionsMap.containsKey(device.getId())){
continue;
}
DeviceSubscriptionData deviceSubscriptionData = new DeviceSubscriptionData(); DeviceSubscriptionData deviceSubscriptionData = new DeviceSubscriptionData();
if(currentVersionsMap.containsKey(device.getId())){
deviceSubscriptionData.setCurrentInstalledVersion(currentVersionsMap.get(device.getId()));
}else{
deviceSubscriptionData.setCurrentInstalledVersion("-");
}
for (DeviceSubscriptionDTO subscription : deviceSubscriptionDTOS) { for (DeviceSubscriptionDTO subscription : deviceSubscriptionDTOS) {
if (subscription.getDeviceId() == device.getId()) { if (subscription.getDeviceId() == device.getId()) {
deviceSubscriptionData.setDevice(device); deviceSubscriptionData.setDevice(device);

@ -41,7 +41,6 @@ import io.entgra.application.mgt.core.dto.ApplicationsDTO;
import io.entgra.application.mgt.core.impl.ApplicationManagerImpl; import io.entgra.application.mgt.core.impl.ApplicationManagerImpl;
import io.entgra.application.mgt.core.internal.DataHolder; import io.entgra.application.mgt.core.internal.DataHolder;
import io.entgra.application.mgt.core.util.ConnectionManagerUtil; import io.entgra.application.mgt.core.util.ConnectionManagerUtil;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion;
@ -121,9 +120,8 @@ public class ApplicationManagementTest extends BaseTestCase {
screenshots.put("shot3", new FileInputStream(new File("src/test/resources/samples/app1/shot3.png"))); screenshots.put("shot3", new FileInputStream(new File("src/test/resources/samples/app1/shot3.png")));
applicationArtifact.setScreenshots(screenshots); applicationArtifact.setScreenshots(screenshots);
ApplicationManager manager = new ApplicationManagerImpl(); ApplicationManager manager = new ApplicationManagerImpl();
manager.createEntApp(applicationWrapper, applicationArtifact); manager.createEntApp(applicationWrapper, applicationArtifact, false);
} }
@DataProvider(name = "applicationIdDataProvider") @DataProvider(name = "applicationIdDataProvider")
@ -141,6 +139,11 @@ public class ApplicationManagementTest extends BaseTestCase {
return new Object[][] {{"TEST_APP_UUID"}}; return new Object[][] {{"TEST_APP_UUID"}};
} }
@Test(enabled = false)
public void createApplicationAndPublish(ApplicationWrapper applicationWrapper, ApplicationArtifact applicationArtifact, boolean isPublish) throws ApplicationManagementException {
}
@Test(enabled = false) @Test(enabled = false)
public void updateApplication(int applicationId, ApplicationUpdateWrapper applicationUpdateWrapper) throws ApplicationManagementException { public void updateApplication(int applicationId, ApplicationUpdateWrapper applicationUpdateWrapper) throws ApplicationManagementException {

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -319,6 +319,11 @@ public interface ApplicationManagementPublisherAPI {
value = "The application that need to be created.", value = "The application that need to be created.",
required = true) required = true)
@Multipart("application") ApplicationWrapper application, @Multipart("application") ApplicationWrapper application,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("is-Published") boolean isPublished,
@ApiParam( @ApiParam(
name = "binaryFile", name = "binaryFile",
value = "Binary file of uploading application", value = "Binary file of uploading application",
@ -388,6 +393,11 @@ public interface ApplicationManagementPublisherAPI {
value = "The web app that need to be created.", value = "The web app that need to be created.",
required = true) required = true)
@Multipart("webapp") WebAppWrapper webAppWrapper, @Multipart("webapp") WebAppWrapper webAppWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("is-Published") boolean isPublished,
@ApiParam( @ApiParam(
name = "icon", name = "icon",
value = "Icon of the uploading web app", value = "Icon of the uploading web app",
@ -452,6 +462,11 @@ public interface ApplicationManagementPublisherAPI {
value = "The public app that need to be created.", value = "The public app that need to be created.",
required = true) required = true)
@Multipart("public-app") PublicAppWrapper publicAppWrapper, @Multipart("public-app") PublicAppWrapper publicAppWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("is-Published") boolean isPublished,
@ApiParam( @ApiParam(
name = "icon", name = "icon",
value = "Icon of the uploading public app", value = "Icon of the uploading public app",
@ -514,6 +529,11 @@ public interface ApplicationManagementPublisherAPI {
value = "The application that need to be created.", value = "The application that need to be created.",
required = true) required = true)
@Multipart("application") CustomAppWrapper customAppWrapper, @Multipart("application") CustomAppWrapper customAppWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("is-Published") boolean isPublished,
@ApiParam( @ApiParam(
name = "binaryFile", name = "binaryFile",
value = "Binary file of uploading application", value = "Binary file of uploading application",
@ -593,6 +613,11 @@ public interface ApplicationManagementPublisherAPI {
value = "The application release that need to be created.", value = "The application release that need to be created.",
required = true) required = true)
@Multipart("applicationRelease") EntAppReleaseWrapper entAppReleaseWrapper, @Multipart("applicationRelease") EntAppReleaseWrapper entAppReleaseWrapper,
@ApiParam(
name = "isPublished",
value = "Published state of the application"
)
@QueryParam("is-Published") boolean isPublished,
@ApiParam( @ApiParam(
name = "binaryFile", name = "binaryFile",
value = "Binary file of uploading application", value = "Binary file of uploading application",

@ -173,6 +173,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Path("/ent-app") @Path("/ent-app")
public Response createEntApp( public Response createEntApp(
@Multipart("application") ApplicationWrapper applicationWrapper, @Multipart("application") ApplicationWrapper applicationWrapper,
@QueryParam("is-published") boolean isPublished,
@Multipart("binaryFile") Attachment binaryFile, @Multipart("binaryFile") Attachment binaryFile,
@Multipart("icon") Attachment iconFile, @Multipart("icon") Attachment iconFile,
@Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart(value = "banner", required = false) Attachment bannerFile,
@ -190,7 +191,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
// Created new Ent App // Created new Ent App
Application application = applicationManager.createEntApp(applicationWrapper, Application application = applicationManager.createEntApp(applicationWrapper,
constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList)); constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList), isPublished);
if (application != null) { if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build(); return Response.status(Response.Status.CREATED).entity(application).build();
} else { } else {
@ -218,6 +219,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Path("/web-app") @Path("/web-app")
public Response createWebApp( public Response createWebApp(
@Multipart("webapp") WebAppWrapper webAppWrapper, @Multipart("webapp") WebAppWrapper webAppWrapper,
@QueryParam("is-published") boolean isPublished,
@Multipart("icon") Attachment iconFile, @Multipart("icon") Attachment iconFile,
@Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart(value = "banner", required = false) Attachment bannerFile,
@Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot1") Attachment screenshot1,
@ -233,7 +235,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
// Created new Web App // Created new Web App
Application application = applicationManager.createWebClip(webAppWrapper, Application application = applicationManager.createWebClip(webAppWrapper,
constructApplicationArtifact(null, iconFile, bannerFile, attachmentList)); constructApplicationArtifact(null, iconFile, bannerFile, attachmentList), isPublished);
if (application != null) { if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build(); return Response.status(Response.Status.CREATED).entity(application).build();
} else { } else {
@ -261,6 +263,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Path("/public-app") @Path("/public-app")
public Response createPubApp( public Response createPubApp(
@Multipart("public-app") PublicAppWrapper publicAppWrapper, @Multipart("public-app") PublicAppWrapper publicAppWrapper,
@QueryParam("is-published") boolean isPublished,
@Multipart("icon") Attachment iconFile, @Multipart("icon") Attachment iconFile,
@Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart(value = "banner", required = false) Attachment bannerFile,
@Multipart("screenshot1") Attachment screenshot1, @Multipart("screenshot1") Attachment screenshot1,
@ -276,11 +279,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
// Created new Public App // Created new Public App
Application application = applicationManager.createPublicApp(publicAppWrapper, Application application = applicationManager.createPublicApp(publicAppWrapper,
constructApplicationArtifact(null, iconFile, bannerFile, attachmentList)); constructApplicationArtifact(null, iconFile, bannerFile, attachmentList), isPublished);
if (application != null) { if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build(); return Response.status(Response.Status.CREATED).entity(application).build();
} else { } else {
String msg = "Web app creation is failed"; String msg = "Public app creation is failed";
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
@ -304,6 +307,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@Path("/custom-app") @Path("/custom-app")
public Response createCustomApp( public Response createCustomApp(
@Multipart("application") CustomAppWrapper customAppWrapper, @Multipart("application") CustomAppWrapper customAppWrapper,
@QueryParam("is-published") boolean isPublished,
@Multipart("binaryFile") Attachment binaryFile, @Multipart("binaryFile") Attachment binaryFile,
@Multipart("icon") Attachment iconFile, @Multipart("icon") Attachment iconFile,
@Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart(value = "banner", required = false) Attachment bannerFile,
@ -321,7 +325,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
// Created new Custom App // Created new Custom App
Application application = applicationManager.createCustomApp(customAppWrapper, Application application = applicationManager.createCustomApp(customAppWrapper,
constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList)); constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList), isPublished);
if (application != null) { if (application != null) {
return Response.status(Response.Status.CREATED).entity(application).build(); return Response.status(Response.Status.CREATED).entity(application).build();
} else { } else {
@ -351,6 +355,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@PathParam("deviceType") String deviceType, @PathParam("deviceType") String deviceType,
@PathParam("appId") int appId, @PathParam("appId") int appId,
@Multipart("applicationRelease") EntAppReleaseWrapper entAppReleaseWrapper, @Multipart("applicationRelease") EntAppReleaseWrapper entAppReleaseWrapper,
@QueryParam("is-published") boolean isPublished,
@Multipart("binaryFile") Attachment binaryFile, @Multipart("binaryFile") Attachment binaryFile,
@Multipart("icon") Attachment iconFile, @Multipart("icon") Attachment iconFile,
@Multipart(value = "banner", required = false) Attachment bannerFile, @Multipart(value = "banner", required = false) Attachment bannerFile,
@ -366,7 +371,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
// Created new Ent App release // Created new Ent App release
ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper, ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper,
constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList)); constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList), isPublished);
if (release != null) { if (release != null) {
return Response.status(Response.Status.CREATED).entity(release).build(); return Response.status(Response.Status.CREATED).entity(release).build();
} else { } else {

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>application-mgt</artifactId> <artifactId>application-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -139,6 +139,10 @@ public interface SubscriptionManagementAdminAPI {
name = "status", name = "status",
value = "Provide the device status details, such as active or inactive.") value = "Provide the device status details, such as active or inactive.")
@QueryParam("status") List<String> status, @QueryParam("status") List<String> status,
@ApiParam(
name = "installedVersion",
value = "Provide the installed version of the application.")
@QueryParam("installedVersion") String installedVersion,
@ApiParam( @ApiParam(
name = "uuid", name = "uuid",
value = "uuid of the application release.", value = "uuid of the application release.",

@ -60,6 +60,7 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
@QueryParam("action") String action, @QueryParam("action") String action,
@QueryParam("actionStatus") String actionStatus, @QueryParam("actionStatus") String actionStatus,
@QueryParam("status") List<String> status, @QueryParam("status") List<String> status,
@QueryParam("installedVersion") String installedVersion,
@PathParam("uuid") String uuid, @PathParam("uuid") String uuid,
@DefaultValue("0") @DefaultValue("0")
@QueryParam("offset") int offset, @QueryParam("offset") int offset,
@ -97,7 +98,7 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
} }
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager(); SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails PaginationResult subscriptionData = subscriptionManager.getAppSubscriptionDetails
(request, uuid, actionStatus, action); (request, uuid, actionStatus, action, installedVersion);
return Response.status(Response.Status.OK).entity(subscriptionData).build(); return Response.status(Response.Status.OK).entity(subscriptionData).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
String msg = "Application with application release UUID: " + uuid + " is not found"; String msg = "Application with application release UUID: " + uuid + " is not found";

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -38,7 +38,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt</artifactId> <artifactId>certificate-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt-extensions</artifactId> <artifactId>device-mgt-extensions</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.event.config.EventConfig; import org.wso2.carbon.device.mgt.common.event.config.EventConfig;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.impl.AbstractEventConfigDAO; import org.wso2.carbon.device.mgt.core.dao.impl.AbstractEventConfigDAO;
import java.sql.Connection; import java.sql.Connection;
@ -75,6 +76,6 @@ public class H2EventConfigDAOImpl extends AbstractEventConfigDAO {
} }
private Connection getConnection() throws SQLException { private Connection getConnection() throws SQLException {
return DeviceManagementDAOFactory.getConnection(); return EventManagementDAOFactory.getConnection();
} }
} }

@ -74,7 +74,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt.setDouble(14, deviceInfo.getTotalRAMMemory()); stmt.setDouble(14, deviceInfo.getTotalRAMMemory());
stmt.setDouble(15, deviceInfo.getAvailableRAMMemory()); stmt.setDouble(15, deviceInfo.getAvailableRAMMemory());
stmt.setBoolean(16, deviceInfo.isPluggedIn()); stmt.setBoolean(16, deviceInfo.isPluggedIn());
stmt.setLong(17, DeviceManagementDAOUtil.getCurrentUTCTime()); stmt.setLong(17, DeviceManagementDAOUtil.getCurrentUTCTime() * 1000L);
stmt.setInt(18, enrolmentId); stmt.setInt(18, enrolmentId);
stmt.execute(); stmt.execute();
@ -508,7 +508,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO {
stmt.setDouble(13, newDeviceInfo.getTotalRAMMemory()); stmt.setDouble(13, newDeviceInfo.getTotalRAMMemory());
stmt.setDouble(14, newDeviceInfo.getAvailableRAMMemory()); stmt.setDouble(14, newDeviceInfo.getAvailableRAMMemory());
stmt.setBoolean(15, newDeviceInfo.isPluggedIn()); stmt.setBoolean(15, newDeviceInfo.isPluggedIn());
stmt.setLong(16, System.currentTimeMillis()); stmt.setLong(16, DeviceManagementDAOUtil.getCurrentUTCTime() * 1000L);
stmt.setInt(17, deviceId); stmt.setInt(17, deviceId);
stmt.setInt(18, enrollmentId); stmt.setInt(18, enrollmentId);

@ -132,7 +132,10 @@ public class EventOperationExecutor implements Runnable {
EventRevokeOperation eventRevokeOperation = new EventRevokeOperation(); EventRevokeOperation eventRevokeOperation = new EventRevokeOperation();
eventRevokeOperation.setEventSource(eventSource); eventRevokeOperation.setEventSource(eventSource);
eventRevokeOperation.setId(geoFenceMeta.getId()); eventRevokeOperation.setId(geoFenceMeta.getId());
operation.setPayLoad(new Gson().toJson(eventRevokeOperation));
List<EventRevokeOperation> eventOperationsRevoke = new ArrayList<>();
eventOperationsRevoke.add(eventRevokeOperation);
operation.setPayLoad(new Gson().toJson(eventOperationsRevoke));
} }
@Override @Override

@ -1507,7 +1507,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
geofenceDAO.deleteGeofenceGroupMapping(groupIdsOfGeoFence, fenceId); geofenceDAO.deleteGeofenceGroupMapping(groupIdsOfGeoFence, fenceId);
} }
geofenceDAO.deleteGeofenceById(fenceId); geofenceDAO.deleteGeofenceById(fenceId);
DeviceManagementDAOFactory.commitTransaction(); EventManagementDAOFactory.commitTransaction();
GeoCacheManagerImpl.getInstance().removeFenceFromCache(fenceId, tenantId); GeoCacheManagerImpl.getInstance().removeFenceFromCache(fenceId, tenantId);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
EventManagementDAOFactory.rollbackTransaction(); EventManagementDAOFactory.rollbackTransaction();
@ -1571,7 +1571,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
log.error(msg, e); log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e); throw new GeoLocationBasedServiceException(msg, e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); EventManagementDAOFactory.closeConnection();
} }
return true; return true;
} }
@ -1772,12 +1772,9 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic
DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData), DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData),
tenantId, geofenceData.getGroupIds()); tenantId, geofenceData.getGroupIds());
} catch (EventConfigurationException e) { } catch (EventConfigurationException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Failed to delete Geofence event configurations"; String msg = "Failed to delete Geofence event configurations";
log.error(msg, e); log.error(msg, e);
throw new GeoLocationBasedServiceException(msg, e); throw new GeoLocationBasedServiceException(msg, e);
} finally {
DeviceManagementDAOFactory.closeConnection();
} }
} }
} }

@ -22,7 +22,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -23,7 +23,7 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>heartbeat-management</artifactId> <artifactId>heartbeat-management</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>identity-extensions</artifactId> <artifactId>identity-extensions</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>policy-mgt</artifactId> <artifactId>policy-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -23,7 +23,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>email-sender</artifactId> <artifactId>email-sender</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>transport-mgt</artifactId> <artifactId>transport-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>sms-handler</artifactId> <artifactId>sms-handler</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>sms-handler</artifactId> <artifactId>sms-handler</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>sms-handler</artifactId> <artifactId>sms-handler</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>transport-mgt</artifactId> <artifactId>transport-mgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>ui-request-interceptor</artifactId> <artifactId>ui-request-interceptor</artifactId>
<groupId>io.entgra.devicemgt</groupId> <groupId>io.entgra.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

@ -48,6 +48,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets;
@MultipartConfig @MultipartConfig
@WebServlet( @WebServlet(
@ -150,6 +151,7 @@ public class GrafanaHandler extends HttpServlet {
resp.setContentType(contentType); resp.setContentType(contentType);
resp.setStatus(grafanaAPIResponse.getCode()); resp.setStatus(grafanaAPIResponse.getCode());
addXFrameOptionsHeaders(resp); addXFrameOptionsHeaders(resp);
resp.setCharacterEncoding(StandardCharsets.UTF_8.name());
resp.getWriter().print(grafanaAPIResponse.getData()); resp.getWriter().print(grafanaAPIResponse.getData());
} }

@ -84,7 +84,7 @@ public class HandlerConstants {
public static final String WSS_PROTOCOL = "wss"; public static final String WSS_PROTOCOL = "wss";
public static final String WS_PROTOCOL = "ws"; public static final String WS_PROTOCOL = "ws";
public static final String REMOTE_SESSION_CONTEXT = "/remote/session/clients"; public static final String REMOTE_SESSION_CONTEXT = "/remote/session/clients";
public static final String GRAFANA_API = "/api/device-mgt/v1.0/reports/grafana"; public static final String GRAFANA_API = "/api/grafana-mgt/v1.0";
public static final String IOT_CORE_HOST_ENV_VAR = "iot.core.host"; public static final String IOT_CORE_HOST_ENV_VAR = "iot.core.host";
public static final String IOT_CORE_HTTP_PORT_ENV_VAR = "iot.core.http.port"; public static final String IOT_CORE_HTTP_PORT_ENV_VAR = "iot.core.http.port";

@ -656,7 +656,7 @@ public class HandlerUtil {
public static ProxyResponse getTokenResult(AuthData authData, String keymanagerUrl) throws IOException { public static ProxyResponse getTokenResult(AuthData authData, String keymanagerUrl) throws IOException {
HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.TOKEN_ENDPOINT); HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.TOKEN_ENDPOINT);
StringEntity tokenEndpointPayload = new StringEntity( StringEntity tokenEndpointPayload = new StringEntity(
"grant_type=refresh_token&refresh_token=" + authData.getRefreshToken() + "&scope=PRODUCTION", "grant_type=refresh_token&refresh_token=" + authData.getRefreshToken(),
ContentType.APPLICATION_FORM_URLENCODED); ContentType.APPLICATION_FORM_URLENCODED);
tokenEndpoint.setEntity(tokenEndpointPayload); tokenEndpoint.setEntity(tokenEndpointPayload);

@ -21,7 +21,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>webapp-authenticator-framework</artifactId> <artifactId>webapp-authenticator-framework</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>grafana-mgt-feature</artifactId> <artifactId>grafana-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>grafana-mgt-feature</artifactId> <artifactId>grafana-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>analytics-mgt-feature</artifactId> <artifactId>analytics-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -3,7 +3,7 @@
<parent> <parent>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -21,7 +21,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>apimgt-extensions-feature</artifactId> <artifactId>apimgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>application-mgt-feature</artifactId> <artifactId>application-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>application-mgt-feature</artifactId> <artifactId>application-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>certificate-mgt-feature</artifactId> <artifactId>certificate-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-extensions-feature</artifactId> <artifactId>device-mgt-extensions-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>carbon-devicemgt</artifactId> <artifactId>carbon-devicemgt</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

@ -22,7 +22,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>5.0.3-SNAPSHOT</version> <version>5.0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save