|
|
|
@ -20,7 +20,11 @@ package org.wso2.carbon.mdm.services.android.services.impl;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.*;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
|
|
@ -125,16 +129,21 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|
|
|
|
for (Device device : deviceList) {
|
|
|
|
|
deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(),device.getType()));
|
|
|
|
|
}
|
|
|
|
|
NotifierFrequency notifierFrequency = new NotifierFrequency();
|
|
|
|
|
notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString()));
|
|
|
|
|
ProfileOperation operation = new ProfileOperation();
|
|
|
|
|
operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY);
|
|
|
|
|
operation.setPayLoad(notifierFrequency.toJSON());
|
|
|
|
|
operation.setType(Operation.Type.CONFIG);
|
|
|
|
|
operation.setEnabled(true);
|
|
|
|
|
AndroidAPIUtils.getDeviceManagementService().addOperation(
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
|
|
|
|
operation, deviceIdList);
|
|
|
|
|
if (entry.getValue() != null) {
|
|
|
|
|
NotifierFrequency notifierFrequency = new NotifierFrequency();
|
|
|
|
|
notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString()));
|
|
|
|
|
ProfileOperation operation = new ProfileOperation();
|
|
|
|
|
operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY);
|
|
|
|
|
operation.setPayLoad(notifierFrequency.toJSON());
|
|
|
|
|
operation.setType(Operation.Type.CONFIG);
|
|
|
|
|
operation.setEnabled(true);
|
|
|
|
|
AndroidAPIUtils.getDeviceManagementService().addOperation(
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
|
|
|
|
operation, deviceIdList);
|
|
|
|
|
} else {
|
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST)
|
|
|
|
|
.entity("No value specified for notifierFrequency.").build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -143,7 +152,6 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|
|
|
|
}
|
|
|
|
|
configuration.setConfiguration(configs);
|
|
|
|
|
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
|
|
|
|
//AndroidAPIUtils.getGCMService().resetTenantConfigCache();
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
msg = "Error occurred while modifying configuration settings of Android platform";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
@ -154,11 +162,6 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
} catch (NullPointerException e) {
|
|
|
|
|
msg = "Error occurred while reading notifierFrequency value.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
|
msg = "Error occurred while modifying configuration settings of Android platform.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|