diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 71fea6c747..9d5069b8a9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -83,8 +83,7 @@ org.wso2.carbon.identity.oauth.stub, org.wso2.carbon.identity.oauth.stub.dto, org.wso2.carbon.ndatasource.core, - org.wso2.carbon.base, - org.wso2.carbon.base.api + org.apache.catalina !org.wso2.carbon.device.mgt.core.internal, @@ -209,6 +208,10 @@ org.wso2.carbon.identity org.wso2.carbon.identity.oauth.stub + + org.wso2.tomcat + tomcat + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index 577cd3bbff..e4f648035a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -180,10 +180,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem @Override public void updateApplicationListInstalledInDevice( DeviceIdentifier deviceIdentifier, List applications) throws ApplicationManagementException { - - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceManagementDAOFactory.beginTransaction(); Device device = deviceDAO.getDevice(deviceIdentifier, tenantId); @@ -199,8 +197,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem List appsToAdd = new ArrayList(); List appIdsToRemove = new ArrayList(); - for(Application installedApp:installedAppList){ - if (!applications.contains(installedApp)){ + for (Application installedApp : installedAppList) { + if (!applications.contains(installedApp)) { if (log.isDebugEnabled()) { log.debug("Remove app Id:" + installedApp.getId()); } @@ -211,12 +209,12 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem Application installedApp; List applicationIds = new ArrayList<>(); - for(Application application:applications){ + for (Application application : applications) { if (!installedAppList.contains(application)) { installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), tenantId); - if (installedApp == null){ + if (installedApp == null) { appsToAdd.add(application); - }else{ + } else { applicationIds.add(installedApp.getId()); } } @@ -234,7 +232,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem if (log.isDebugEnabled()) { log.debug("num of remove app Ids:" + appIdsToRemove.size()); } - applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove,tenantId); + applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId); DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException deviceDaoEx) { String errorMsg = "Error occurred saving application list to the device"; @@ -242,37 +240,26 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem try { DeviceManagementDAOFactory.rollbackTransaction(); } 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); } } -// private int getTenantId() { -// -// int tenantId = 0; -//// if (isTest){ -//// tenantId = DeviceManagerUtil.currentTenant.get(); -//// }else{ -// tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); -//// } -// -// return tenantId; -// } + @Override - public List getApplicationListForDevice(DeviceIdentifier deviceIdentifier) - throws ApplicationManagementException { - Device device = null; - try { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - device = deviceDAO.getDevice(deviceIdentifier, tenantId); - return applicationDAO.getInstalledApplications(device.getId()); - }catch (DeviceManagementDAOException deviceDaoEx) { - String errorMsg = "Error occured while fetching the Application List of device : " + device.getId(); - log.error(errorMsg, deviceDaoEx); - throw new ApplicationManagementException(errorMsg, deviceDaoEx); - } + public List getApplicationListForDevice( + DeviceIdentifier deviceId) throws ApplicationManagementException { + Device device = null; + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + device = deviceDAO.getDevice(deviceId, tenantId); + return applicationDAO.getInstalledApplications(device.getId()); + } catch (DeviceManagementDAOException e) { + throw new ApplicationManagementException("Error occured while fetching the Application List of '" + + deviceId.getType() + "' device carrying the identifier'" + deviceId.getId(), e); + } } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 56e46fdca9..4973f8ef47 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -54,7 +54,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private DeviceTypeDAO deviceTypeDAO; private EnrolmentDAO enrolmentDAO; private DeviceManagementPluginRepository pluginRepository; - private boolean isTest = false; private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); private int tenantId; @@ -76,7 +75,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementProviderServiceImpl(DeviceManagementPluginRepository pluginRepo, boolean test){ this.pluginRepository = pluginRepo; initDataAccessObjects(); - isTest = test; } private void initDataAccessObjects() { @@ -749,14 +747,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.getConnection(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); allDevices = deviceDAO.getDevicesByStatus(status, tenantId); - } catch (DeviceManagementDAOException e) { - String errorMsg = "Error occurred while fetching the list of devices that matches to status: '" - + status + "'"; - log.error(errorMsg, e); - throw new DeviceManagementException(errorMsg, e); + throw new DeviceManagementException( + "Error occurred while fetching the list of devices that matches to status: '" + status + "'", e); } finally { - try { DeviceManagementDAOFactory.closeConnection(); } catch (DeviceManagementDAOException e) { @@ -779,18 +773,4 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } - -// private int getTenantId() { -// -//// ThreadLocal tenantId = new ThreadLocal(); -// int tenant = 0; -// -//// if (isTest){ -//// tenant = DeviceManagerUtil.currentTenant.get(); -//// }else{ -// tenant = CarbonContext.getThreadLocalCarbonContext().getTenantId(); -//// } -// return tenant; -// } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/startup/handler/URLPrinterStartupHandler.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/startup/handler/URLPrinterStartupHandler.java index 17a5b0dc17..83250c0d22 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/startup/handler/URLPrinterStartupHandler.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/startup/handler/URLPrinterStartupHandler.java @@ -51,11 +51,14 @@ public class URLPrinterStartupHandler implements ServerStartupObserver { String mgtConsoleTransport = CarbonUtils.getManagementTransport(); ConfigurationContextService configContextService = DeviceManagementDataHolder.getInstance().getConfigurationContextService(); - int httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); + int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); int httpsProxyPort = CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); - return "https://" + hostName + ":" + httpsPort + "/mdm"; + if (httpsProxyPort > 0) { + port = httpsProxyPort; + } + return "https://" + hostName + ":" + port + "/mdm"; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 8fc16db4ec..dc895d8581 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -49,7 +49,6 @@ import java.util.*; public final class DeviceManagerUtil { private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); - public static ThreadLocal currentTenant = new ThreadLocal(); enum HTTPMethod { GET, POST, DELETE, PUT, OPTIONS diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java index 8322684d07..e79930ee04 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceTest.java @@ -58,7 +58,6 @@ public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTes deviceManagementProviderService = new DeviceManagementProviderServiceImpl(deviceManagementPluginRepository, true); DeviceManagerUtil.registerDeviceType(TestDataHolder.TEST_DEVICE_TYPE); - DeviceManagerUtil.currentTenant.set(TestDataHolder.SUPER_TENANT_ID); Device device = TestDataHolder.generateDummyDeviceData(TestDataHolder.TEST_DEVICE_TYPE); boolean isEnrolled = deviceManagementProviderService.enrollDevice(device); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml index cf107283b8..1eee2b18eb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -24,17 +24,17 @@ - - - - - + + + + + - - + + \ No newline at end of file diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java index 1c08a18789..19c9c13715 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java @@ -53,4 +53,6 @@ public interface FeatureDAO { boolean deleteFeaturesOfProfile(Profile profile) throws FeatureManagerDAOException; + boolean deleteFeaturesOfProfile(int profileId) throws FeatureManagerDAOException; + } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java index 811a52d1ac..174ca08c48 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java @@ -32,6 +32,8 @@ public interface ProfileDAO { boolean deleteProfile(Profile profile) throws ProfileManagerDAOException; + boolean deleteProfile(int policyId) throws ProfileManagerDAOException; + Profile getProfiles(int profileId) throws ProfileManagerDAOException; List getAllProfiles() throws ProfileManagerDAOException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/FeatureDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/FeatureDAOImpl.java index e6e5b93abe..f5933350cf 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/FeatureDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/FeatureDAOImpl.java @@ -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 public List getAllProfileFeatures() throws FeatureManagerDAOException { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java index 09c87cfa8e..eccb9eedc3 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java @@ -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 public Profile getProfiles(int profileId) throws ProfileManagerDAOException { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 40b06329e5..be174530e7 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -126,7 +126,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } String msg = "Error occurred while adding the policy (" + - policy.getId() + " - " + policy.getPolicyName() + ")"; + policy.getId() + " - " + policy.getPolicyName() + ")"; log.error(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."); } String msg = "Error occurred while adding the profile related to policy (" + - policy.getId() + " - " + policy.getPolicyName() + ")"; + policy.getId() + " - " + policy.getPolicyName() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } catch (FeatureManagerDAOException e) { @@ -147,7 +147,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } 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); throw new PolicyManagementException(msg, e); } @@ -210,7 +210,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } String msg = "Error occurred while updating the policy (" - + policy.getId() + " - " + policy.getPolicyName() + ")"; + + policy.getId() + " - " + policy.getPolicyName() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } @@ -240,12 +240,14 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean deletePolicy(Policy policy) throws PolicyManagementException { - boolean bool; try { PolicyManagementDAOFactory.beginTransaction(); - bool = policyDAO.deletePolicy(policy); + policyDAO.deleteAllPolicyRelatedConfigs(policy.getId()); + policyDAO.deletePolicy(policy.getId()); + featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); + profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); - + return true; } catch (PolicyManagerDAOException e) { try { PolicyManagementDAOFactory.rollbackTransaction(); @@ -253,21 +255,51 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } 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); throw new PolicyManagementException(msg, e); } - return bool; + } @Override public boolean deletePolicy(int policyId) throws PolicyManagementException { - boolean bool; + try { PolicyManagementDAOFactory.beginTransaction(); + Policy policy = policyDAO.getPolicy(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(); + return true; } catch (PolicyManagerDAOException e) { try { @@ -276,16 +308,35 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } 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); throw new PolicyManagementException(msg, e); } - return bool; } @Override - public Policy addPolicyToDevice(List deviceIdentifierList, Policy policy) throws - PolicyManagementException { + public Policy addPolicyToDevice(List deviceIdentifierList, Policy policy) + throws PolicyManagementException { try { PolicyManagementDAOFactory.beginTransaction(); @@ -319,7 +370,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } String msg = "Error occurred while adding the policy (" - + policy.getId() + " - " + policy.getPolicyName() + ")"; + + policy.getId() + " - " + policy.getPolicyName() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } catch (DeviceManagementException e) { @@ -366,7 +417,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } String msg = "Error occurred while adding the policy (" - + policy.getId() + " - " + policy.getPolicyName() + ")"; + + policy.getId() + " - " + policy.getPolicyName() + ")"; log.error(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."); } 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); throw new PolicyManagementException(msg, e); } @@ -538,12 +589,12 @@ public class PolicyManagerImpl implements PolicyManager { Collections.sort(policies); } catch (PolicyManagerDAOException e) { String msg = "Error occurred while getting the policies for device identifier (" + - deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")"; + deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } catch (DeviceManagementException e) { String msg = "Error occurred while getting device related to device identifier (" + - deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")"; + deviceIdentifier.getId() + " - " + deviceIdentifier.getType() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } @@ -658,8 +709,7 @@ public class PolicyManagerImpl implements PolicyManager { @Override public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId, - List profileFeatures) throws - PolicyManagementException { + List profileFeatures) throws PolicyManagementException { int deviceId = -1; try { @@ -681,7 +731,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } String msg = "Error occurred while adding the evaluated policy to device (" + - deviceId + " - " + policyId + ")"; + deviceId + " - " + policyId + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } catch (DeviceManagementException e) { @@ -693,8 +743,8 @@ public class PolicyManagerImpl implements PolicyManager { } @Override - public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy) throws - PolicyManagementException { + public void addAppliedPolicyToDevice(DeviceIdentifier deviceIdentifier, Policy policy) + throws PolicyManagementException { int deviceId = -1; try { @@ -721,7 +771,7 @@ public class PolicyManagerImpl implements PolicyManager { log.warn("Error occurred while roll backing the transaction."); } String msg = "Error occurred while adding the evaluated policy to device (" + - deviceId + " - " + policy.getId() + ")"; + deviceId + " - " + policy.getId() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } catch (DeviceManagementException e) { @@ -766,7 +816,7 @@ public class PolicyManagerImpl implements PolicyManager { return true; } catch (PolicyManagerDAOException e) { String msg = "Error occurred while setting the policy has applied to device (" + - deviceIdentifier.getId() + ")"; + deviceIdentifier.getId() + ")"; log.error(msg, e); throw new PolicyManagementException(msg, e); } catch (DeviceManagementException e) { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java index e3b0393e95..ba59d282c6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java @@ -133,8 +133,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { } @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(); policy = PolicyCreator.createPolicy(profile); policyManager.addPolicy(policy); @@ -169,8 +171,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { } @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(); policy = PolicyCreator.createPolicy2(profile); policyManager.addPolicy(policy); @@ -178,8 +182,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { @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(); policy = PolicyCreator.createPolicy4(profile); policyManager.addPolicy(policy); @@ -273,7 +279,10 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { } @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(); policy = PolicyCreator.createPolicy3(profile); policyManager.addPolicy(policy); diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index bc2360aa32..ebf27bf99f 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -64,11 +64,11 @@ - org.apache.tomcat.wso2 + org.wso2.tomcat tomcat - org.apache.tomcat.wso2 + org.wso2.tomcat tomcat-servlet-api diff --git a/pom.xml b/pom.xml index 0f56e6a870..ab536762c7 100644 --- a/pom.xml +++ b/pom.xml @@ -748,7 +748,7 @@ - org.apache.tomcat.wso2 + org.wso2.tomcat tomcat ${orbit.version.tomcat} @@ -815,7 +815,7 @@ ${tomcat.jdbc.pooling.version} - org.apache.tomcat.wso2 + org.wso2.tomcat tomcat-servlet-api ${orbit.version.tomcat.servlet.api} @@ -1137,8 +1137,8 @@ 1.2.140.wso2v3 - 7.0.52.wso2v5 - 7.0.52.wso2v1 + 7.0.59.wso2v1 + 7.0.59.wso2v1 7.0.34.wso2v2