osh 3 years ago
commit 7ba8311c93

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

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

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

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

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

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

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

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

@ -62,11 +62,13 @@ public interface APIManagementProviderService {
* @param applicationName Application Name
* @param tokenType Token Type
* @param validityPeriod Validity Period
* @param username Name of the user to create the token. If null, set as carbon context user
* @return {@link String} Access Token
* @throws APIManagerException if error occurred while getting the access token for given scopes,
* validity period etc.
*/
AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, String validityPeriod)
AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String
tokenType, String validityPeriod, String username)
throws APIManagerException;
}

@ -233,7 +233,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
@Override
public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType,
String validityPeriod) throws APIManagerException {
String validityPeriod, String username) throws APIManagerException {
try {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
ApiApplicationKey clientCredentials = getClientCredentials(tenantDomain, tags, applicationName, tokenType,
@ -245,15 +245,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
throw new APIManagerException(msg);
}
String user =
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + PrivilegedCarbonContext
if (username == null || username.isEmpty()) {
username =
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + PrivilegedCarbonContext
.getThreadLocalCarbonContext().getTenantDomain(true);
} else {
if (!username.contains("@")) {
username += "@" + PrivilegedCarbonContext
.getThreadLocalCarbonContext().getTenantDomain(true);
}
}
JWTClientManagerService jwtClientManagerService = APIApplicationManagerExtensionDataHolder.getInstance()
.getJwtClientManagerService();
JWTClient jwtClient = jwtClientManagerService.getJWTClient();
AccessTokenInfo accessTokenForAdmin = jwtClient
.getAccessToken(clientCredentials.getConsumerKey(), clientCredentials.getConsumerSecret(), user,
.getAccessToken(clientCredentials.getConsumerKey(), clientCredentials.getConsumerSecret(), username,
scopes);
return accessTokenForAdmin;

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

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

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

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

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

@ -23,6 +23,7 @@ import java.sql.Timestamp;
public class DeviceSubscriptionData {
private int subId;
private String action;
private long actionTriggeredTimestamp;
private String actionTriggeredBy;
@ -82,4 +83,12 @@ public class DeviceSubscriptionData {
public String getCurrentInstalledVersion() { return currentInstalledVersion; }
public void setCurrentInstalledVersion(String currentInstalledVersion) { this.currentInstalledVersion = currentInstalledVersion; }
public int getSubId() {
return subId;
}
public void setSubId(int subId) {
this.subId = subId;
}
}

@ -108,6 +108,11 @@ public class Filter {
*/
private String appReleaseState;
/**
* Username of whose favourite apps to be retrieved
*/
private String favouredBy;
public int getLimit() {
return limit;
}
@ -195,4 +200,12 @@ public class Filter {
public String getAppReleaseType() { return appReleaseType; }
public void setAppReleaseType(String appReleaseType) { this.appReleaseType = appReleaseType; }
public String getFavouredBy() {
return favouredBy;
}
public void setFavouredBy(String favouredBy) {
this.favouredBy = favouredBy;
}
}

@ -0,0 +1,32 @@
package io.entgra.application.mgt.common;
public class OperationStatusBean {
private int operationId;
private String status;
private String operationCode;
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getOperationCode() {
return operationCode;
}
public void setOperationCode(String operationCode) {
this.operationCode = operationCode;
}
}

@ -96,6 +96,10 @@ public class ApplicationDTO {
value = "package name of the application")
private String packageName;
@ApiModelProperty(name = "isFavourite",
value = "if the app is favoured by the user")
private boolean isFavourite;
public String getPackageName() {
return packageName;
}
@ -189,4 +193,12 @@ public class ApplicationDTO {
public double getAppRating() { return appRating; }
public void setAppRating(double appRating) { this.appRating = appRating; }
public boolean isFavourite() {
return isFavourite;
}
public void setFavourite(boolean favourite) {
isFavourite = favourite;
}
}

@ -103,6 +103,10 @@ public class Application {
value = "package name of the application")
private String packageName;
@ApiModelProperty(name = "isFavourite",
value = "if the app is favoured by the user")
private boolean isFavourite;
public String getPackageName() {
return packageName;
}
@ -181,4 +185,12 @@ public class Application {
public String getInstallerName() { return installerName; }
public void setInstallerName(String installerName) { this.installerName = installerName; }
public boolean isFavourite() {
return isFavourite;
}
public void setFavourite(boolean favourite) {
isFavourite = favourite;
}
}

@ -61,6 +61,27 @@ public interface ApplicationManager {
Application createWebClip(WebAppWrapper webAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException;
/**
* Add an application to favourites
* @param appId id of the application
* @throws ApplicationManagementException Catch all other throwing exceptions and throw {@link ApplicationManagementException}
*/
void addAppToFavourites(int appId) throws ApplicationManagementException;
/**
* Remove an application from favourites
* @param appId id of the application
* @throws ApplicationManagementException Catch all other throwing exceptions and throw {@link ApplicationManagementException}
*/
void removeAppFromFavourites(int appId) throws ApplicationManagementException;
/**
* Check if an application is a favourite app
* @param appId id of the application
* @throws ApplicationManagementException Catch all other throwing exceptions and throw {@link ApplicationManagementException}
*/
boolean isFavouriteApp(int appId) throws ApplicationManagementException;
Application createPublicApp(PublicAppWrapper publicAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException;
@ -113,6 +134,8 @@ public interface ApplicationManager {
*/
void deleteApplicationRelease(String releaseUuid) throws ApplicationManagementException;
ApplicationList getFavouriteApplications(Filter filter) throws ApplicationManagementException;
/**
* To get the applications based on the search filter.
*
@ -304,7 +327,9 @@ public interface ApplicationManager {
*/
boolean checkSubDeviceIdsForOperations(int operationId, int deviceId) throws ApplicationManagementException;
void updateSubsStatus (int deviceId, int operationId, String status) throws ApplicationManagementException;
void updateSubStatus(int deviceId, List<Integer> operationId, String status) throws ApplicationManagementException;
void updateSubsStatus(int deviceId, int operationId, String status) throws ApplicationManagementException;
/**

@ -34,6 +34,16 @@ import java.util.Properties;
*/
public interface SubscriptionManager {
/**
* Use to update status of a subscription
*
* @param deviceId Id of the device
* @param subId subscription id
* @param status status to be changed
*/
void updateSubscriptionStatus(int deviceId, int subId, String status)
throws SubscriptionManagementException;
/**
* Performs bulk subscription operation for a given application and a subscriber list.
* @param applicationUUID UUID of the application to subscribe/unsubscribe

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

@ -39,6 +39,33 @@ public interface ApplicationDAO {
*/
int createApplication(ApplicationDTO applicationDTO, int tenantId) throws ApplicationManagementDAOException;
/**
* Use to add an application to favourites for given appId, username and tenantId
*
* @param appId id of the application
* @param userName currently logged-in user
* @throws ApplicationManagementDAOException if error occurred wile executing query to insert data into database.
*/
void addAppToFavourite(int appId, String userName, int tenantId) throws ApplicationManagementDAOException;
/**
* Use to remove an application from favourites for given appId, username and tenantId
*
* @param appId id of the application
* @param userName currently logged-in username
* @throws ApplicationManagementDAOException if error occurred wile executing query to delete data from database.
*/
void removeAppFromFavourite(int appId, String userName, int tenantId) throws ApplicationManagementDAOException;
/**
* Use to check if an app is favourite for given username and tenantId
* @param appId id of the application
* @param userName currently logged-in username
* @return If application is favourite
* @throws ApplicationManagementDAOException if error occurred wile executing query to check if application is a favourite
*/
boolean isFavouriteApp(int appId, String userName, int tenantId) throws ApplicationManagementDAOException;
/**
* To add tags for a particular application.
*

@ -101,6 +101,10 @@ public interface SubscriptionDAO {
List<Integer> getDeviceSubIds(List<Integer> deviceIds, int applicationReleaseId, int tenantId)
throws ApplicationManagementDAOException;
int getDeviceIdForSubId(int subId, int tenantId) throws ApplicationManagementDAOException;
List<Integer> getOperationIdsForSubId(int subId, int tenantId) throws ApplicationManagementDAOException;
List<Integer> getDeviceSubIdsForOperation(int operationId, int deviceID, int tenantId)
throws ApplicationManagementDAOException;

@ -24,7 +24,6 @@ import io.entgra.application.mgt.common.AppLifecycleState;
import io.entgra.application.mgt.common.dto.ApplicationDTO;
import io.entgra.application.mgt.common.dto.CategoryDTO;
import io.entgra.application.mgt.common.Filter;
import io.entgra.application.mgt.common.dto.ReviewDTO;
import io.entgra.application.mgt.common.dto.TagDTO;
import io.entgra.application.mgt.common.exception.DBConnectionException;
import io.entgra.application.mgt.core.dao.ApplicationDAO;
@ -136,10 +135,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
+ "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 "
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ";
+ "FROM AP_APP ";
if (StringUtils.isNotEmpty(filter.getFavouredBy())) {
sql += "INNER JOIN AP_APP_FAVOURITES ON "
+ "AP_APP.ID = AP_APP_FAVOURITES.AP_APP_ID ";
}
sql += "INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ";
if (StringUtils.isNotEmpty(filter.getVersion()) || StringUtils.isNotEmpty(filter.getAppReleaseState())
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) {
sql += "INNER JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";
@ -190,8 +193,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ "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";
+ "WHERE AP_APP.TENANT_ID = ? ";
if (StringUtils.isNotEmpty(filter.getFavouredBy())) {
sql += "AND AP_APP_FAVOURITES.USER_NAME = ? ";
}
sql += "ORDER BY AP_APP.ID, LATEST_UPDATE DESC";
try {
Connection conn = this.getDBConnection();
@ -230,7 +236,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.setInt(paramIndex++, filter.getLimit());
stmt.setInt(paramIndex++, filter.getOffset());
}
stmt.setInt(paramIndex, tenantId);
stmt.setInt(paramIndex++, tenantId);
if (StringUtils.isNotEmpty(filter.getFavouredBy())) {
stmt.setString(paramIndex, filter.getFavouredBy());
}
try (ResultSet rs = stmt.executeQuery()) {
return DAOUtil.loadApplications(rs);
}
@ -732,6 +741,95 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
@Override
public void addAppToFavourite(int appId, String userName, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to add app with the id " + appId + " favourites");
}
String sql = "INSERT INTO AP_APP_FAVOURITES "
+ "(AP_APP_ID, USER_NAME, "
+ " TENANT_ID) "
+ "VALUES (?, ?, ?)";
try {
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appId);
stmt.setString(2, userName);
stmt.setInt(3, tenantId);
stmt.addBatch();
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection when adding app to favourites";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while adding app with the id " + appId + " to favourites. Executed Query: " + sql;
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void removeAppFromFavourite(int appId, String userName, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to add app with the id " + appId + " favourites");
}
String sql = "DELETE FROM AP_APP_FAVOURITES "
+ "WHERE AP_APP_ID = ? "
+ "AND USER_NAME = ? "
+ "AND TENANT_ID = ?";
try {
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appId);
stmt.setString(2, userName);
stmt.setInt(3, tenantId);
stmt.addBatch();
stmt.executeUpdate();
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection when removing app from favourites";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while removing app with the id " + appId + " from favourites. Executed Query: " + sql;
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public boolean isFavouriteApp(int appId, String userName, int tenantId) throws ApplicationManagementDAOException {
String sql = "SELECT AP_APP_ID "
+ "FROM AP_APP_FAVOURITES "
+ "WHERE "
+ "AP_APP_ID = ? AND "
+ "USER_NAME = ? AND "
+ "TENANT_ID = ?";
try {
Connection conn = this.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)){
stmt.setInt(1, appId);
stmt.setString(2, userName);
stmt.setInt(3, tenantId);
try (ResultSet rs = stmt.executeQuery()){
return rs.next();
}
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to check whether the application with the id "
+ appId + " is a favourite app";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "SQL Error occurred while checking whether the application with the id "
+ appId + " is a favourite app. executed query " + sql;
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public void addTags(List<String> tags, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) {

@ -82,10 +82,14 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
+ "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 "
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ORDER BY ID ";
+ "FROM AP_APP ";
if (StringUtils.isNotEmpty(filter.getFavouredBy())) {
sql += "INNER JOIN AP_APP_FAVOURITES ON "
+ "AP_APP.ID = AP_APP_FAVOURITES.AP_APP_ID ";
}
sql += "INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ORDER BY ID ";
if (StringUtils.isNotEmpty(filter.getVersion()) || StringUtils.isNotEmpty(filter.getAppReleaseState())
|| StringUtils.isNotEmpty(filter.getAppReleaseType())) {
sql += "INNER JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID ";

@ -81,8 +81,12 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
+ "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 "
+ "FROM AP_APP ";
if (StringUtils.isNotEmpty(filter.getFavouredBy())) {
sql += "INNER JOIN AP_APP_FAVOURITES ON "
+ "AP_APP.ID = AP_APP_FAVOURITES.AP_APP_ID ";
}
sql += "INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
+ "INNER JOIN (SELECT AP_APP.ID FROM AP_APP ";
if (StringUtils.isNotEmpty(filter.getVersion()) || StringUtils.isNotEmpty(filter.getAppReleaseState())

@ -691,6 +691,68 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
}
}
@Override
public int getDeviceIdForSubId(int subId, int tenantId) throws ApplicationManagementDAOException {
try {
Connection conn = this.getDBConnection();
String sql = "SELECT DM_DEVICE_ID "
+ "FROM AP_DEVICE_SUBSCRIPTION "
+ "WHERE ID = ? AND "
+ "TENANT_ID = ?";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, subId);
stmt.setInt(2, tenantId);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getInt("DM_DEVICE_ID");
}
}
return -1;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get app operation ids for given "
+ "subscription id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred when processing SQL to get operation ids for given subscription id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public List<Integer> getOperationIdsForSubId(int subId, int tenantId) throws ApplicationManagementDAOException {
try {
Connection conn = this.getDBConnection();
List<Integer> operationIds = new ArrayList<>();
String sql = "SELECT OPERATION_ID "
+ "FROM AP_APP_SUB_OP_MAPPING "
+ "WHERE AP_DEVICE_SUBSCRIPTION_ID = ? AND "
+ "TENANT_ID = ?";
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, subId);
stmt.setInt(2, tenantId);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
operationIds.add(rs.getInt("OPERATION_ID"));
}
}
return operationIds;
}
} catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to get app operation ids for given "
+ "subscription id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred when processing SQL to get operation ids for given subscription id.";
log.error(msg, e);
throw new ApplicationManagementDAOException(msg, e);
}
}
@Override
public List<Integer> getDeviceSubIdsForOperation(int operationId, int deviceId, int tenantId)
throws ApplicationManagementDAOException {
@ -1204,7 +1266,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
Connection conn = this.getDBConnection();
List<String> subscribedGroups = new ArrayList<>();
String sql = "SELECT "
+ "GS.GROUP_NAME AS GROUPS "
+ "GS.GROUP_NAME AS APP_GROUPS "
+ "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
@ -1215,7 +1277,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
ps.setInt(4, offsetValue);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
subscribedGroups.add(rs.getString("GROUPS"));
subscribedGroups.add(rs.getString("APP_GROUPS"));
}
}
return subscribedGroups;
@ -1244,7 +1306,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
try {
Connection conn = this.getDBConnection();
String sql = "SELECT "
+ "COUNT(GS.GROUP_NAME) AS GROUPS "
+ "COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT "
+ "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?";
@ -1254,7 +1316,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
return rs.getInt("GROUPS");
return rs.getInt("APP_GROUPS_COUNT");
}
}
return 0;

@ -178,6 +178,116 @@ ApplicationManagerImpl implements ApplicationManager {
return addAppDataIntoDB(applicationDTO, tenantId, isPublished);
}
@Override
public void addAppToFavourites(int appId) throws ApplicationManagementException {
validateAddAppToFavouritesRequest(appId);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
try {
ConnectionManagerUtil.beginDBTransaction();
applicationDAO.addAppToFavourite(appId, userName, tenantId);
ConnectionManagerUtil.commitDBTransaction();
} catch (TransactionManagementException e) {
String msg = "Error occurred while staring transaction to add applicationId: "
+ appId + " to favourites";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while adding application id " + appId + " to favourites ";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred while adding application with the id: " + appId + " to favourites ";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
@Override
public void removeAppFromFavourites(int appId) throws ApplicationManagementException {
validateRemoveAppFromFavouritesRequest(appId);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
try {
ConnectionManagerUtil.beginDBTransaction();
applicationDAO.removeAppFromFavourite(appId, userName, tenantId);
ConnectionManagerUtil.commitDBTransaction();
} catch (TransactionManagementException e) {
String msg = "Error occurred while staring transaction to remove applicationId: "
+ appId + " from favourites";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while removing application id " + appId + " from favourites ";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred while removing application with the id: " + appId + " from favourites ";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
@Override
public boolean isFavouriteApp(int appId) throws ApplicationManagementException{
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
try {
ConnectionManagerUtil.openDBConnection();
return applicationDAO.isFavouriteApp(appId, userName, tenantId);
} catch (DBConnectionException e) {
String msg = "Error occurred while getting DB connection to check is app with the id " + appId
+ " is a favourite app";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred while checking app with the id " + appId + " is a favourite app.";
log.error(msg);
throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
/**
* Use to check if the requested application id is valid before removing from favourites
*
* @param appId ID of the application
* @throws ApplicationManagementException if ID is not valid or errors while validating
*/
private void validateRemoveAppFromFavouritesRequest(int appId) throws ApplicationManagementException {
if (!isFavouriteApp(appId)) {
String msg = "Provided appId " + appId + " is not a favourite app in order remove from favourites";
throw new BadRequestException(msg);
}
}
/**
* Use to check if the requested application id is valid before adding to favourites
*
* @param appId ID of the application
* @throws ApplicationManagementException if ID is not valid or errors while validating
*/
private void validateAddAppToFavouritesRequest(int appId) throws ApplicationManagementException {
try {
getApplication(appId);
} catch (NotFoundException e) {
String msg = " No application exists for the provided appId " + appId;
throw new BadRequestException(msg);
}
if (isFavouriteApp(appId)) {
String msg = "Provided appId " + appId + " is already a favourite app";
throw new BadRequestException(msg);
}
}
@Override
public Application createPublicApp(PublicAppWrapper publicAppWrapper, ApplicationArtifact applicationArtifact, boolean isPublished)
throws ApplicationManagementException {
@ -608,9 +718,17 @@ ApplicationManagerImpl implements ApplicationManager {
return applicationReleaseDTO;
}
@Override
public ApplicationList getFavouriteApplications(Filter filter) throws ApplicationManagementException {
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
filter.setFavouredBy(userName);
return getApplications(filter);
}
@Override
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
ApplicationList applicationList = new ApplicationList();
List<Application> applications = new ArrayList<>();
DeviceType deviceType;
@ -636,6 +754,7 @@ ApplicationManagerImpl implements ApplicationManager {
.setUnrestrictedRoles(visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId));
applicationDTO.setAppCategories(applicationDAO.getAppCategories(applicationDTO.getId(), tenantId));
applicationDTO.setTags(applicationDAO.getAppTags(applicationDTO.getId(), tenantId));
applicationDTO.setFavourite(applicationDAO.isFavouriteApp(applicationDTO.getId(), userName, tenantId));
if (isFilteringApp(applicationDTO, filter)) {
boolean isHideableApp = isHideableApp(applicationDTO.getApplicationReleaseDTOs());
@ -3549,7 +3668,40 @@ ApplicationManagerImpl implements ApplicationManager {
}
@Override
public void updateSubsStatus (int deviceId, int operationId, String status) throws ApplicationManagementException {
public void updateSubStatus(int deviceId, List<Integer> operationIds, String status) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
ConnectionManagerUtil.beginDBTransaction();
for (int operationId : operationIds) {
List<Integer> deviceSubIds = subscriptionDAO.getDeviceSubIdsForOperation(operationId, deviceId, tenantId);
if (!subscriptionDAO.updateDeviceSubStatus(deviceId, deviceSubIds, status, tenantId)){
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Didn't update an any app subscription of device for operation Id: " + operationId;
log.error(msg);
throw new ApplicationManagementException(msg);
}
}
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
String msg = "Error occured while updating app subscription status of the device.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while obersving the database connection to update aoo subscription status of "
+ "device.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (TransactionManagementException e) {
String msg = "Error occurred while executing database transaction";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
@Override
public void updateSubsStatus(int deviceId, int operationId, String status) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try {
ConnectionManagerUtil.beginDBTransaction();

@ -20,6 +20,7 @@ package io.entgra.application.mgt.core.impl;
import com.google.gson.Gson;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.lang.StringUtils;
@ -1189,18 +1190,62 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
}
@Override
public void updateSubscriptionStatus(int deviceId, int subId, String status)
throws SubscriptionManagementException {
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
List<Integer> operationIds = getOperationIdsForSubId(subId, tenantId);
APIUtil.getApplicationManager().updateSubStatus(deviceId, operationIds, status);
} catch (DBConnectionException e) {
String msg = "Error occurred while observing the database connection to get operation Ids for " + subId;
log.error(msg, e);
throw new SubscriptionManagementException(msg, e);
} catch (ApplicationManagementException e) {
String msg = "Error occurred while updating subscription status with the id: "
+ subId;
log.error(msg, e);
throw new SubscriptionManagementException(msg, e);
}
}
private List<Integer> getOperationIdsForSubId(int subId, int tenantId) throws SubscriptionManagementException {
try {
ConnectionManagerUtil.openDBConnection();
return subscriptionDAO.getOperationIdsForSubId(subId, tenantId);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred while getting operation Ids for subId" + subId;
log.error(msg, e);
throw new SubscriptionManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while observing the database connection to get operation Ids for " + subId;
log.error(msg, e);
throw new SubscriptionManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
private int invokeIOTCoreAPI(HttpMethodBase request) throws UserStoreException, APIManagerException, IOException {
HttpClient httpClient;
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
ApiApplicationKey apiApplicationKey = OAuthUtils.getClientCredentials(tenantDomain);
String username =
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration()
.getAdminUserName() + Constants.ApplicationInstall.AT + tenantDomain;
AccessTokenInfo tokenInfo = OAuthUtils.getOAuthCredentials(apiApplicationKey, username);
request.addRequestHeader(Constants.ApplicationInstall.AUTHORIZATION,
Constants.ApplicationInstall.AUTHORIZATION_HEADER_VALUE + tokenInfo.getAccessToken());
httpClient = new HttpClient();
httpClient.executeMethod(request);
return request.getStatusCode();
}
public int installEnrollmentApplications(ApplicationPolicyDTO applicationPolicyDTO)
throws ApplicationManagementException {
HttpClient httpClient;
PostMethod request;
try {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
ApiApplicationKey apiApplicationKey = OAuthUtils.getClientCredentials(tenantDomain);
String username =
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration()
.getAdminUserName() + Constants.ApplicationInstall.AT + tenantDomain;
AccessTokenInfo tokenInfo = OAuthUtils.getOAuthCredentials(apiApplicationKey, username);
String requestUrl = Constants.ApplicationInstall.ENROLLMENT_APP_INSTALL_PROTOCOL + System
.getProperty(Constants.ApplicationInstall.IOT_CORE_HOST) + Constants.ApplicationInstall.COLON
+ System.getProperty(Constants.ApplicationInstall.IOT_CORE_PORT)
@ -1210,14 +1255,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
StringRequestEntity requestEntity = new StringRequestEntity(payload, MediaType.APPLICATION_JSON,
Constants.ApplicationInstall.ENCODING);
httpClient = new HttpClient();
request = new PostMethod(requestUrl);
request.addRequestHeader(Constants.ApplicationInstall.AUTHORIZATION,
Constants.ApplicationInstall.AUTHORIZATION_HEADER_VALUE + tokenInfo.getAccessToken());
request.setRequestEntity(requestEntity);
httpClient.executeMethod(request);
return request.getStatusCode();
return invokeIOTCoreAPI(request);
} catch (UserStoreException e) {
String msg = "Error while accessing user store for user with Android device.";
log.error(msg, e);
@ -1240,6 +1280,13 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
}
private String getIOTCoreBaseUrl() {
return Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + System
.getProperty(Constants.IOT_CORE_HOST) + Constants.COLON
+ System.getProperty(Constants.IOT_CORE_HTTPS_PORT);
}
@Override
public PaginationResult getAppInstalledDevices(PaginationRequest request, String appUUID)
throws ApplicationManagementException {
@ -1430,6 +1477,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
deviceSubscriptionData.setActionType(subscription.getActionTriggeredFrom());
deviceSubscriptionData.setStatus(subscription.getStatus());
deviceSubscriptionData.setSubId(subscription.getId());
deviceSubscriptionDataList.add(deviceSubscriptionData);
break;
}

@ -362,6 +362,7 @@ public class APIUtil {
application.setTags(applicationDTO.getTags());
application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles());
application.setRating(applicationDTO.getAppRating());
application.setFavourite(applicationDTO.isFavourite());
application.setInstallerName(applicationDTO.getApplicationReleaseDTOs().get(0).getInstallerName());
List<ApplicationRelease> applicationReleases = new ArrayList<>();
if (ApplicationType.PUBLIC.toString().equals(applicationDTO.getType()) && application.getCategories()

@ -44,7 +44,11 @@ public class Constants {
public static final String IOT_CORE_HTTPS_PORT = "iot.core.https.port";
public static final String HTTPS_PROTOCOL = "https";
public static final String HTTP_PROTOCOL = "http";
public static final String SCHEME_SEPARATOR = "://";
public static final String OPERATION_STATUS_UPDATE_API_BASE = "/api/device-mgt/v1.0/devices";
public static final String OPERATION_STATUS_UPDATE_API_URI = "/operation";
public static final String COLON = ":";
public static final String FORWARD_SLASH = "/";
public static final String ANY = "ANY";
public static final String DEFAULT_PCK_NAME = "default.app.com";

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

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

@ -0,0 +1,43 @@
package io.entgra.application.mgt.store.api.beans;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* This is used to map the status of subscription.
*/
@ApiModel(
value = "SubscriptionStatusBean",
description = "This class carries all information related map statuses of the subscription."
)
public class SubscriptionStatusBean {
@ApiModelProperty(
name = "sub id",
value = "Subscription Id.",
required = true
)
private int subId;
@ApiModelProperty(
name = "status",
value = "Status of the subscription.",
required = true
)
private String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getSubId() {
return subId;
}
public void setSubId(int subId) {
this.subId = subId;
}
}

@ -35,8 +35,10 @@ import io.entgra.application.mgt.common.ApplicationList;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@ -70,6 +72,13 @@ import javax.ws.rs.core.Response;
key = "perm:app:store:view",
roles = {"Internal/devicemgt-user"},
permissions = {"/app-mgt/store/application/view"}
),
@Scope(
name = "Modify Application",
description = "Modify application state",
key = "perm:app:store:modify",
roles = {"Internal/devicemgt-user"},
permissions = {"/app-mgt/store/application/modify"}
)
}
)
@ -81,6 +90,120 @@ public interface ApplicationManagementAPI {
String SCOPE = "scope";
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("/favourite/{appId}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "add application to favourites",
notes = "This will add application to favourites",
tags = "Application Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:app:store:modify")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully added application to favourites.",
response = ApplicationList.class),
@ApiResponse(
code = 400,
message = "Bad Request. \n " +
"Payload contains unacceptable or vulnerable data"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while adding the application to favourites.",
response = ErrorResponse.class)
})
Response addAppToFavourite(
@ApiParam(
name = "appId",
value = "id of the application",
required = true)
@PathParam("appId") int appId);
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("/favourite/{appId}")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "DELETE",
value = "remove application from favourites",
notes = "This will removing an application from favourites",
tags = "Application Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:app:store:modify")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully removed application from favourites.",
response = ApplicationList.class),
@ApiResponse(
code = 400,
message = "Bad Request. \n " +
"Payload contains unacceptable or vulnerable data"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while removing the application from favourites.",
response = ErrorResponse.class)
})
Response removeAppFromFavourite(
@ApiParam(
name = "appId",
value = "id of the application",
required = true)
@PathParam("appId") int appId);
@POST
@Path("/favourite")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "get all favourite applications",
notes = "This will get all favourite applications",
tags = "Application Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:app:store:view")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully got application list.",
response = ApplicationList.class),
@ApiResponse(
code = 400,
message = "Bad Request. \n " +
"Application retrieving request payload contains unacceptable or vulnerable data"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while getting the application list.",
response = ErrorResponse.class)
})
Response getFavouriteApplications(
@ApiParam(
name = "filter",
value = "Application filtering data",
required = true)
@Valid Filter filter);
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)

@ -17,6 +17,7 @@
*/
package io.entgra.application.mgt.store.api.services.admin;
import io.entgra.application.mgt.store.api.beans.SubscriptionStatusBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -34,6 +35,7 @@ import io.entgra.application.mgt.common.ErrorResponse;
import javax.validation.constraints.Size;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@ -69,6 +71,13 @@ import java.util.List;
key = "perm:admin:app:subscription:view",
roles = {"Internal/devicemgt-admin"},
permissions = {"/app-mgt/store/admin/subscription/view"}
),
@Scope(
name = "View Application Subscriptions",
description = "View Application Subscriptions.",
key = "perm:admin:app:subscription:modify",
roles = {"Internal/devicemgt-admin"},
permissions = {"/app-mgt/store/admin/subscription/modify"}
)
}
)
@ -79,6 +88,51 @@ public interface SubscriptionManagementAdminAPI {
String SCOPE = "scope";
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Path("/device/{deviceId}/status")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Update subscription status",
notes = "This will update the subscription status that belongs to the given device id",
tags = "Subscription Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:admin:app:subscription:modify")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully updated subscription status.",
response = List.class,
responseContainer = "List"),
@ApiResponse(
code = 404,
message = "Not Found. \n No Application found which has application release of UUID.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while updating subscription status",
response = ErrorResponse.class)
})
Response updateSubscription(
@ApiParam(
name = "deviceId",
value = "Id of the device",
required = true)
@PathParam("deviceId") int deviceId,
@ApiParam(
name = "subscription status change bean",
value = "this bean contains the information related to status change",
required = true)
SubscriptionStatusBean subscriptionStatusBean
);
@GET
@Path("/{uuid}")
@Produces(MediaType.APPLICATION_JSON)

@ -28,14 +28,15 @@ import io.entgra.application.mgt.core.exception.NotFoundException;
import io.entgra.application.mgt.core.exception.UnexpectedServerErrorException;
import io.entgra.application.mgt.core.util.APIUtil;
import io.entgra.application.mgt.store.api.services.ApplicationManagementAPI;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
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.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
@ -47,30 +48,88 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
private static final Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
@POST
@Path("/favourite/{appId}")
@Override
@Consumes(MediaType.APPLICATION_JSON)
public Response addAppToFavourite(@PathParam("appId") int appId) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
applicationManager.addAppToFavourites(appId);
return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) {
String msg = "Invalid payload found in the request. Hence verify the request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while adding application to favourites";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@DELETE
@Path("/favourite/{appId}")
@Override
@Consumes(MediaType.APPLICATION_JSON)
public Response removeAppFromFavourite(@PathParam("appId") int appId) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
applicationManager.removeAppFromFavourites(appId);
return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) {
String msg = "Invalid payload found in the request. Hence verify the request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while removing application from favourites";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@POST
@Path("/favourite")
@Override
@Consumes(MediaType.APPLICATION_JSON)
public Response getFavouriteApplications(@Valid Filter filter) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
validateFilter(filter);
ApplicationList applications = applicationManager.getFavouriteApplications(filter);
return Response.status(Response.Status.OK).entity(applications).build();
} catch (BadRequestException e) {
String msg = "Invalid filter payload found in the request. Hence verify the filter payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while retrieving favourite applications";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@POST
@Override
@Consumes("application/json")
public Response getApplications(@Valid Filter filter) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
if (filter == null) {
String msg = "Request Payload is null";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}
validateFilter(filter);
filter.setAppReleaseState(applicationManager.getInstallableLifecycleState());
ApplicationList applications = applicationManager.getApplications(filter);
return Response.status(Response.Status.OK).entity(applications).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
String msg = "Invalid request payload found in the request. Hence verify the payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (UnexpectedServerErrorException e) {
String msg = e.getMessage();
String msg = "Unexpected Error occurred while retrieving applications";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = e.getMessage();
String msg = "Error occurred while retrieving applications";
log.error(msg);
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
@ -101,4 +160,18 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
/**
* This method can be used to check & validate if {@link Filter} object exist.
*
* @param filter {@link Filter}
* @throws BadRequestException if filter object doesn't exist
*/
private void validateFilter(Filter filter) throws BadRequestException {
if (filter == null) {
String msg = "Request Payload is null";
log.error(msg);
throw new BadRequestException(msg);
}
}
}

@ -18,6 +18,8 @@
package io.entgra.application.mgt.store.api.services.impl.admin;
import io.entgra.application.mgt.common.exception.SubscriptionManagementException;
import io.entgra.application.mgt.store.api.beans.SubscriptionStatusBean;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -34,10 +36,12 @@ import org.wso2.carbon.device.mgt.common.PaginationResult;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
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.List;
@ -50,6 +54,30 @@ public class SubscriptionManagementAdminAPIImpl implements SubscriptionManagemen
private static final Log log = LogFactory.getLog(SubscriptionManagementAdminAPIImpl.class);
@Override
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Path("/device/{deviceId}/status")
public Response updateSubscription(
@PathParam("deviceId") int deviceId,
SubscriptionStatusBean subscriptionStatusBean
) {
try {
RequestValidationUtil.validateSubscriptionStatus(subscriptionStatusBean.getStatus());
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
subscriptionManager.updateSubscriptionStatus(deviceId, subscriptionStatusBean.getSubId(),
subscriptionStatusBean.getStatus());
return Response.status(Response.Status.OK).entity("Subscription status updated successfully").build();
} catch (BadRequestException e) {
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
} catch (SubscriptionManagementException e) {
String msg = "Error occurred while changing subscription status of the subscription with the id "
+ subscriptionStatusBean.getSubId();
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}
@GET
@Consumes("application/json")
@Produces("application/json")

@ -18,12 +18,16 @@
*/
package io.entgra.application.mgt.store.api.services.impl.util;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import io.entgra.application.mgt.core.exception.BadRequestException;
import io.entgra.application.mgt.store.api.util.Constants;
import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus;
import java.util.List;
import java.util.StringJoiner;
public class RequestValidationUtil {
@ -113,4 +117,18 @@ public class RequestValidationUtil {
throw new BadRequestException(msg);
}
}
/**
* Checks if user requested subscription status is valid.
*
*/
public static void validateSubscriptionStatus(String status) throws BadRequestException{
if (!EnumUtils.isValidEnum(ActivityStatus.Status.class, status)) {
List<ActivityStatus.Status> validStatuses = EnumUtils.getEnumList(ActivityStatus.Status.class);
String validStatusesString = StringUtils.join(validStatuses, " | ");
String msg = "Invalid status type: " + status + ". \nValid status types are " + validStatusesString;
log.error(msg);
throw new BadRequestException(msg);
}
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -20,7 +20,11 @@ package org.wso2.carbon.device.mgt.core.dao.impl.device;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.Count;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
@ -926,6 +930,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
String name = request.getDeviceName();
String user = request.getOwner();
String ownership = request.getOwnership();
String query = null;
try {
List<Device> devices = new ArrayList<>();
if (deviceIds.isEmpty()) {
@ -961,10 +966,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "
+ "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ?");
") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString();
query = joiner.toString();
if (name != null && !name.isEmpty()) {
query += " AND DM_DEVICE.NAME LIKE ?";
@ -991,6 +996,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
ps.setObject(index++, deviceId);
}
ps.setInt(index++, tenantId);
ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString());
if (isDeviceNameProvided) {
ps.setString(index++, name + "%");
}
@ -1017,7 +1023,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
}
} catch (SQLException e) {
String msg = "Error occurred while retrieving information of all registered devices " +
"according to device ids and the limit area.";
"according to device ids and the limit area. Executed query " + query;
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -278,3 +278,17 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION(
FOREIGN KEY (APPLICATION_UUID)
REFERENCES AP_APP_RELEASE (UUID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
-- -----------------------------------------------------
-- Table AP_APP_FAVOURITES
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES(
ID INTEGER NOT NULL AUTO_INCREMENT,
AP_APP_ID INTEGER NOT NULL,
USER_NAME VARCHAR(100) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(ID),
CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk
FOREIGN KEY (AP_APP_ID)
REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);

@ -278,4 +278,18 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION(
CONSTRAINT fk_AP_SCHEDULED_SUBSCRIPTION_AP_APP_RELEASE
FOREIGN KEY (APPLICATION_UUID)
REFERENCES AP_APP_RELEASE (UUID) ON DELETE NO ACTION ON UPDATE NO ACTION
);
);
-- -----------------------------------------------------
-- Table AP_APP_FAVOURITES
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES(
ID INTEGER NOT NULL IDENTITY,
AP_APP_ID INTEGER NOT NULL,
USER_NAME VARCHAR(100) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(ID),
CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk
FOREIGN KEY (AP_APP_ID)
REFERENCES AP_APP (ID)
);

@ -274,4 +274,18 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION(
SCHEDULED_TIMESTAMP TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
DELETED BOOLEAN,
PRIMARY KEY (ID)
);
);
-- -----------------------------------------------------
-- Table AP_APP_FAVOURITES
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES(
ID INTEGER NOT NULL AUTO_INCREMENT,
AP_APP_ID INTEGER NOT NULL,
USER_NAME VARCHAR(100) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(ID),
CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk
FOREIGN KEY (AP_APP_ID)
REFERENCES AP_APP (ID)
);

@ -382,3 +382,15 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION (
REFERENCES AP_APP_RELEASE (UUID)
)
/
CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES(
ID number GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL,
AP_APP_ID INTEGER NOT NULL,
USER_NAME VARCHAR(100) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(ID),
CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk
FOREIGN KEY (AP_APP_ID)
REFERENCES AP_APP (ID)
)
/

@ -305,3 +305,18 @@ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION(
DELETED BOOLEAN,
PRIMARY KEY (ID)
);
-- -----------------------------------------------------
-- Table AP_APP_FAVOURITES
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AP_APP_FAVOURITES(
ID INTEGER NOT NULL DEFAULT NEXTVAL ('AP_APP_FAVOURITES_seq'),
AP_APP_ID INTEGER NOT NULL,
USER_NAME VARCHAR(100) NOT NULL,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY(ID),
CONSTRAINT AP_APP_FAVOURITES_AP_APP_ID_fk
FOREIGN KEY (AP_APP_ID)
REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
);

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

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

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

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

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

Loading…
Cancel
Save