Conflicts:
	components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java
revert-70aa11f8
harshanL 10 years ago
commit 1d94f81ec6

@ -17,12 +17,6 @@ package org.wso2.carbon.device.mgt.common;
public final class DeviceManagementConstants { public final class DeviceManagementConstants {
/*DEVICE Manager operations*/
public static final String ADD_DEVICE_ENTRY = "Add device entry";
public static final String STANDARD_TRANSACTION_MANAGER_JNDI_NAME = "java:comp/TransactionManager";
public static final String STANDARD_USER_TRANSACTION_JNDI_NAME = "java:comp/UserTransaction";
/*Data Source Configurations */
public static final class DataSourceProperties { public static final class DataSourceProperties {
private DataSourceProperties() { private DataSourceProperties() {
throw new AssertionError(); throw new AssertionError();

@ -1,5 +1,5 @@
/** /**
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import java.util.List; import java.util.List;
@ -52,7 +53,8 @@ public class DeviceManager implements DeviceManagerService {
this.getPluginRepository().getDeviceManagementProvider(device.getType()); this.getPluginRepository().getDeviceManagementProvider(device.getType());
boolean status = dms.enrollDevice(device); boolean status = dms.enrollDevice(device);
try { try {
this.getDeviceDAO().addDevice(device); this.getDeviceTypeDAO().getDeviceType();
this.getDeviceDAO().addDevice(DeviceManagementDAOUtil.convertDevice(device));
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while enrolling the device '" + throw new DeviceManagementException("Error occurred while enrolling the device '" +
device.getId() + "'", e); device.getId() + "'", e);
@ -66,7 +68,7 @@ public class DeviceManager implements DeviceManagerService {
this.getPluginRepository().getDeviceManagementProvider(device.getType()); this.getPluginRepository().getDeviceManagementProvider(device.getType());
boolean status = dms.modifyEnrollment(device); boolean status = dms.modifyEnrollment(device);
try { try {
this.getDeviceDAO().updateDevice(device); this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while modifying the device '" + throw new DeviceManagementException("Error occurred while modifying the device '" +
device.getId() + "'", e); device.getId() + "'", e);

@ -15,7 +15,7 @@
package org.wso2.carbon.device.mgt.core.dao; package org.wso2.carbon.device.mgt.core.dao;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.device.mgt.core.dto.Status; import org.wso2.carbon.device.mgt.core.dto.Status;
import java.util.List; import java.util.List;

@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.core.dao; package org.wso2.carbon.device.mgt.core.dao;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import java.util.List; import java.util.List;
@ -33,4 +34,6 @@ public interface DeviceTypeDAO {
List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException; List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException;
DeviceIdentifier getDeviceType() throws DeviceManagementDAOException;
} }

@ -38,6 +38,7 @@ public class DeviceDAOImpl implements DeviceDAO {
private DataSource dataSource; private DataSource dataSource;
private static final Log log = LogFactory.getLog(DeviceDAOImpl.class); private static final Log log = LogFactory.getLog(DeviceDAOImpl.class);
public DeviceDAOImpl(DataSource dataSource) { public DeviceDAOImpl(DataSource dataSource) {
this.dataSource = dataSource; this.dataSource = dataSource;
} }
@ -60,13 +61,13 @@ public class DeviceDAOImpl implements DeviceDAO {
stmt.setLong(4, new Date().getTime()); stmt.setLong(4, new Date().getTime());
stmt.setString(5, device.getOwnerShip()); stmt.setString(5, device.getOwnerShip());
stmt.setString(6, device.getStatus().toString()); stmt.setString(6, device.getStatus().toString());
stmt.setLong(7, device.getDeviceType().getId()); stmt.setString(7, device.getDeviceType());
stmt.setLong(8, device.getDeviceIdentificationId()); stmt.setString(8, device.getDeviceIdentificationId());
stmt.setString(9, device.getOwnerId()); stmt.setString(9, device.getOwnerId());
stmt.setInt(10, DeviceManagementDAOUtil.getTenantId()); stmt.setInt(10, DeviceManagementDAOUtil.getTenantId());
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Failed to enroll device '" + device.getName() + "'"; String msg = "Error occurred while enrolling device '" + device.getName() + "'";
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementDAOException(msg, e); throw new DeviceManagementDAOException(msg, e);
} finally { } finally {

@ -15,6 +15,7 @@
*/ */
package org.wso2.carbon.device.mgt.core.dao.impl; package org.wso2.carbon.device.mgt.core.dao.impl;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
@ -60,6 +61,11 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
return null; return null;
} }
@Override
public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException {
return new DeviceIdentifier();
}
private Connection getConnection() throws DeviceManagementDAOException { private Connection getConnection() throws DeviceManagementDAOException {
try { try {
return dataSource.getConnection(); return dataSource.getConnection();

@ -19,6 +19,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.dto.Status;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.user.core.tenant.TenantManager;
@ -99,4 +102,19 @@ public final class DeviceManagementDAOUtil {
} }
} }
public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device
device) throws DeviceManagementDAOException {
Device deviceBO = new Device();
deviceBO.setDescription(device.getDescription());
deviceBO.setName(device.getName());
deviceBO.setDateOfEnrolment(device.getDateOfEnrolment());
deviceBO.setDateOfLastUpdate(device.getDateOfLastUpdate());
deviceBO.setStatus(Status.valueOf(String.valueOf(device.isStatus())));
deviceBO.setOwnerId(device.getOwner());
deviceBO.setOwnerShip(device.getOwnership());
deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId());
deviceBO.setDeviceType(device.getType());
return deviceBO;
}
} }

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.core.dto; package org.wso2.carbon.device.mgt.core.dto;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
public class Device implements Serializable { public class Device implements Serializable {
@ -26,20 +27,20 @@ public class Device implements Serializable {
private String id; private String id;
private String description; private String description;
private String name; private String name;
private Long dateOfEnrolment; private Date dateOfEnrolment;
private Long dateOfLastUpdate; private Date dateOfLastUpdate;
private Long deviceIdentificationId; private String deviceIdentificationId;
private Status status; private Status status;
private String ownerId; private String ownerId;
private String ownerShip; private String ownerShip;
private Long tenantId; private int tenantId;
private DeviceType deviceType; private String deviceType;
public DeviceType getDeviceType() { public String getDeviceType() {
return deviceType; return deviceType;
} }
public void setDeviceType(DeviceType deviceType) { public void setDeviceType(String deviceType) {
this.deviceType = deviceType; this.deviceType = deviceType;
} }
@ -67,27 +68,27 @@ public class Device implements Serializable {
this.name = name; this.name = name;
} }
public Long getDateOfEnrolment() { public Date getDateOfEnrolment() {
return dateOfEnrolment; return dateOfEnrolment;
} }
public void setDateOfEnrolment(Long dateOfEnrolment) { public void setDateOfEnrolment(Date dateOfEnrolment) {
this.dateOfEnrolment = dateOfEnrolment; this.dateOfEnrolment = dateOfEnrolment;
} }
public Long getDateOfLastUpdate() { public Date getDateOfLastUpdate() {
return dateOfLastUpdate; return dateOfLastUpdate;
} }
public void setDateOfLastUpdate(Long dateOfLastUpdate) { public void setDateOfLastUpdate(Date dateOfLastUpdate) {
this.dateOfLastUpdate = dateOfLastUpdate; this.dateOfLastUpdate = dateOfLastUpdate;
} }
public Long getDeviceIdentificationId() { public String getDeviceIdentificationId() {
return deviceIdentificationId; return deviceIdentificationId;
} }
public void setDeviceIdentificationId(Long deviceIdentificationId) { public void setDeviceIdentificationId(String deviceIdentificationId) {
this.deviceIdentificationId = deviceIdentificationId; this.deviceIdentificationId = deviceIdentificationId;
} }
@ -115,11 +116,11 @@ public class Device implements Serializable {
this.ownerId = ownerId; this.ownerId = ownerId;
} }
public Long getTenantId() { public int getTenantId() {
return tenantId; return tenantId;
} }
public void setTenantId(Long tenantId) { public void setTenantId(int tenantId) {
this.tenantId = tenantId; this.tenantId = tenantId;
} }
} }

@ -31,7 +31,7 @@ public interface PolicyManagerService {
/** /**
* This method adds a policy to the platform * This method adds a policy to the platform
* @param policy * @param policy
* @return * @return primary key (generated key)
*/ */
int addPolicy(Policy policy); int addPolicy(Policy policy);
@ -41,7 +41,7 @@ public interface PolicyManagerService {
* @param deviceId * @param deviceId
* @param deviceType * @param deviceType
* @param policy * @param policy
* @return * @return primary key (generated key)
*/ */
int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToDevice(String deviceId, String deviceType, Policy policy) throws FeatureManagementException, PolicyManagementException;
@ -50,7 +50,7 @@ public interface PolicyManagerService {
* This method adds a policy to device type by the related device type plugins. * This method adds a policy to device type by the related device type plugins.
* @param deviceType * @param deviceType
* @param policy * @param policy
* @return * @return primary key (generated key)
*/ */
int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException;
@ -59,7 +59,7 @@ public interface PolicyManagerService {
* This method adds the policy to specific role. * This method adds the policy to specific role.
* @param roleName * @param roleName
* @param policy * @param policy
* @return * @return primary key (generated key)
*/ */
int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException; int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException;

Loading…
Cancel
Save