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 {
/*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 {
private DataSourceProperties() {
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");
* 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.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import java.util.List;
@ -52,7 +53,8 @@ public class DeviceManager implements DeviceManagerService {
this.getPluginRepository().getDeviceManagementProvider(device.getType());
boolean status = dms.enrollDevice(device);
try {
this.getDeviceDAO().addDevice(device);
this.getDeviceTypeDAO().getDeviceType();
this.getDeviceDAO().addDevice(DeviceManagementDAOUtil.convertDevice(device));
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while enrolling the device '" +
device.getId() + "'", e);
@ -66,7 +68,7 @@ public class DeviceManager implements DeviceManagerService {
this.getPluginRepository().getDeviceManagementProvider(device.getType());
boolean status = dms.modifyEnrollment(device);
try {
this.getDeviceDAO().updateDevice(device);
this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while modifying the device '" +
device.getId() + "'", e);

@ -15,7 +15,7 @@
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 java.util.List;

@ -18,6 +18,7 @@
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 java.util.List;
@ -33,4 +34,6 @@ public interface DeviceTypeDAO {
List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException;
DeviceIdentifier getDeviceType() throws DeviceManagementDAOException;
}

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

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

@ -19,6 +19,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
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.user.api.UserStoreException;
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;
import java.io.Serializable;
import java.util.Date;
public class Device implements Serializable {
@ -26,20 +27,20 @@ public class Device implements Serializable {
private String id;
private String description;
private String name;
private Long dateOfEnrolment;
private Long dateOfLastUpdate;
private Long deviceIdentificationId;
private Date dateOfEnrolment;
private Date dateOfLastUpdate;
private String deviceIdentificationId;
private Status status;
private String ownerId;
private String ownerShip;
private Long tenantId;
private DeviceType deviceType;
private int tenantId;
private String deviceType;
public DeviceType getDeviceType() {
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(DeviceType deviceType) {
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
@ -67,27 +68,27 @@ public class Device implements Serializable {
this.name = name;
}
public Long getDateOfEnrolment() {
public Date getDateOfEnrolment() {
return dateOfEnrolment;
}
public void setDateOfEnrolment(Long dateOfEnrolment) {
public void setDateOfEnrolment(Date dateOfEnrolment) {
this.dateOfEnrolment = dateOfEnrolment;
}
public Long getDateOfLastUpdate() {
public Date getDateOfLastUpdate() {
return dateOfLastUpdate;
}
public void setDateOfLastUpdate(Long dateOfLastUpdate) {
public void setDateOfLastUpdate(Date dateOfLastUpdate) {
this.dateOfLastUpdate = dateOfLastUpdate;
}
public Long getDeviceIdentificationId() {
public String getDeviceIdentificationId() {
return deviceIdentificationId;
}
public void setDeviceIdentificationId(Long deviceIdentificationId) {
public void setDeviceIdentificationId(String deviceIdentificationId) {
this.deviceIdentificationId = deviceIdentificationId;
}
@ -115,11 +116,11 @@ public class Device implements Serializable {
this.ownerId = ownerId;
}
public Long getTenantId() {
public int getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
}

@ -31,7 +31,7 @@ public interface PolicyManagerService {
/**
* This method adds a policy to the platform
* @param policy
* @return
* @return primary key (generated key)
*/
int addPolicy(Policy policy);
@ -41,7 +41,7 @@ public interface PolicyManagerService {
* @param deviceId
* @param deviceType
* @param policy
* @return
* @return primary key (generated key)
*/
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.
* @param deviceType
* @param policy
* @return
* @return primary key (generated key)
*/
int addPolicyToDeviceType(String deviceType,Policy policy) throws FeatureManagementException, PolicyManagementException;
@ -59,7 +59,7 @@ public interface PolicyManagerService {
* This method adds the policy to specific role.
* @param roleName
* @param policy
* @return
* @return primary key (generated key)
*/
int addPolicyToRole(String roleName, Policy policy) throws FeatureManagementException, PolicyManagementException;

Loading…
Cancel
Save