Fixing the merge conflicts

revert-70aa11f8
geethkokila 9 years ago
commit bd75f70a24

@ -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
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.core.internal,
@ -209,6 +208,10 @@
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId>
</dependency>
</dependencies>
</project>

@ -180,10 +180,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
@Override
public void updateApplicationListInstalledInDevice(
DeviceIdentifier deviceIdentifier, List<Application> 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<Application> appsToAdd = new ArrayList<Application>();
List<Integer> appIdsToRemove = new ArrayList<Integer>();
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<Integer> 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,36 +240,25 @@ 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<Application> getApplicationListForDevice(DeviceIdentifier deviceIdentifier)
throws ApplicationManagementException {
public List<Application> getApplicationListForDevice(
DeviceIdentifier deviceId) throws ApplicationManagementException {
Device device = null;
try {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
device = deviceDAO.getDevice(deviceIdentifier, tenantId);
device = deviceDAO.getDevice(deviceId, 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);
} catch (DeviceManagementDAOException e) {
throw new ApplicationManagementException("Error occured while fetching the Application List of '" +
deviceId.getType() + "' device carrying the identifier'" + deviceId.getId(), e);
}
}

@ -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<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();
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";
}
}

@ -49,7 +49,6 @@ import java.util.*;
public final class DeviceManagerUtil {
private static final Log log = LogFactory.getLog(DeviceManagerUtil.class);
public static ThreadLocal<Integer> currentTenant = new ThreadLocal<Integer>();
enum HTTPMethod {
GET, POST, DELETE, PUT, OPTIONS

@ -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);

@ -24,17 +24,17 @@
<test name="DAO Unit Tests" preserve-order="true">
<classes>
<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.DeviceManagementRepositoryTests"/>
<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.common.BaseDeviceManagementTest"/>-->
<!--<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.DeviceManagementConfigTests"/>-->
<!--<class name="org.wso2.carbon.device.mgt.core.dao.ApplicationPersistenceTests"/>-->
</classes>
</test>
<test name="Service Unit Tests" preserve-order="true">
<classes>
<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.service.DeviceManagementProviderServiceTest"/>-->
<!--<class name="org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderServiceTest"/>-->
</classes>
</test>
</suite>

@ -53,4 +53,6 @@ public interface FeatureDAO {
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(int policyId) throws ProfileManagerDAOException;
Profile getProfiles(int profileId) 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
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
public Profile getProfiles(int profileId) throws ProfileManagerDAOException {

@ -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();
@ -256,18 +258,48 @@ public class PolicyManagerImpl implements PolicyManager {
+ 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.");
}
return bool;
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);
}
}
@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 {
@ -279,13 +311,32 @@ public class PolicyManagerImpl implements PolicyManager {
+ 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<DeviceIdentifier> deviceIdentifierList, Policy policy) throws
PolicyManagementException {
public Policy addPolicyToDevice(List<DeviceIdentifier> deviceIdentifierList, Policy policy)
throws PolicyManagementException {
try {
PolicyManagementDAOFactory.beginTransaction();
@ -658,8 +709,7 @@ public class PolicyManagerImpl implements PolicyManager {
@Override
public void addAppliedPolicyFeaturesToDevice(DeviceIdentifier deviceIdentifier, int policyId,
List<ProfileFeature> profileFeatures) throws
PolicyManagementException {
List<ProfileFeature> profileFeatures) throws PolicyManagementException {
int deviceId = -1;
try {
@ -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 {

@ -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);

@ -64,11 +64,11 @@
<dependencies>
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
</dependency>
<dependency>

@ -748,7 +748,7 @@
<!-- Tomcat dependencies -->
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>${orbit.version.tomcat}</version>
<exclusions>
@ -815,7 +815,7 @@
<version>${tomcat.jdbc.pooling.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<groupId>org.wso2.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>${orbit.version.tomcat.servlet.api}</version>
</dependency>
@ -1137,8 +1137,8 @@
<orbit.version.h2.engine>1.2.140.wso2v3</orbit.version.h2.engine>
<!-- Tomcat -->
<orbit.version.tomcat>7.0.52.wso2v5</orbit.version.tomcat>
<orbit.version.tomcat.servlet.api>7.0.52.wso2v1</orbit.version.tomcat.servlet.api>
<orbit.version.tomcat>7.0.59.wso2v1</orbit.version.tomcat>
<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>
<!-- Carbon Deployment -->

Loading…
Cancel
Save