mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Add notifier type details
This commit is contained in:
parent
625bbdc6f7
commit
4bc04b7923
@ -27,9 +27,20 @@ import java.io.Serializable;
|
|||||||
description = "This class represents notification frequency configuration.")
|
description = "This class represents notification frequency configuration.")
|
||||||
public class NotifierFrequency extends AndroidOperation implements Serializable {
|
public class NotifierFrequency extends AndroidOperation implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "type", value = "Notification type", required = true)
|
||||||
|
private int type;
|
||||||
|
|
||||||
@ApiModelProperty(name = "value", value = "Notification polling frequency", required = true)
|
@ApiModelProperty(name = "value", value = "Notification polling frequency", required = true)
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,6 +134,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
try {
|
try {
|
||||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
||||||
|
NotifierFrequency notifierFrequency = new NotifierFrequency();
|
||||||
for (ConfigurationEntry entry : configs) {
|
for (ConfigurationEntry entry : configs) {
|
||||||
if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
|
||||||
License license = new License();
|
License license = new License();
|
||||||
@ -145,30 +146,18 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
|
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
|
||||||
licenseEntry = entry;
|
licenseEntry = entry;
|
||||||
} else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) {
|
} else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) {
|
||||||
List<Device> deviceList = AndroidAPIUtils.
|
|
||||||
getDeviceManagementService().
|
|
||||||
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false);
|
|
||||||
List<DeviceIdentifier> deviceIdList = new ArrayList<>();
|
|
||||||
for (Device device : deviceList) {
|
|
||||||
if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) {
|
|
||||||
deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!deviceIdList.isEmpty()) {
|
|
||||||
if (entry.getValue() != null) {
|
if (entry.getValue() != null) {
|
||||||
NotifierFrequency notifierFrequency = new NotifierFrequency();
|
|
||||||
notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString()));
|
notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString()));
|
||||||
ProfileOperation operation = new ProfileOperation();
|
|
||||||
operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY);
|
|
||||||
operation.setPayLoad(notifierFrequency.toJSON());
|
|
||||||
operation.setEnabled(true);
|
|
||||||
AndroidAPIUtils.getDeviceManagementService().addOperation(
|
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
|
||||||
operation, deviceIdList);
|
|
||||||
} else {
|
} else {
|
||||||
return Response.status(Response.Status.BAD_REQUEST)
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
.entity("No value specified for notifierFrequency.").build();
|
.entity("No value specified for notifierFrequency.").build();
|
||||||
}
|
}
|
||||||
|
} else if (AndroidConstants.TenantConfigProperties.NOTIFIER_TYPE.equals(entry.getName())) {
|
||||||
|
if (entry.getValue() != null) {
|
||||||
|
notifierFrequency.setType(Integer.parseInt(entry.getValue().toString()));
|
||||||
|
} else {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("No value specified for notifierType.").build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,6 +167,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
}
|
}
|
||||||
configuration.setConfiguration(configs);
|
configuration.setConfiguration(configs);
|
||||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||||
|
notifyDevices(notifierFrequency);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
msg = "Error occurred while modifying configuration settings of Android platform";
|
msg = "Error occurred while modifying configuration settings of Android platform";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
@ -203,6 +193,27 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
.entity("Android platform configuration has been updated successfully.").build();
|
.entity("Android platform configuration has been updated successfully.").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyDevices(NotifierFrequency notifierFrequency) throws DeviceManagementException,
|
||||||
|
OperationManagementException, InvalidDeviceException {
|
||||||
|
List<Device> deviceList = AndroidAPIUtils.
|
||||||
|
getDeviceManagementService().
|
||||||
|
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false);
|
||||||
|
List<DeviceIdentifier> deviceIdList = new ArrayList<>();
|
||||||
|
for (Device device : deviceList) {
|
||||||
|
if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) {
|
||||||
|
deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!deviceIdList.isEmpty()) {
|
||||||
|
ProfileOperation operation = new ProfileOperation();
|
||||||
|
operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY);
|
||||||
|
operation.setPayLoad(notifierFrequency.toJSON());
|
||||||
|
operation.setEnabled(true);
|
||||||
|
AndroidAPIUtils.getDeviceManagementService().addOperation(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
||||||
|
operation, deviceIdList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/license")
|
@Path("/license")
|
||||||
|
|||||||
@ -160,6 +160,7 @@ public final class AndroidConstants {
|
|||||||
public static final String LANGUAGE_US = "en_US";
|
public static final String LANGUAGE_US = "en_US";
|
||||||
public static final String CONTENT_TYPE_TEXT = "text";
|
public static final String CONTENT_TYPE_TEXT = "text";
|
||||||
public static final String NOTIFIER_FREQUENCY = "notifierFrequency";
|
public static final String NOTIFIER_FREQUENCY = "notifierFrequency";
|
||||||
|
public static final String NOTIFIER_TYPE = "notifierType";
|
||||||
public static final String SERVER_VERSION = "serverVersion";
|
public static final String SERVER_VERSION = "serverVersion";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user