Adding an interface method to DeviceManager.java to support claimable devices

revert-70aa11f8
prabathabey 10 years ago
parent a3e385bd2f
commit d444f4ce0c

@ -24,6 +24,13 @@ public class DeviceIdentifier implements Serializable{
private String id; private String id;
private String type; private String type;
public DeviceIdentifier() {}
public DeviceIdentifier(String id, String type) {
this.id = id;
this.type = type;
}
public String getType() { public String getType() {
return type; return type;
} }

@ -134,4 +134,6 @@ public interface DeviceManager {
*/ */
boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException; boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException;
boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException;
} }

@ -108,7 +108,11 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
try { try {
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device); org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
DeviceType deviceType = this.getDeviceTypeDAO().getDeviceType(device.getType()); DeviceType deviceType = this.getDeviceTypeDAO().getDeviceType(device.getType());
if (dms.isClaimable(new DeviceIdentifier(device.getDeviceIdentifier(), deviceType.getName()))) {
deviceDto.setStatus(Status.INACTIVE);
} else {
deviceDto.setStatus(Status.ACTIVE); deviceDto.setStatus(Status.ACTIVE);
}
deviceDto.setDeviceTypeId(deviceType.getId()); deviceDto.setDeviceTypeId(deviceType.getId());
this.getDeviceDAO().addDevice(deviceDto); this.getDeviceDAO().addDevice(deviceDto);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
@ -410,6 +414,13 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
return dms.setOwnership(deviceId, ownershipType); return dms.setOwnership(deviceId, ownershipType);
} }
@Override
public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManager dms =
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
return dms.isClaimable(deviceId);
}
@Override @Override
public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { public License getLicense(String deviceType, String languageCode) throws LicenseManagementException {
return DeviceManagementDataHolder.getInstance().getLicenseManager().getLicense(deviceType, languageCode); return DeviceManagementDataHolder.getInstance().getLicenseManager().getLicense(deviceType, languageCode);

@ -110,6 +110,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
ownershipType); ownershipType);
} }
@Override
public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isClaimable(deviceId);
}
@Override @Override
public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { public License getLicense(String deviceType, String languageCode) throws LicenseManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getLicense(deviceType, return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getLicense(deviceType,
@ -217,4 +222,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
.getDevicesByName(deviceName, tenantId); .getDevicesByName(deviceName, tenantId);
} }
} }

@ -88,6 +88,11 @@ public class TestDeviceManager implements DeviceMgtService {
return false; return false;
} }
@Override
public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override @Override
public void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers) public void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
throws AppManagerConnectorException { throws AppManagerConnectorException {

Loading…
Cancel
Save