Merge pull request #899 from Megala21/appm_new

Refactoring
feature/appm-store/pbac
Megala Uthayakumar 7 years ago committed by GitHub
commit b05b392534

@ -34,12 +34,23 @@ import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList; import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.*; 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;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List;
/**
* APIs to handle application management related tasks.
*/
@SwaggerDefinition( @SwaggerDefinition(
info = @Info( info = @Info(
version = "1.0.0", version = "1.0.0",
@ -98,7 +109,7 @@ import java.util.List;
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface ApplicationManagementAPI { public interface ApplicationManagementAPI {
public final static String SCOPE = "scope"; String SCOPE = "scope";
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ -124,8 +135,8 @@ public interface ApplicationManagementAPI {
response = ApplicationList.class), response = ApplicationList.class),
@ApiResponse( @ApiResponse(
code = 304, code = 304,
message = "Not Modified. \n " + message = "Not Modified. Empty body because the client already has the latest version "
"Empty body because the client already has the latest version of the requested resource."), + "of the requested resource."),
@ApiResponse( @ApiResponse(
code = 500, code = 500,
message = "Internal Server Error. \n Error occurred while getting the application list.", message = "Internal Server Error. \n Error occurred while getting the application list.",
@ -134,21 +145,15 @@ public interface ApplicationManagementAPI {
Response getApplications( Response getApplications(
@ApiParam( @ApiParam(
name = "offset", name = "offset",
value = "Provide from which position apps should return", value = "Provide from which position apps should return", defaultValue = "20")
required = false,
defaultValue = "20")
@QueryParam("offset") int offset, @QueryParam("offset") int offset,
@ApiParam( @ApiParam(
name = "limit", name = "limit",
value = "Provide how many apps it should return", value = "Provide how many apps it should return", defaultValue = "0")
required = false,
defaultValue = "0")
@QueryParam("limit") int limit, @QueryParam("limit") int limit,
@ApiParam( @ApiParam(
name = "searchQuery", name = "searchQuery",
value = "Relevant search query to search on", value = "Relevant search query to search on", defaultValue = "*")
required = false,
defaultValue = "*")
@QueryParam("searchQuery") String searchQuery @QueryParam("searchQuery") String searchQuery
); );

@ -25,7 +25,6 @@ import org.wso2.carbon.device.application.mgt.api.services.ApplicationManagement
import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList; import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.Filter; import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.User;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.Constants;
@ -43,7 +42,9 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/**
* Implementation of Application Management related APIs.
*/
@Produces({"application/json"}) @Produces({"application/json"})
@Consumes({"application/json"}) @Consumes({"application/json"})
@Path("/applications") @Path("/applications")

@ -22,16 +22,12 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.api.APIUtil; import org.wso2.carbon.device.application.mgt.api.APIUtil;
import org.wso2.carbon.device.application.mgt.api.services.LifecycleManagementAPI; import org.wso2.carbon.device.application.mgt.api.services.LifecycleManagementAPI;
import org.wso2.carbon.device.application.mgt.common.LifecycleState; import org.wso2.carbon.device.application.mgt.common.LifecycleState;
import org.wso2.carbon.device.application.mgt.common.User;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException; import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;

@ -18,13 +18,14 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.config; package org.wso2.carbon.device.application.mgt.core.config;
import org.wso2.carbon.device.application.mgt.core.deployer.Platform; import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* Represents the Application Management Configuration.
*/
@XmlRootElement(name = "ApplicationManagementConfiguration") @XmlRootElement(name = "ApplicationManagementConfiguration")
public class Configuration { public class Configuration {

@ -24,10 +24,13 @@ import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManage
import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException; import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException;
import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.Constants;
import java.io.File;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
import java.io.File;
/**
* ConfigurationManager is responsible for the managing Application Management related configurations.
*/
public class ConfigurationManager { public class ConfigurationManager {
private static final Log log = LogFactory.getLog(ConfigurationManager.class); private static final Log log = LogFactory.getLog(ConfigurationManager.class);

@ -18,9 +18,15 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.config; package org.wso2.carbon.device.application.mgt.core.config;
import javax.xml.bind.annotation.*;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Represents a extension in the application management configuration.
*/
@XmlRootElement(name = "Extension") @XmlRootElement(name = "Extension")
public class Extension { public class Extension {
@ -68,6 +74,9 @@ public class Extension {
return false; return false;
} }
/**
* ApplicationManagement Extensions.
*/
public enum Name { public enum Name {
ApplicationManager, ApplicationManager,
ApplicationReleaseManager, ApplicationReleaseManager,

@ -22,6 +22,9 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.XmlValue;
/**
* Parameter of the extensions.
*/
@XmlRootElement(name = "Parameter") @XmlRootElement(name = "Parameter")
public class Parameter { public class Parameter {

@ -18,6 +18,9 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.dao; package org.wso2.carbon.device.application.mgt.core.dao;
/**
* This is responsible for Application Release related DAO operations.
*/
public interface ApplicationReleaseDAO { public interface ApplicationReleaseDAO {
} }

@ -18,5 +18,8 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.dao; package org.wso2.carbon.device.application.mgt.core.dao;
/**
* This is responsible for Application Category related DAO operations.
*/
public interface CategoryDAO { public interface CategoryDAO {
} }

@ -21,7 +21,12 @@ package org.wso2.carbon.device.application.mgt.core.dao.common;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONException; import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.common.*; import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.Category;
import org.wso2.carbon.device.application.mgt.common.Lifecycle;
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
import org.wso2.carbon.device.application.mgt.common.Platform;
import org.wso2.carbon.device.application.mgt.common.User;
import org.wso2.carbon.device.application.mgt.core.util.JSONUtil; import org.wso2.carbon.device.application.mgt.core.util.JSONUtil;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;

@ -21,21 +21,34 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONException; import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.common.*; import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.LifecycleStateTransition;
import org.wso2.carbon.device.application.mgt.common.Pagination;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO; import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil;
import org.wso2.carbon.device.application.mgt.core.util.JSONUtil; import org.wso2.carbon.device.application.mgt.core.util.JSONUtil;
import java.sql.*; import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* This handles ApplicationDAO related operations.
*/
public class GenericApplicationDAOImpl extends AbstractDAOImpl implements ApplicationDAO { public class GenericApplicationDAOImpl extends AbstractDAOImpl implements ApplicationDAO {
private static final Log log = LogFactory.getLog(GenericApplicationDAOImpl.class); private static final Log log = LogFactory.getLog(GenericApplicationDAOImpl.class);
@ -78,8 +91,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.setInt(14, application.getPlatform().getId()); stmt.setInt(14, application.getPlatform().getId());
stmt.setInt(15, application.getUser().getTenantId()); stmt.setInt(15, application.getUser().getTenantId());
stmt.setInt(16, application.getCurrentLifecycle().getLifecycleState().getId()); stmt.setInt(16, application.getCurrentLifecycle().getLifecycleState().getId());
stmt.setDate(17, new Date( stmt.setDate(17, new Date(application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime()));
application.getCurrentLifecycle().getLifecycleStateModifiedAt().getTime()));
stmt.setString(18, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy()); stmt.setString(18, application.getCurrentLifecycle().getGetLifecycleStateModifiedBy());
stmt.executeUpdate(); stmt.executeUpdate();
@ -88,6 +100,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
application.setId(rs.getInt(1)); application.setId(rs.getInt(1));
} }
insertApplicationTagsAndProperties(application, stmt, conn, isBatchExecutionSupported); insertApplicationTagsAndProperties(application, stmt, conn, isBatchExecutionSupported);
return application;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) { } catch (SQLException e) {
@ -95,8 +108,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} finally { } finally {
Util.cleanupResources(stmt, rs); Util.cleanupResources(stmt, rs);
} }
return application;
} }
@ -276,9 +287,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
Util.cleanupResources(null, rsProperties); Util.cleanupResources(null, rsProperties);
Util.cleanupResources(null, rsTags); Util.cleanupResources(null, rsTags);
} }
return application;
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting application details with UUID " throw new ApplicationManagementDAOException(
+ uuid, e); "Error occurred while getting application details with UUID " + uuid, e);
} catch (JSONException e) { } catch (JSONException e) {
throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e); throw new ApplicationManagementDAOException("Error occurred while parsing JSON", e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -286,7 +298,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} finally { } finally {
Util.cleanupResources(stmt, rs); Util.cleanupResources(stmt, rs);
} }
return application;
} }
@Override @Override
@ -361,9 +372,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
@Override @Override
public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException { public Application editApplication(Application application, int tenantId) throws ApplicationManagementDAOException {
Connection conn = null; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null;
String sql = ""; String sql = "";
boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported(); boolean isBatchExecutionSupported = ConnectionManagerUtil.isBatchQuerySupported();
try { try {
@ -431,13 +441,14 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
stmt.executeUpdate(); stmt.executeUpdate();
insertApplicationTagsAndProperties(application, stmt, conn, isBatchExecutionSupported); insertApplicationTagsAndProperties(application, stmt, conn, isBatchExecutionSupported);
return application;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding the application", e); throw new ApplicationManagementDAOException("Error occurred while adding the application", e);
} finally {
Util.cleanupResources(stmt, null);
} }
return application;
} }
/** /**
@ -509,7 +520,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
@Override @Override
public void deleteProperties(int applicationId) throws ApplicationManagementDAOException { public void deleteProperties(int applicationId) throws ApplicationManagementDAOException {
Connection conn = null; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
@ -530,10 +541,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
@Override @Override
public void deleteTags(int applicationId) throws ApplicationManagementDAOException { public void deleteTags(int applicationId) throws ApplicationManagementDAOException {
Connection conn;
Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
String sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?"; String sql = "DELETE FROM APPM_APPLICATION_TAG WHERE APPLICATION_ID = ?";
@ -547,7 +556,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Error occurred while deleting tags of application: " + applicationId, e); "Error occurred while deleting tags of application: " + applicationId, e);
} finally { } finally {
Util.cleanupResources(stmt, rs); Util.cleanupResources(stmt, null);
} }
} }
@ -556,13 +565,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
String sql = ""; String sql;
int id = 0; int id = 0;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
sql += "SELECT ID FROM APPM_APPLICATION WHERE UUID = ?"; sql = "SELECT ID FROM APPM_APPLICATION WHERE UUID = ?";
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString(1, uuid); stmt.setString(1, uuid);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -576,7 +583,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} finally { } finally {
Util.cleanupResources(stmt, rs); Util.cleanupResources(stmt, rs);
} }
return id; return id;
} }

@ -21,12 +21,25 @@ package org.wso2.carbon.device.application.mgt.core.util;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException; import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException;
import org.wso2.carbon.device.application.mgt.common.services.*; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationUploadManager;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager;
import org.wso2.carbon.device.application.mgt.common.services.PlatformManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
import org.wso2.carbon.device.application.mgt.common.services.VisibilityManager;
import org.wso2.carbon.device.application.mgt.common.services.VisibilityTypeManager;
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.config.Extension; import org.wso2.carbon.device.application.mgt.core.config.Extension;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
/**
* This Util class is responsible for making sure single instance of each Extension Manager is used throughout for
* all the tasks.
*/
public class ApplicationManagementUtil { public class ApplicationManagementUtil {
private static Log log = LogFactory.getLog(ApplicationManagementUtil.class); private static Log log = LogFactory.getLog(ApplicationManagementUtil.class);
@ -37,7 +50,8 @@ public class ApplicationManagementUtil {
return getInstance(extension, ApplicationManager.class); return getInstance(extension, ApplicationManager.class);
} }
public static ApplicationReleaseManager getApplicationReleaseManagerInstance() throws InvalidConfigurationException { public static ApplicationReleaseManager getApplicationReleaseManagerInstance()
throws InvalidConfigurationException {
ConfigurationManager configurationManager = ConfigurationManager.getInstance(); ConfigurationManager configurationManager = ConfigurationManager.getInstance();
Extension extension = configurationManager.getExtension(Extension.Name.ApplicationReleaseManager); Extension extension = configurationManager.getExtension(Extension.Name.ApplicationReleaseManager);
return getInstance(extension, ApplicationReleaseManager.class); return getInstance(extension, ApplicationReleaseManager.class);
@ -108,8 +122,9 @@ public class ApplicationManagementUtil {
return constructor.newInstance(); return constructor.newInstance();
} }
} catch (Exception e) { } catch (Exception e) {
throw new InvalidConfigurationException("Unable to get instance of extension - " + extension.getName() throw new InvalidConfigurationException(
+ " , for class - " + extension.getClassName(), e); "Unable to get instance of extension - " + extension.getName() + " , for class - " + extension
.getClassName(), e);
} }
} }
} }

@ -18,11 +18,11 @@
package org.wso2.carbon.device.application.mgt.core.util; package org.wso2.carbon.device.application.mgt.core.util;
import java.io.File;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator; import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
import java.io.File;
/** /**
* ApplicationMgtDatabaseCreator is responsible for creating the Application Management related tables. * ApplicationMgtDatabaseCreator is responsible for creating the Application Management related tables.

@ -22,6 +22,9 @@ import org.wso2.carbon.utils.CarbonUtils;
import java.io.File; import java.io.File;
/**
* Application Management related constants.
*/
public class Constants { public class Constants {
public static final String APPLICATION_CONFIG_XML_FILE = "application-mgt.xml"; public static final String APPLICATION_CONFIG_XML_FILE = "application-mgt.xml";

@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.core.util;
import java.util.UUID; import java.util.UUID;
/**
* Utility methods used in the Application Management.
*/
public class HelperUtil { public class HelperUtil {
public static String generateApplicationUuid() { public static String generateApplicationUuid() {

@ -24,17 +24,18 @@ import org.json.JSONException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* This utility class handles the JSON manipulation related tasks.
*/
public class JSONUtil { public class JSONUtil {
public static List<String> jsonArrayStringToList(String value) throws JSONException { public static List<String> jsonArrayStringToList(String value) throws JSONException {
JSONArray jsonArray = new JSONArray(value); JSONArray jsonArray = new JSONArray(value);
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (jsonArray != null) {
int len = jsonArray.length(); int len = jsonArray.length();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
list.add(jsonArray.get(i).toString()); list.add(jsonArray.get(i).toString());
} }
}
return list; return list;
} }

Loading…
Cancel
Save