mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
refactoring error/debug logs
This commit is contained in:
parent
78d60b1a92
commit
92d6624bbf
@ -65,4 +65,10 @@ public class GroupPaginationRequest {
|
|||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Group Name '" + this.groupName + "' num of rows: " + this.rowCount + " start index: " + this.startIndex
|
||||||
|
+ " owner' " + this.owner + "'";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,4 +129,12 @@ public class PaginationRequest {
|
|||||||
public void setOwnerPattern(String ownerPattern) {
|
public void setOwnerPattern(String ownerPattern) {
|
||||||
this.ownerPattern = ownerPattern;
|
this.ownerPattern = ownerPattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Device type '" + this.deviceType + "' Device Name '" + this.deviceName + "' row count: " + this.rowCount
|
||||||
|
+ " Owner role '" + this.ownerRole + "' owner pattern '" + this.ownerPattern + "' ownership "
|
||||||
|
+ this.ownership + "' Status '" + this.status + "' owner '" + this.owner + "' groupId: " + this.groupId
|
||||||
|
+ " start index: " + this.startIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,8 +160,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||||
|
if (device != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Enrolling the device " + device.getId() + "of type " + device.getType());
|
log.debug("Enrolling the device " + device.getId() + "of type '" + device.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "required values are not set for device enrollment";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
boolean status = false;
|
boolean status = false;
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
||||||
@ -292,9 +298,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||||
|
if (device != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Modifying enrollment for device " + device.getDeviceIdentifier() + " of type " + device.getType());
|
log.debug("Modifying enrollment for device: " + device.getId() + " of type '" + device.getType() + "'");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "required values are not set to modify device enrollment";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceManager deviceManager = this.getDeviceManager(device.getType());
|
DeviceManager deviceManager = this.getDeviceManager(device.getType());
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType());
|
||||||
if (deviceManager == null) {
|
if (deviceManager == null) {
|
||||||
@ -366,8 +379,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
|
if (deviceId != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Dis-enrolling device " + deviceId.getId() + " of type " + deviceId.getType());
|
log.debug("Dis-enrolling device: " + deviceId.getId() + " of type '" + deviceId.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "required values are not set to dis-enroll device";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
|
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
|
||||||
if (deviceManager == null) {
|
if (deviceManager == null) {
|
||||||
@ -465,8 +484,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getAllDevices(String deviceType, boolean requireDeviceInfo) throws DeviceManagementException {
|
public List<Device> getAllDevices(String deviceType, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (deviceType != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting all devices of type " + deviceType);
|
log.debug("Getting all devices of type '" + deviceType + "' and requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "Device type is empty for method getAllDevices";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> allDevices;
|
List<Device> allDevices;
|
||||||
try {
|
try {
|
||||||
@ -508,7 +533,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public List<Device> getAllDevices(boolean requireDeviceInfo) throws DeviceManagementException {
|
public List<Device> getAllDevices(boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting all devices");
|
log.debug("Getting all devices with requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
}
|
}
|
||||||
List<Device> allDevices;
|
List<Device> allDevices;
|
||||||
try {
|
try {
|
||||||
@ -543,8 +568,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getDevices(Date since, boolean requireDeviceInfo) throws DeviceManagementException {
|
public List<Device> getDevices(Date since, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (since != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting all devices since date " + since.toString());
|
log.debug("Getting all devices since date '" + since.toString() + "' and required device info: "
|
||||||
|
+ requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "Given date is empty for method getDevices";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> allDevices;
|
List<Device> allDevices;
|
||||||
try {
|
try {
|
||||||
@ -579,8 +611,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaginationResult getDevicesByType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException {
|
public PaginationResult getDevicesByType(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices with pagination");
|
log.debug("Get devices with pagination " + request.toString() + " and required deviceinfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete pagination request for getDevicesByType";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
PaginationResult paginationResult = new PaginationResult();
|
PaginationResult paginationResult = new PaginationResult();
|
||||||
List<Device> allDevices = new ArrayList<>();
|
List<Device> allDevices = new ArrayList<>();
|
||||||
@ -627,8 +665,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaginationResult getAllDevices(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException {
|
public PaginationResult getAllDevices(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices with pagination");
|
log.debug("Get devices with pagination " + request.toString() + " and requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete pagination request for method getAllDevices";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> devicesForRoles = null;
|
List<Device> devicesForRoles = null;
|
||||||
PaginationResult paginationResult = new PaginationResult();
|
PaginationResult paginationResult = new PaginationResult();
|
||||||
@ -677,8 +721,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceIdentifier deviceId, boolean requireDeviceInfo) throws DeviceManagementException {
|
public Device getDevice(DeviceIdentifier deviceId, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (deviceId != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get device by device id " + deviceId.getId() + " of type " + deviceId.getType());
|
log.debug("Get device by device id :" + deviceId.getId() + " of type '" + deviceId.getType()
|
||||||
|
+ "' and requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null device identifier for method getDevice";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
int tenantId = this.getTenantId();
|
int tenantId = this.getTenantId();
|
||||||
Device device = this.getDeviceFromCache(deviceId);
|
Device device = this.getDeviceFromCache(deviceId);
|
||||||
@ -719,8 +770,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException {
|
public void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException {
|
||||||
|
if (metaInfo != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Send enrollment invitation");
|
log.debug("Send enrollment invitation, templateName '" + templateName + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data to method sendEnrolmentInvitation";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
Map<String, TypedValue<Class<?>, Object>> params = new HashMap<>();
|
Map<String, TypedValue<Class<?>, Object>> params = new HashMap<>();
|
||||||
Properties props = metaInfo.getProperties();
|
Properties props = metaInfo.getProperties();
|
||||||
@ -751,9 +808,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException {
|
public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException {
|
||||||
|
if (metaInfo != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Send registration email");
|
log.debug("Send registration email");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete request for sendRegistrationEmail";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
|
}
|
||||||
Map<String, TypedValue<Class<?>, Object>> params = new HashMap<>();
|
Map<String, TypedValue<Class<?>, Object>> params = new HashMap<>();
|
||||||
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.FIRST_NAME,
|
params.put(org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailAttributes.FIRST_NAME,
|
||||||
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("first-name")));
|
new TypedValue<Class<?>, Object>(String.class, metaInfo.getProperty("first-name")));
|
||||||
@ -788,8 +851,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
public HashMap<Integer, Device> getTenantedDevice(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||||
|
if (deviceIdentifier != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get tenanted device with id " + deviceIdentifier.getId() + " of type " + deviceIdentifier.getType());
|
log.debug("Get tenanted device with id: " + deviceIdentifier.getId() + " of type '" +
|
||||||
|
deviceIdentifier.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null deviceIdentifier for getTenantedDevice";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
HashMap<Integer, Device> deviceHashMap;
|
HashMap<Integer, Device> deviceHashMap;
|
||||||
try {
|
try {
|
||||||
@ -827,8 +897,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDeviceWithTypeProperties(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public Device getDeviceWithTypeProperties(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
|
if (deviceId != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get tenanted device with type properties");
|
log.debug("Get tenanted device with type properties, deviceId: " + deviceId.getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null deviceIdentifier for getDeviceWithTypeProperties";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
Device device = this.getDevice(deviceId, false);
|
Device device = this.getDevice(deviceId, false);
|
||||||
|
|
||||||
@ -856,9 +932,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceIdentifier deviceId, Date since, boolean requireDeviceInfo) throws DeviceManagementException {
|
public Device getDevice(DeviceIdentifier deviceId, Date since, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (deviceId != null && since != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get device since " + since.toString() + " with identifier " + deviceId.getId() + " and type "
|
log.debug("Get device since '" + since.toString() + "' with identifier: " + deviceId.getId()
|
||||||
+ deviceId.getType());
|
+ " and type '" + deviceId.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevice";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
Device device;
|
Device device;
|
||||||
try {
|
try {
|
||||||
@ -900,8 +982,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status, boolean requireDeviceInfo)
|
public Device getDevice(DeviceIdentifier deviceId, EnrolmentInfo.Status status, boolean requireDeviceInfo)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (deviceId != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get device with identifier " + deviceId.getId() + " and type " + deviceId.getType());
|
log.debug("Get device with identifier: " + deviceId.getId() + " and type '" + deviceId.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null deviceIdentifier for getDevice";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
Device device;
|
Device device;
|
||||||
try {
|
try {
|
||||||
@ -994,8 +1082,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateDeviceInfo(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
|
public boolean updateDeviceInfo(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
|
||||||
|
if (deviceId != null && device != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Update device info of device " + deviceId.getId());
|
log.debug("Update device info of device: " + deviceId.getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for updateDeviceInfo";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
|
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
|
||||||
if (deviceManager == null) {
|
if (deviceManager == null) {
|
||||||
@ -1010,8 +1104,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
|
||||||
|
if (deviceId != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Set ownership of device " + deviceId.getId());
|
log.debug("Set ownership of device: " + deviceId.getId() + " ownership type '" + ownershipType + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for setOwnership";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
|
DeviceManager deviceManager = this.getDeviceManager(deviceId.getType());
|
||||||
if (deviceManager == null) {
|
if (deviceManager == null) {
|
||||||
@ -1040,8 +1140,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
|
public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
|
||||||
EnrolmentInfo.Status status) throws DeviceManagementException {
|
EnrolmentInfo.Status status) throws DeviceManagementException {
|
||||||
|
if (deviceId != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Set status of device " + deviceId.getId());
|
log.debug("Set status of device: " + deviceId.getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null deviceIdentifier for setStatus";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
@ -1120,8 +1226,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public License getLicense(String deviceType, String languageCode) throws DeviceManagementException {
|
public License getLicense(String deviceType, String languageCode) throws DeviceManagementException {
|
||||||
|
if (deviceType != null && languageCode != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get the licence for device type " + deviceType);
|
log.debug("Get the licence for device type '" + deviceType + "' languageCode '" + languageCode + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getLicence";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManager deviceManager = this.getDeviceManager(deviceType);
|
DeviceManager deviceManager = this.getDeviceManager(deviceType);
|
||||||
License license;
|
License license;
|
||||||
@ -1154,8 +1266,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLicense(String deviceType, License license) throws DeviceManagementException {
|
public void addLicense(String deviceType, License license) throws DeviceManagementException {
|
||||||
|
if (deviceType != null && license != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Add the licence for device type " + deviceType);
|
log.debug("Add the licence for device type '" + deviceType + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for addLicence";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManager deviceManager = this.getDeviceManager(deviceType);
|
DeviceManager deviceManager = this.getDeviceManager(deviceType);
|
||||||
if (deviceManager == null) {
|
if (deviceManager == null) {
|
||||||
@ -1306,8 +1424,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getDevicesOfUser(String username, boolean requireDeviceInfo) throws DeviceManagementException {
|
public List<Device> getDevicesOfUser(String username, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (username == null) {
|
||||||
|
String msg = "username null in getDevicesOfUser";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices of user with username " + username);
|
log.debug("Get devices of user with username '" + username + "' and requiredDeviceInfo " + requireDeviceInfo);
|
||||||
}
|
}
|
||||||
List<Device> userDevices;
|
List<Device> userDevices;
|
||||||
try {
|
try {
|
||||||
@ -1344,8 +1467,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public List<Device> getDevicesOfUser(String username, String deviceType, boolean requireDeviceInfo) throws
|
public List<Device> getDevicesOfUser(String username, String deviceType, boolean requireDeviceInfo) throws
|
||||||
DeviceManagementException {
|
DeviceManagementException {
|
||||||
|
if (username != null && deviceType != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices of user with username " + username);
|
log.debug("Get '" + deviceType + "' devices of user with username '" + username + "' requiredDeviceInfo: "
|
||||||
|
+ requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesOfUser";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> userDevices;
|
List<Device> userDevices;
|
||||||
try {
|
try {
|
||||||
@ -1382,8 +1512,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public PaginationResult getDevicesOfUser(PaginationRequest request, boolean requireDeviceInfo)
|
public PaginationResult getDevicesOfUser(PaginationRequest request, boolean requireDeviceInfo)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get paginated results of devices of user " + request.getOwner());
|
log.debug("Get paginated results of devices of user " + request.toString() + " and requiredDeviceInfo: "
|
||||||
|
+ requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete pagination request for getDevicesOfUser";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
PaginationResult result = new PaginationResult();
|
PaginationResult result = new PaginationResult();
|
||||||
int deviceCount = 0;
|
int deviceCount = 0;
|
||||||
@ -1431,8 +1568,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public PaginationResult getDevicesByOwnership(PaginationRequest request, boolean requireDeviceInfo)
|
public PaginationResult getDevicesByOwnership(PaginationRequest request, boolean requireDeviceInfo)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices by ownership " + request.getOwnership());
|
log.debug("Get devices by ownership " + request.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesByOwnership";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
PaginationResult result = new PaginationResult();
|
PaginationResult result = new PaginationResult();
|
||||||
List<Device> allDevices;
|
List<Device> allDevices;
|
||||||
@ -1477,8 +1620,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getAllDevicesOfRole(String role, boolean requireDeviceInfo) throws DeviceManagementException {
|
public List<Device> getAllDevicesOfRole(String role, boolean requireDeviceInfo) throws DeviceManagementException {
|
||||||
|
if (role != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices of role " + role);
|
log.debug("Get devices of role '" + role + "' and requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received empty role for the method getAllDevicesOfRole";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
String[] users;
|
String[] users;
|
||||||
@ -1522,8 +1671,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDeviceCount(String username) throws DeviceManagementException {
|
public int getDeviceCount(String username) throws DeviceManagementException {
|
||||||
|
if (username != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Getting device count of the user " + username);
|
log.debug("Getting device count of the user '" + username + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received empty username for getDeviceCount";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
@ -1573,8 +1728,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public List<Device> getDevicesByNameAndType(PaginationRequest request, boolean requireDeviceInfo)
|
public List<Device> getDevicesByNameAndType(PaginationRequest request, boolean requireDeviceInfo)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices by name " + request.getDeviceName() + " and type " + request.getDeviceType());
|
log.debug("Get devices by name " + request.toString() + " and requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesByNameAndType";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
List<Device> allDevices;
|
List<Device> allDevices;
|
||||||
@ -1616,8 +1777,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public PaginationResult getDevicesByName(PaginationRequest request, boolean requireDeviceInfo) throws
|
public PaginationResult getDevicesByName(PaginationRequest request, boolean requireDeviceInfo) throws
|
||||||
DeviceManagementException {
|
DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get devices by name " + request.getDeviceName());
|
log.debug("Get devices by name " + request.toString() + " requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesByName";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
PaginationResult result = new PaginationResult();
|
PaginationResult result = new PaginationResult();
|
||||||
int tenantId = this.getTenantId();
|
int tenantId = this.getTenantId();
|
||||||
@ -1656,8 +1823,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status status) throws DeviceManagementException {
|
public void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status status) throws DeviceManagementException {
|
||||||
try {
|
try {
|
||||||
|
if (device != null && status != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Updating enrolment for device " + device.getDeviceIdentifier() + " of type " + device.getType());
|
log.debug("Updating enrolment for device: " + device.getId() + " of type '" + device.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for updateDeviceEnrolmentInfo";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManagementDAOFactory.beginTransaction();
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
||||||
@ -1725,7 +1898,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
public List<Device> getDevicesByStatus(EnrolmentInfo.Status status, boolean requireDeviceInfo) throws
|
public List<Device> getDevicesByStatus(EnrolmentInfo.Status status, boolean requireDeviceInfo) throws
|
||||||
DeviceManagementException {
|
DeviceManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("get devices by status");
|
log.debug("get devices by status and requiredDeviceInfo: " + requireDeviceInfo);
|
||||||
}
|
}
|
||||||
List<Device> allDevices;
|
List<Device> allDevices;
|
||||||
try {
|
try {
|
||||||
@ -1759,11 +1932,18 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public PaginationResult getDevicesByStatus(PaginationRequest request, boolean requireDeviceInfo)
|
public PaginationResult getDevicesByStatus(PaginationRequest request, boolean requireDeviceInfo)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("get devices by status with pagination");
|
log.debug("get devices by status " + request.toString() + " and requiredDeviceInfo: "
|
||||||
|
+ requireDeviceInfo);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesByStatus";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
PaginationResult result = new PaginationResult();
|
PaginationResult result = new PaginationResult();
|
||||||
List<Device> allDevices = new ArrayList<>();
|
List<Device> allDevices;
|
||||||
int tenantId = this.getTenantId();
|
int tenantId = this.getTenantId();
|
||||||
String status = request.getStatus();
|
String status = request.getStatus();
|
||||||
request = DeviceManagerUtil.validateDeviceListPageSize(request);
|
request = DeviceManagerUtil.validateDeviceListPageSize(request);
|
||||||
@ -1827,8 +2007,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus)
|
public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (deviceIdentifier != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Change device status of " + deviceIdentifier.getId());
|
log.debug("Change device status of device: " + deviceIdentifier.getId() + " of type '"
|
||||||
|
+ deviceIdentifier.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesByStatus";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
boolean isDeviceUpdated = false;
|
boolean isDeviceUpdated = false;
|
||||||
Device device = getDevice(deviceIdentifier, false);
|
Device device = getDevice(deviceIdentifier, false);
|
||||||
@ -1880,7 +2067,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId)
|
private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Update enrollment of device " + deviceId);
|
log.debug("Update enrollment of device: " + deviceId);
|
||||||
}
|
}
|
||||||
boolean isUpdatedEnrollment = false;
|
boolean isUpdatedEnrollment = false;
|
||||||
boolean isAutoCommit = true;
|
boolean isAutoCommit = true;
|
||||||
@ -1943,8 +2130,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
*/
|
*/
|
||||||
private void addDeviceToGroups(DeviceIdentifier deviceIdentifier, EnrolmentInfo.OwnerShip ownership)
|
private void addDeviceToGroups(DeviceIdentifier deviceIdentifier, EnrolmentInfo.OwnerShip ownership)
|
||||||
throws DeviceManagementException {
|
throws DeviceManagementException {
|
||||||
|
if (deviceIdentifier != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Add device " + deviceIdentifier.getId() + " to default group");
|
log.debug("Add device:" + deviceIdentifier.getId() + " to default group");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for addDeviceToGroup";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
GroupManagementProviderService groupManagementProviderService = new GroupManagementProviderServiceImpl();
|
GroupManagementProviderService groupManagementProviderService = new GroupManagementProviderServiceImpl();
|
||||||
try {
|
try {
|
||||||
@ -1970,8 +2163,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addInitialOperations(DeviceIdentifier deviceIdentifier, String deviceType) throws DeviceManagementException {
|
private void addInitialOperations(DeviceIdentifier deviceIdentifier, String deviceType) throws DeviceManagementException {
|
||||||
|
if (deviceIdentifier != null && deviceType != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Add initial operations to the device " + deviceIdentifier.getId());
|
log.debug("Add initial operations to the device:" + deviceIdentifier.getId() + " of type '"
|
||||||
|
+ deviceType + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDevicesByStatus";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
|
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
|
||||||
getDeviceManagementProvider();
|
getDeviceManagementProvider();
|
||||||
@ -2018,8 +2218,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
*/
|
*/
|
||||||
private DeviceGroup createDefaultGroup(GroupManagementProviderService service, String groupName)
|
private DeviceGroup createDefaultGroup(GroupManagementProviderService service, String groupName)
|
||||||
throws GroupManagementException {
|
throws GroupManagementException {
|
||||||
|
if (service != null && groupName != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Create default group with name " + groupName);
|
log.debug("Create default group with name '" + groupName + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for createDefaultGroup";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceGroup defaultGroup = service.getGroup(groupName);
|
DeviceGroup defaultGroup = service.getGroup(groupName);
|
||||||
if (defaultGroup == null) {
|
if (defaultGroup == null) {
|
||||||
@ -2054,8 +2260,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceType getDeviceType(String deviceType) throws DeviceManagementException {
|
public DeviceType getDeviceType(String deviceType) throws DeviceManagementException {
|
||||||
|
if (deviceType != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("get device type " + deviceType);
|
log.debug("get device type '" + deviceType + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null deviceType for getDeviceType";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.openConnection();
|
DeviceManagementDAOFactory.openConnection();
|
||||||
@ -2113,8 +2325,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
DeviceManagementService dms =
|
DeviceManagementService dms =
|
||||||
pluginRepository.getDeviceManagementService(deviceIdentifier.getType(), this.getTenantId());
|
pluginRepository.getDeviceManagementService(deviceIdentifier.getType(), this.getTenantId());
|
||||||
if (dms == null) {
|
if (dms == null) {
|
||||||
String message = "Device type '" + deviceIdentifier.getType() + "' does not have an associated device management " +
|
String message = "Device type '" + deviceIdentifier.getType() + "' does not have an associated " +
|
||||||
"plugin registered within the framework";
|
"device management plugin registered within the framework";
|
||||||
log.error(message);
|
log.error(message);
|
||||||
throw new PullNotificationExecutionFailedException(message);
|
throw new PullNotificationExecutionFailedException(message);
|
||||||
}
|
}
|
||||||
@ -2132,8 +2344,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
* Returns all the device-info including location of the given device.
|
* Returns all the device-info including location of the given device.
|
||||||
*/
|
*/
|
||||||
private DeviceInfo getDeviceInfo(Device device) throws DeviceManagementException {
|
private DeviceInfo getDeviceInfo(Device device) throws DeviceManagementException {
|
||||||
|
if (device != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get device info of device " + device.getId() + " of type " + device.getType());
|
log.debug("Get device info of device: " + device.getId() + " of type '" + device.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getDeviceInfo";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceInfo info = null;
|
DeviceInfo info = null;
|
||||||
try {
|
try {
|
||||||
@ -2166,7 +2384,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
*/
|
*/
|
||||||
private List<Application> getInstalledApplications(Device device) {
|
private List<Application> getInstalledApplications(Device device) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get installed applications of device " + device.getId() + " of type " + device.getType());
|
log.debug("Get installed applications of device: " + device.getId() + " of type '" + device.getType() + "'");
|
||||||
}
|
}
|
||||||
List<Application> applications = new ArrayList<>();
|
List<Application> applications = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
@ -2192,8 +2410,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
* of the given device list.
|
* of the given device list.
|
||||||
*/
|
*/
|
||||||
private List<Device> getAllDeviceInfo(List<Device> allDevices) throws DeviceManagementException {
|
private List<Device> getAllDeviceInfo(List<Device> allDevices) throws DeviceManagementException {
|
||||||
|
if (allDevices.size() > 0) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get all device info of devices");
|
log.debug("Get all device info of devices, num of devices: " + allDevices.size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received empty device list for getAllDeviceInfo";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
if (allDevices != null) {
|
if (allDevices != null) {
|
||||||
@ -2226,8 +2450,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
* of a given device.
|
* of a given device.
|
||||||
*/
|
*/
|
||||||
private Device getAllDeviceInfo(Device device) throws DeviceManagementException {
|
private Device getAllDeviceInfo(Device device) throws DeviceManagementException {
|
||||||
|
if (device != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get all device info of device " + device.getId() + " of type " + device.getType());
|
log.debug("Get all device info of device: " + device.getId() + " of type '" + device.getType() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received empty device for getAllDeviceInfo";
|
||||||
|
log.error(msg);
|
||||||
|
throw new DeviceManagementException(msg);
|
||||||
}
|
}
|
||||||
device.setDeviceInfo(this.getDeviceInfo(device));
|
device.setDeviceInfo(this.getDeviceInfo(device));
|
||||||
device.setApplications(this.getInstalledApplications(device));
|
device.setApplications(this.getInstalledApplications(device));
|
||||||
|
|||||||
@ -65,8 +65,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions)
|
public void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions)
|
||||||
throws GroupManagementException, GroupAlreadyExistException {
|
throws GroupManagementException, GroupAlreadyExistException {
|
||||||
|
if (deviceGroup != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Creating group" + deviceGroup.getName());
|
log.debug("Creating group '" + deviceGroup.getName() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for createGroup";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
if (deviceGroup == null) {
|
if (deviceGroup == null) {
|
||||||
throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException());
|
throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException());
|
||||||
@ -109,8 +115,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public void updateGroup(DeviceGroup deviceGroup, int groupId)
|
public void updateGroup(DeviceGroup deviceGroup, int groupId)
|
||||||
throws GroupManagementException, GroupAlreadyExistException {
|
throws GroupManagementException, GroupAlreadyExistException {
|
||||||
|
if (deviceGroup != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("update group" + deviceGroup.getName());
|
log.debug("update group '" + deviceGroup.getName() + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for updateGroup";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
if (deviceGroup == null) {
|
if (deviceGroup == null) {
|
||||||
throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException());
|
throw new GroupManagementException("DeviceGroup cannot be null.", new NullPointerException());
|
||||||
@ -149,7 +161,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public boolean deleteGroup(int groupId) throws GroupManagementException {
|
public boolean deleteGroup(int groupId) throws GroupManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Delete group " + groupId);
|
log.debug("Delete group: " + groupId);
|
||||||
}
|
}
|
||||||
DeviceGroup deviceGroup = getGroup(groupId);
|
DeviceGroup deviceGroup = getGroup(groupId);
|
||||||
if (deviceGroup == null) {
|
if (deviceGroup == null) {
|
||||||
@ -187,7 +199,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public DeviceGroup getGroup(int groupId) throws GroupManagementException {
|
public DeviceGroup getGroup(int groupId) throws GroupManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get group by id " + groupId);
|
log.debug("Get group by id: " + groupId);
|
||||||
}
|
}
|
||||||
DeviceGroup deviceGroup;
|
DeviceGroup deviceGroup;
|
||||||
try {
|
try {
|
||||||
@ -216,8 +228,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DeviceGroup getGroup(String groupName) throws GroupManagementException {
|
public DeviceGroup getGroup(String groupName) throws GroupManagementException {
|
||||||
|
if (groupName != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get group by name " + groupName);
|
log.debug("Get group by name '" + groupName + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received empty groupName for getGroup";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
DeviceGroup deviceGroup;
|
DeviceGroup deviceGroup;
|
||||||
try {
|
try {
|
||||||
@ -271,8 +289,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaginationResult getGroups(GroupPaginationRequest request) throws GroupManagementException {
|
public PaginationResult getGroups(GroupPaginationRequest request) throws GroupManagementException {
|
||||||
|
if (request != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups with pagination");
|
log.debug("Get groups with pagination " + request.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received incomplete data for getGroup";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
request = DeviceManagerUtil.validateGroupListPageSize(request);
|
request = DeviceManagerUtil.validateGroupListPageSize(request);
|
||||||
List<DeviceGroup> deviceGroups = new ArrayList<>();
|
List<DeviceGroup> deviceGroups = new ArrayList<>();
|
||||||
@ -303,8 +327,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceGroup> getGroups(String username) throws GroupManagementException {
|
public List<DeviceGroup> getGroups(String username) throws GroupManagementException {
|
||||||
|
if (username != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups of owner " + username);
|
log.debug("Get groups of owner '" + username + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received null user name for getGroups";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
Map<Integer, DeviceGroup> groups = new HashMap<>();
|
Map<Integer, DeviceGroup> groups = new HashMap<>();
|
||||||
UserStoreManager userStoreManager;
|
UserStoreManager userStoreManager;
|
||||||
@ -344,8 +374,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> getGroupIds(String username) throws GroupManagementException {
|
private List<Integer> getGroupIds(String username) throws GroupManagementException {
|
||||||
|
if (username != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups Ids of owner " + username);
|
log.debug("Get groups Ids of owner '" + username + "'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String msg = "received empty user name for getGroupIds";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
}
|
}
|
||||||
UserStoreManager userStoreManager;
|
UserStoreManager userStoreManager;
|
||||||
List<Integer> deviceGroupIds = new ArrayList<>();
|
List<Integer> deviceGroupIds = new ArrayList<>();
|
||||||
@ -381,8 +417,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public PaginationResult getGroups(String currentUser, GroupPaginationRequest request)
|
public PaginationResult getGroups(String currentUser, GroupPaginationRequest request)
|
||||||
throws GroupManagementException {
|
throws GroupManagementException {
|
||||||
|
if (currentUser == null || request == null) {
|
||||||
|
String msg = "received incomplete date for getGroups";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get all groups of user " + currentUser);
|
log.debug("Get all groups of user '" + currentUser + "' pagination request " + request.toString());
|
||||||
}
|
}
|
||||||
request = DeviceManagerUtil.validateGroupListPageSize(request);
|
request = DeviceManagerUtil.validateGroupListPageSize(request);
|
||||||
List<Integer> allDeviceGroupIdsOfUser = getGroupIds(currentUser);
|
List<Integer> allDeviceGroupIdsOfUser = getGroupIds(currentUser);
|
||||||
@ -439,8 +480,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getGroupCount(GroupPaginationRequest request) throws GroupManagementException {
|
private int getGroupCount(GroupPaginationRequest request) throws GroupManagementException {
|
||||||
|
if (request == null) {
|
||||||
|
String msg = "received empty request for getGroupCount";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups count");
|
log.debug("Get groups count, pagination request " + request.toString());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
@ -468,8 +514,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getGroupCount(String username) throws GroupManagementException {
|
public int getGroupCount(String username) throws GroupManagementException {
|
||||||
|
if (username == null) {
|
||||||
|
String msg = "received empty user name for getGroupCount";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups count of " + username);
|
log.debug("Get groups count of '" + username + "'");
|
||||||
}
|
}
|
||||||
UserStoreManager userStoreManager;
|
UserStoreManager userStoreManager;
|
||||||
int count;
|
int count;
|
||||||
@ -510,7 +561,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
public void manageGroupSharing(int groupId, List<String> newRoles)
|
public void manageGroupSharing(int groupId, List<String> newRoles)
|
||||||
throws GroupManagementException, RoleDoesNotExistException {
|
throws GroupManagementException, RoleDoesNotExistException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Group sharing for group " + groupId);
|
log.debug("Manage group sharing for group: " + groupId);
|
||||||
}
|
}
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
UserStoreManager userStoreManager;
|
UserStoreManager userStoreManager;
|
||||||
@ -564,7 +615,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getRoles(int groupId) throws GroupManagementException {
|
public List<String> getRoles(int groupId) throws GroupManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Group roles for group " + groupId);
|
log.debug("Group roles for group: " + groupId);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
@ -594,7 +645,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
public List<Device> getDevices(int groupId, int startIndex, int rowCount)
|
public List<Device> getDevices(int groupId, int startIndex, int rowCount)
|
||||||
throws GroupManagementException {
|
throws GroupManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Group devices of group " + groupId);
|
log.debug("Group devices of group: " + groupId + " start index " + startIndex + " row count " + rowCount);
|
||||||
}
|
}
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
List<Device> devices;
|
List<Device> devices;
|
||||||
@ -630,7 +681,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public int getDeviceCount(int groupId) throws GroupManagementException {
|
public int getDeviceCount(int groupId) throws GroupManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Group devices count of group " + groupId);
|
log.debug("Group devices count of group: " + groupId);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
GroupManagementDAOFactory.openConnection();
|
GroupManagementDAOFactory.openConnection();
|
||||||
@ -659,7 +710,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
public void addDevices(int groupId, List<DeviceIdentifier> deviceIdentifiers)
|
public void addDevices(int groupId, List<DeviceIdentifier> deviceIdentifiers)
|
||||||
throws GroupManagementException, DeviceNotFoundException {
|
throws GroupManagementException, DeviceNotFoundException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Group devices to the group " + groupId);
|
log.debug("Group devices to the group: " + groupId);
|
||||||
}
|
}
|
||||||
Device device;
|
Device device;
|
||||||
try {
|
try {
|
||||||
@ -705,7 +756,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
public void removeDevice(int groupId, List<DeviceIdentifier> deviceIdentifiers)
|
public void removeDevice(int groupId, List<DeviceIdentifier> deviceIdentifiers)
|
||||||
throws GroupManagementException, DeviceNotFoundException {
|
throws GroupManagementException, DeviceNotFoundException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Remove devices from the group " + groupId);
|
log.debug("Remove devices from the group: " + groupId);
|
||||||
}
|
}
|
||||||
Device device;
|
Device device;
|
||||||
try {
|
try {
|
||||||
@ -748,7 +799,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
@Override
|
@Override
|
||||||
public List<DeviceGroup> getGroups(String username, String permission) throws GroupManagementException {
|
public List<DeviceGroup> getGroups(String username, String permission) throws GroupManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups of user " + username);
|
log.debug("Get groups of user '" + username + "'");
|
||||||
}
|
}
|
||||||
List<DeviceGroup> deviceGroups = getGroups(username);
|
List<DeviceGroup> deviceGroups = getGroups(username);
|
||||||
Map<Integer, DeviceGroup> permittedDeviceGroups = new HashMap<>();
|
Map<Integer, DeviceGroup> permittedDeviceGroups = new HashMap<>();
|
||||||
@ -779,6 +830,11 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceGroup> getGroups(DeviceIdentifier deviceIdentifier) throws GroupManagementException {
|
public List<DeviceGroup> getGroups(DeviceIdentifier deviceIdentifier) throws GroupManagementException {
|
||||||
|
if (deviceIdentifier == null) {
|
||||||
|
String msg = "received empty device identifier for getGroups";
|
||||||
|
log.error(msg);
|
||||||
|
throw new GroupManagementException(msg);
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get groups of device " + deviceIdentifier.getId());
|
log.debug("Get groups of device " + deviceIdentifier.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user