mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixing the merge conflicts
This commit is contained in:
commit
bd75f70a24
@ -83,8 +83,7 @@
|
|||||||
org.wso2.carbon.identity.oauth.stub,
|
org.wso2.carbon.identity.oauth.stub,
|
||||||
org.wso2.carbon.identity.oauth.stub.dto,
|
org.wso2.carbon.identity.oauth.stub.dto,
|
||||||
org.wso2.carbon.ndatasource.core,
|
org.wso2.carbon.ndatasource.core,
|
||||||
org.wso2.carbon.base,
|
org.apache.catalina
|
||||||
org.wso2.carbon.base.api
|
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
<Export-Package>
|
<Export-Package>
|
||||||
!org.wso2.carbon.device.mgt.core.internal,
|
!org.wso2.carbon.device.mgt.core.internal,
|
||||||
@ -209,6 +208,10 @@
|
|||||||
<groupId>org.wso2.carbon.identity</groupId>
|
<groupId>org.wso2.carbon.identity</groupId>
|
||||||
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
|
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -180,10 +180,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
@Override
|
@Override
|
||||||
public void updateApplicationListInstalledInDevice(
|
public void updateApplicationListInstalledInDevice(
|
||||||
DeviceIdentifier deviceIdentifier, List<Application> applications) throws ApplicationManagementException {
|
DeviceIdentifier deviceIdentifier, List<Application> applications) throws ApplicationManagementException {
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
DeviceManagementDAOFactory.beginTransaction();
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
Device device = deviceDAO.getDevice(deviceIdentifier, tenantId);
|
Device device = deviceDAO.getDevice(deviceIdentifier, tenantId);
|
||||||
|
|
||||||
@ -199,8 +197,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
List<Application> appsToAdd = new ArrayList<Application>();
|
List<Application> appsToAdd = new ArrayList<Application>();
|
||||||
List<Integer> appIdsToRemove = new ArrayList<Integer>();
|
List<Integer> appIdsToRemove = new ArrayList<Integer>();
|
||||||
|
|
||||||
for(Application installedApp:installedAppList){
|
for (Application installedApp : installedAppList) {
|
||||||
if (!applications.contains(installedApp)){
|
if (!applications.contains(installedApp)) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Remove app Id:" + installedApp.getId());
|
log.debug("Remove app Id:" + installedApp.getId());
|
||||||
}
|
}
|
||||||
@ -211,12 +209,12 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
Application installedApp;
|
Application installedApp;
|
||||||
List<Integer> applicationIds = new ArrayList<>();
|
List<Integer> applicationIds = new ArrayList<>();
|
||||||
|
|
||||||
for(Application application:applications){
|
for (Application application : applications) {
|
||||||
if (!installedAppList.contains(application)) {
|
if (!installedAppList.contains(application)) {
|
||||||
installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), tenantId);
|
installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), tenantId);
|
||||||
if (installedApp == null){
|
if (installedApp == null) {
|
||||||
appsToAdd.add(application);
|
appsToAdd.add(application);
|
||||||
}else{
|
} else {
|
||||||
applicationIds.add(installedApp.getId());
|
applicationIds.add(installedApp.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,7 +232,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("num of remove app Ids:" + appIdsToRemove.size());
|
log.debug("num of remove app Ids:" + appIdsToRemove.size());
|
||||||
}
|
}
|
||||||
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove,tenantId);
|
applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId);
|
||||||
DeviceManagementDAOFactory.commitTransaction();
|
DeviceManagementDAOFactory.commitTransaction();
|
||||||
} catch (DeviceManagementDAOException deviceDaoEx) {
|
} catch (DeviceManagementDAOException deviceDaoEx) {
|
||||||
String errorMsg = "Error occurred saving application list to the device";
|
String errorMsg = "Error occurred saving application list to the device";
|
||||||
@ -242,37 +240,26 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.rollbackTransaction();
|
DeviceManagementDAOFactory.rollbackTransaction();
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
log.error("Error occurred while roll back transaction",e);
|
log.error("Error occurred while roll back transaction", e);
|
||||||
}
|
}
|
||||||
throw new ApplicationManagementException(errorMsg, deviceDaoEx);
|
throw new ApplicationManagementException(errorMsg, deviceDaoEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private int getTenantId() {
|
|
||||||
//
|
|
||||||
// int tenantId = 0;
|
|
||||||
//// if (isTest){
|
|
||||||
//// tenantId = DeviceManagerUtil.currentTenant.get();
|
|
||||||
//// }else{
|
|
||||||
// tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// return tenantId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Application> getApplicationListForDevice(DeviceIdentifier deviceIdentifier)
|
public List<Application> getApplicationListForDevice(
|
||||||
throws ApplicationManagementException {
|
DeviceIdentifier deviceId) throws ApplicationManagementException {
|
||||||
Device device = null;
|
Device device = null;
|
||||||
try {
|
try {
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
device = deviceDAO.getDevice(deviceIdentifier, tenantId);
|
device = deviceDAO.getDevice(deviceId, tenantId);
|
||||||
return applicationDAO.getInstalledApplications(device.getId());
|
return applicationDAO.getInstalledApplications(device.getId());
|
||||||
}catch (DeviceManagementDAOException deviceDaoEx) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
String errorMsg = "Error occured while fetching the Application List of device : " + device.getId();
|
throw new ApplicationManagementException("Error occured while fetching the Application List of '" +
|
||||||
log.error(errorMsg, deviceDaoEx);
|
deviceId.getType() + "' device carrying the identifier'" + deviceId.getId(), e);
|
||||||
throw new ApplicationManagementException(errorMsg, deviceDaoEx);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -54,7 +54,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
private DeviceTypeDAO deviceTypeDAO;
|
private DeviceTypeDAO deviceTypeDAO;
|
||||||
private EnrolmentDAO enrolmentDAO;
|
private EnrolmentDAO enrolmentDAO;
|
||||||
private DeviceManagementPluginRepository pluginRepository;
|
private DeviceManagementPluginRepository pluginRepository;
|
||||||
private boolean isTest = false;
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class);
|
private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class);
|
||||||
private int tenantId;
|
private int tenantId;
|
||||||
@ -76,7 +75,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
DeviceManagementProviderServiceImpl(DeviceManagementPluginRepository pluginRepo, boolean test){
|
DeviceManagementProviderServiceImpl(DeviceManagementPluginRepository pluginRepo, boolean test){
|
||||||
this.pluginRepository = pluginRepo;
|
this.pluginRepository = pluginRepo;
|
||||||
initDataAccessObjects();
|
initDataAccessObjects();
|
||||||
isTest = test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDataAccessObjects() {
|
private void initDataAccessObjects() {
|
||||||
@ -749,14 +747,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
DeviceManagementDAOFactory.getConnection();
|
DeviceManagementDAOFactory.getConnection();
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
allDevices = deviceDAO.getDevicesByStatus(status, tenantId);
|
allDevices = deviceDAO.getDevicesByStatus(status, tenantId);
|
||||||
|
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
String errorMsg = "Error occurred while fetching the list of devices that matches to status: '"
|
throw new DeviceManagementException(
|
||||||
+ status + "'";
|
"Error occurred while fetching the list of devices that matches to status: '" + status + "'", e);
|
||||||
log.error(errorMsg, e);
|
|
||||||
throw new DeviceManagementException(errorMsg, e);
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.closeConnection();
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
@ -779,18 +773,4 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// private int getTenantId() {
|
|
||||||
//
|
|
||||||
//// ThreadLocal<Integer> tenantId = new ThreadLocal<Integer>();
|
|
||||||
// int tenant = 0;
|
|
||||||
//
|
|
||||||
//// if (isTest){
|
|
||||||
//// tenant = DeviceManagerUtil.currentTenant.get();
|
|
||||||
//// }else{
|
|
||||||
// tenant = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
//// }
|
|
||||||
// return tenant;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,11 +51,14 @@ public class URLPrinterStartupHandler implements ServerStartupObserver {
|
|||||||
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
|
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
|
||||||
ConfigurationContextService configContextService =
|
ConfigurationContextService configContextService =
|
||||||
DeviceManagementDataHolder.getInstance().getConfigurationContextService();
|
DeviceManagementDataHolder.getInstance().getConfigurationContextService();
|
||||||
int httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
|
int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
|
||||||
int httpsProxyPort =
|
int httpsProxyPort =
|
||||||
CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(),
|
CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(),
|
||||||
mgtConsoleTransport);
|
mgtConsoleTransport);
|
||||||
return "https://" + hostName + ":" + httpsPort + "/mdm";
|
if (httpsProxyPort > 0) {
|
||||||
|
port = httpsProxyPort;
|
||||||
|
}
|
||||||
|
return "https://" + hostName + ":" + port + "/mdm";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,6 @@ import java.util.*;
|
|||||||
public final class DeviceManagerUtil {
|
public final class DeviceManagerUtil {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(DeviceManagerUtil.class);
|
private static final Log log = LogFactory.getLog(DeviceManagerUtil.class);
|
||||||
public static ThreadLocal<Integer> currentTenant = new ThreadLocal<Integer>();
|
|
||||||
|
|
||||||
enum HTTPMethod {
|
enum HTTPMethod {
|
||||||
GET, POST, DELETE, PUT, OPTIONS
|
GET, POST, DELETE, PUT, OPTIONS
|
||||||
|
|||||||
@ -58,7 +58,6 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes
|
|||||||
deviceManagementProviderService = new DeviceManagementProviderServiceImpl(deviceManagementPluginRepository,
|
deviceManagementProviderService = new DeviceManagementProviderServiceImpl(deviceManagementPluginRepository,
|
||||||
true);
|
true);
|
||||||
DeviceManagerUtil.registerDeviceType(TestDataHolder.TEST_DEVICE_TYPE);
|
DeviceManagerUtil.registerDeviceType(TestDataHolder.TEST_DEVICE_TYPE);
|
||||||
DeviceManagerUtil.currentTenant.set(TestDataHolder.SUPER_TENANT_ID);
|
|
||||||
|
|
||||||
Device device = TestDataHolder.generateDummyDeviceData(TestDataHolder.TEST_DEVICE_TYPE);
|
Device device = TestDataHolder.generateDummyDeviceData(TestDataHolder.TEST_DEVICE_TYPE);
|
||||||
boolean isEnrolled = deviceManagementProviderService.enrollDevice(device);
|
boolean isEnrolled = deviceManagementProviderService.enrollDevice(device);
|
||||||
|
|||||||
@ -24,17 +24,17 @@
|
|||||||
|
|
||||||
<test name="DAO Unit Tests" preserve-order="true">
|
<test name="DAO Unit Tests" preserve-order="true">
|
||||||
<classes>
|
<classes>
|
||||||
<class name="org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest"/>-->
|
||||||
<class name="org.wso2.carbon.device.mgt.core.dao.DevicePersistTests"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.dao.DevicePersistTests"/>-->
|
||||||
<class name="org.wso2.carbon.device.mgt.core.DeviceManagementRepositoryTests"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.DeviceManagementRepositoryTests"/>-->
|
||||||
<class name="org.wso2.carbon.device.mgt.core.DeviceManagementConfigTests"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.DeviceManagementConfigTests"/>-->
|
||||||
<class name="org.wso2.carbon.device.mgt.core.dao.ApplicationPersistenceTests"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.dao.ApplicationPersistenceTests"/>-->
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
<test name="Service Unit Tests" preserve-order="true">
|
<test name="Service Unit Tests" preserve-order="true">
|
||||||
<classes>
|
<classes>
|
||||||
<class name="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceTest"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceTest"/>-->
|
||||||
<class name="org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderServiceTest"/>
|
<!--<class name="org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderServiceTest"/>-->
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
</suite>
|
</suite>
|
||||||
@ -53,4 +53,6 @@ public interface FeatureDAO {
|
|||||||
|
|
||||||
boolean deleteFeaturesOfProfile(Profile profile) throws FeatureManagerDAOException;
|
boolean deleteFeaturesOfProfile(Profile profile) throws FeatureManagerDAOException;
|
||||||
|
|
||||||
|
boolean deleteFeaturesOfProfile(int profileId) throws FeatureManagerDAOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,8 @@ public interface ProfileDAO {
|
|||||||
|
|
||||||
boolean deleteProfile(Profile profile) throws ProfileManagerDAOException;
|
boolean deleteProfile(Profile profile) throws ProfileManagerDAOException;
|
||||||
|
|
||||||
|
boolean deleteProfile(int policyId) throws ProfileManagerDAOException;
|
||||||
|
|
||||||
Profile getProfiles(int profileId) throws ProfileManagerDAOException;
|
Profile getProfiles(int profileId) throws ProfileManagerDAOException;
|
||||||
|
|
||||||
List<Profile> getAllProfiles() throws ProfileManagerDAOException;
|
List<Profile> getAllProfiles() throws ProfileManagerDAOException;
|
||||||
|
|||||||
@ -261,6 +261,28 @@ public class FeatureDAOImpl implements FeatureDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteFeaturesOfProfile(int profileId) throws FeatureManagerDAOException {
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String query = "DELETE FROM DM_PROFILE_FEATURES WHERE PROFILE_ID = ?";
|
||||||
|
stmt = conn.prepareStatement(query);
|
||||||
|
stmt.setInt(1, profileId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while deleting the feature related to a profile.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new FeatureManagerDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
PolicyManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProfileFeature> getAllProfileFeatures() throws FeatureManagerDAOException {
|
public List<ProfileFeature> getAllProfileFeatures() throws FeatureManagerDAOException {
|
||||||
|
|||||||
@ -154,6 +154,29 @@ public class ProfileDAOImpl implements ProfileDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteProfile(int profileId) throws ProfileManagerDAOException {
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String query = "DELETE FROM DM_PROFILE WHERE ID = ?";
|
||||||
|
stmt = conn.prepareStatement(query);
|
||||||
|
stmt.setInt(1, profileId);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while deleting the profile from the data base.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new ProfileManagerDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
PolicyManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Profile getProfiles(int profileId) throws ProfileManagerDAOException {
|
public Profile getProfiles(int profileId) throws ProfileManagerDAOException {
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the policy (" +
|
String msg = "Error occurred while adding the policy (" +
|
||||||
policy.getId() + " - " + policy.getPolicyName() + ")";
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the profile related to policy (" +
|
String msg = "Error occurred while adding the profile related to policy (" +
|
||||||
policy.getId() + " - " + policy.getPolicyName() + ")";
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
} catch (FeatureManagerDAOException e) {
|
} catch (FeatureManagerDAOException e) {
|
||||||
@ -147,7 +147,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the features of profile related to policy (" +
|
String msg = "Error occurred while adding the features of profile related to policy (" +
|
||||||
policy.getId() + " - " + policy.getPolicyName() + ")";
|
policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while updating the policy ("
|
String msg = "Error occurred while updating the policy ("
|
||||||
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
@ -240,12 +240,14 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
public boolean deletePolicy(Policy policy) throws PolicyManagementException {
|
||||||
|
|
||||||
boolean bool;
|
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.beginTransaction();
|
PolicyManagementDAOFactory.beginTransaction();
|
||||||
bool = policyDAO.deletePolicy(policy);
|
policyDAO.deleteAllPolicyRelatedConfigs(policy.getId());
|
||||||
|
policyDAO.deletePolicy(policy.getId());
|
||||||
|
featureDAO.deleteFeaturesOfProfile(policy.getProfileId());
|
||||||
|
profileDAO.deleteProfile(policy.getProfileId());
|
||||||
PolicyManagementDAOFactory.commitTransaction();
|
PolicyManagementDAOFactory.commitTransaction();
|
||||||
|
return true;
|
||||||
} catch (PolicyManagerDAOException e) {
|
} catch (PolicyManagerDAOException e) {
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.rollbackTransaction();
|
PolicyManagementDAOFactory.rollbackTransaction();
|
||||||
@ -253,21 +255,51 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while deleting the policy ("
|
String msg = "Error occurred while deleting the policy ("
|
||||||
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PolicyManagementException(msg, e);
|
||||||
|
} catch (ProfileManagerDAOException e) {
|
||||||
|
try {
|
||||||
|
PolicyManagementDAOFactory.rollbackTransaction();
|
||||||
|
} catch (PolicyManagerDAOException e1) {
|
||||||
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
|
}
|
||||||
|
String msg = "Error occurred while deleting the profile for policy ("
|
||||||
|
+ policy.getId() + ")";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PolicyManagementException(msg, e);
|
||||||
|
} catch (FeatureManagerDAOException e) {
|
||||||
|
try {
|
||||||
|
PolicyManagementDAOFactory.rollbackTransaction();
|
||||||
|
} catch (PolicyManagerDAOException e1) {
|
||||||
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
|
}
|
||||||
|
String msg = "Error occurred while deleting the profile features for policy ("
|
||||||
|
+ policy.getId() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
return bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
public boolean deletePolicy(int policyId) throws PolicyManagementException {
|
||||||
boolean bool;
|
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.beginTransaction();
|
PolicyManagementDAOFactory.beginTransaction();
|
||||||
|
Policy policy = policyDAO.getPolicy(policyId);
|
||||||
policyDAO.deleteAllPolicyRelatedConfigs(policyId);
|
policyDAO.deleteAllPolicyRelatedConfigs(policyId);
|
||||||
bool = policyDAO.deletePolicy(policyId);
|
policyDAO.deletePolicy(policyId);
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Profile ID: " + policy.getProfileId());
|
||||||
|
}
|
||||||
|
|
||||||
|
featureDAO.deleteFeaturesOfProfile(policy.getProfileId());
|
||||||
|
|
||||||
|
profileDAO.deleteProfile(policy.getProfileId());
|
||||||
PolicyManagementDAOFactory.commitTransaction();
|
PolicyManagementDAOFactory.commitTransaction();
|
||||||
|
return true;
|
||||||
|
|
||||||
} catch (PolicyManagerDAOException e) {
|
} catch (PolicyManagerDAOException e) {
|
||||||
try {
|
try {
|
||||||
@ -276,16 +308,35 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while deleting the policy ("
|
String msg = "Error occurred while deleting the policy ("
|
||||||
+ policyId + ")";
|
+ policyId + ")";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PolicyManagementException(msg, e);
|
||||||
|
} catch (ProfileManagerDAOException e) {
|
||||||
|
try {
|
||||||
|
PolicyManagementDAOFactory.rollbackTransaction();
|
||||||
|
} catch (PolicyManagerDAOException e1) {
|
||||||
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
|
}
|
||||||
|
String msg = "Error occurred while deleting the profile for policy ("
|
||||||
|
+ policyId + ")";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PolicyManagementException(msg, e);
|
||||||
|
} catch (FeatureManagerDAOException e) {
|
||||||
|
try {
|
||||||
|
PolicyManagementDAOFactory.rollbackTransaction();
|
||||||
|
} catch (PolicyManagerDAOException e1) {
|
||||||
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
|
}
|
||||||
|
String msg = "Error occurred while deleting the profile features for policy ("
|
||||||
|
+ policyId + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
return bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy) throws
|
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy)
|
||||||
PolicyManagementException {
|
throws PolicyManagementException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.beginTransaction();
|
PolicyManagementDAOFactory.beginTransaction();
|
||||||
@ -319,7 +370,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the policy ("
|
String msg = "Error occurred while adding the policy ("
|
||||||
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
@ -366,7 +417,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the policy ("
|
String msg = "Error occurred while adding the policy ("
|
||||||
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
+ policy.getId() + " - " + policy.getPolicyName() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
@ -404,7 +455,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the policy ("
|
String msg = "Error occurred while adding the policy ("
|
||||||
+ policy.getId() + " - " + policy.getPolicyName() + ") to user list.";
|
+ policy.getId() + " - " + policy.getPolicyName() + ") to user list.";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
@ -538,12 +589,12 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
Collections.sort(policies);
|
Collections.sort(policies);
|
||||||
} catch (PolicyManagerDAOException e) {
|
} catch (PolicyManagerDAOException e) {
|
||||||
String msg = "Error occurred while getting the policies for device identifier (" +
|
String msg = "Error occurred while getting the policies for device identifier (" +
|
||||||
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while getting device related to device identifier (" +
|
String msg = "Error occurred while getting device related to device identifier (" +
|
||||||
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
}
|
}
|
||||||
@ -658,8 +709,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId,
|
public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId,
|
||||||
List<ProfileFeature> profileFeatures) throws
|
List<ProfileFeature> profileFeatures) throws PolicyManagementException {
|
||||||
PolicyManagementException {
|
|
||||||
|
|
||||||
int deviceId = -1;
|
int deviceId = -1;
|
||||||
try {
|
try {
|
||||||
@ -681,7 +731,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the evaluated policy to device (" +
|
String msg = "Error occurred while adding the evaluated policy to device (" +
|
||||||
deviceId + " - " + policyId + ")";
|
deviceId + " - " + policyId + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
@ -693,8 +743,8 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy) throws
|
public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy)
|
||||||
PolicyManagementException {
|
throws PolicyManagementException {
|
||||||
|
|
||||||
int deviceId = -1;
|
int deviceId = -1;
|
||||||
try {
|
try {
|
||||||
@ -721,7 +771,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
log.warn("Error occurred while roll backing the transaction.");
|
log.warn("Error occurred while roll backing the transaction.");
|
||||||
}
|
}
|
||||||
String msg = "Error occurred while adding the evaluated policy to device (" +
|
String msg = "Error occurred while adding the evaluated policy to device (" +
|
||||||
deviceId + " - " + policy.getId() + ")";
|
deviceId + " - " + policy.getId() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
@ -766,7 +816,7 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
return true;
|
return true;
|
||||||
} catch (PolicyManagerDAOException e) {
|
} catch (PolicyManagerDAOException e) {
|
||||||
String msg = "Error occurred while setting the policy has applied to device (" +
|
String msg = "Error occurred while setting the policy has applied to device (" +
|
||||||
deviceIdentifier.getId() + ")";
|
deviceIdentifier.getId() + ")";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new PolicyManagementException(msg, e);
|
throw new PolicyManagementException(msg, e);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
|
|||||||
@ -133,8 +133,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = ("addProfileFeatures"))
|
@Test(dependsOnMethods = ("addProfileFeatures"))
|
||||||
public void addPolicy() throws PolicyManagementException {
|
public void addPolicy() throws PolicyManagementException, ProfileManagementException {
|
||||||
|
ProfileManager profileManager = new ProfileManagerImpl();
|
||||||
|
profile = ProfileCreator.getProfile(featureList);
|
||||||
|
profileManager.addProfile(profile);
|
||||||
PolicyManager policyManager = new PolicyManagerImpl();
|
PolicyManager policyManager = new PolicyManagerImpl();
|
||||||
policy = PolicyCreator.createPolicy(profile);
|
policy = PolicyCreator.createPolicy(profile);
|
||||||
policyManager.addPolicy(policy);
|
policyManager.addPolicy(policy);
|
||||||
@ -169,8 +171,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = ("addPolicyToDevice"))
|
@Test(dependsOnMethods = ("addPolicyToDevice"))
|
||||||
public void addNewPolicy() throws PolicyManagementException {
|
public void addNewPolicy() throws PolicyManagementException, ProfileManagementException {
|
||||||
|
ProfileManager profileManager = new ProfileManagerImpl();
|
||||||
|
profile = ProfileCreator.getProfile(featureList);
|
||||||
|
profileManager.addProfile(profile);
|
||||||
PolicyManager policyManager = new PolicyManagerImpl();
|
PolicyManager policyManager = new PolicyManagerImpl();
|
||||||
policy = PolicyCreator.createPolicy2(profile);
|
policy = PolicyCreator.createPolicy2(profile);
|
||||||
policyManager.addPolicy(policy);
|
policyManager.addPolicy(policy);
|
||||||
@ -178,8 +182,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = ("addPolicyToDevice"))
|
@Test(dependsOnMethods = ("addPolicyToDevice"))
|
||||||
public void addThirdPolicy() throws PolicyManagementException {
|
public void addThirdPolicy() throws PolicyManagementException, ProfileManagementException {
|
||||||
|
ProfileManager profileManager = new ProfileManagerImpl();
|
||||||
|
profile = ProfileCreator.getProfile(featureList);
|
||||||
|
profileManager.addProfile(profile);
|
||||||
PolicyManager policyManager = new PolicyManagerImpl();
|
PolicyManager policyManager = new PolicyManagerImpl();
|
||||||
policy = PolicyCreator.createPolicy4(profile);
|
policy = PolicyCreator.createPolicy4(profile);
|
||||||
policyManager.addPolicy(policy);
|
policyManager.addPolicy(policy);
|
||||||
@ -273,7 +279,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = ("getRoleRelatedPolicy"))
|
@Test(dependsOnMethods = ("getRoleRelatedPolicy"))
|
||||||
public void addSecondPolicy() throws PolicyManagementException {
|
public void addSecondPolicy() throws PolicyManagementException, ProfileManagementException {
|
||||||
|
ProfileManager profileManager = new ProfileManagerImpl();
|
||||||
|
profile = ProfileCreator.getProfile(featureList);
|
||||||
|
profileManager.addProfile(profile);
|
||||||
PolicyManager policyManager = new PolicyManagerImpl();
|
PolicyManager policyManager = new PolicyManagerImpl();
|
||||||
policy = PolicyCreator.createPolicy3(profile);
|
policy = PolicyCreator.createPolicy3(profile);
|
||||||
policyManager.addPolicy(policy);
|
policyManager.addPolicy(policy);
|
||||||
|
|||||||
@ -64,11 +64,11 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.wso2</groupId>
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
<artifactId>tomcat</artifactId>
|
<artifactId>tomcat</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.wso2</groupId>
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
<artifactId>tomcat-servlet-api</artifactId>
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
8
pom.xml
8
pom.xml
@ -748,7 +748,7 @@
|
|||||||
|
|
||||||
<!-- Tomcat dependencies -->
|
<!-- Tomcat dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.wso2</groupId>
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
<artifactId>tomcat</artifactId>
|
<artifactId>tomcat</artifactId>
|
||||||
<version>${orbit.version.tomcat}</version>
|
<version>${orbit.version.tomcat}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
@ -815,7 +815,7 @@
|
|||||||
<version>${tomcat.jdbc.pooling.version}</version>
|
<version>${tomcat.jdbc.pooling.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat.wso2</groupId>
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
<artifactId>tomcat-servlet-api</artifactId>
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
<version>${orbit.version.tomcat.servlet.api}</version>
|
<version>${orbit.version.tomcat.servlet.api}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -1137,8 +1137,8 @@
|
|||||||
<orbit.version.h2.engine>1.2.140.wso2v3</orbit.version.h2.engine>
|
<orbit.version.h2.engine>1.2.140.wso2v3</orbit.version.h2.engine>
|
||||||
|
|
||||||
<!-- Tomcat -->
|
<!-- Tomcat -->
|
||||||
<orbit.version.tomcat>7.0.52.wso2v5</orbit.version.tomcat>
|
<orbit.version.tomcat>7.0.59.wso2v1</orbit.version.tomcat>
|
||||||
<orbit.version.tomcat.servlet.api>7.0.52.wso2v1</orbit.version.tomcat.servlet.api>
|
<orbit.version.tomcat.servlet.api>7.0.59.wso2v1</orbit.version.tomcat.servlet.api>
|
||||||
<tomcat.jdbc.pooling.version>7.0.34.wso2v2</tomcat.jdbc.pooling.version>
|
<tomcat.jdbc.pooling.version>7.0.34.wso2v2</tomcat.jdbc.pooling.version>
|
||||||
|
|
||||||
<!-- Carbon Deployment -->
|
<!-- Carbon Deployment -->
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user