Merge pull request #916 from charithag/master

Fixed issue in device type config operation & Add HTTPS support for file transfer
revert-dabc3590
Charitha Goonetilleke 6 years ago committed by GitHub
commit 697c86d0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException; 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.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -124,18 +125,20 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
} else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) { } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) {
List<Device> deviceList = AndroidAPIUtils. List<Device> deviceList = AndroidAPIUtils.
getDeviceManagementService(). getDeviceManagementService().
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false);
List<DeviceIdentifier> deviceIdList = new ArrayList<>(); List<DeviceIdentifier> deviceIdList = new ArrayList<>();
for (Device device : deviceList) { for (Device device : deviceList) {
if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) {
deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
} }
}
if (!deviceIdList.isEmpty()) {
if (entry.getValue() != null) { if (entry.getValue() != null) {
NotifierFrequency notifierFrequency = new NotifierFrequency(); NotifierFrequency notifierFrequency = new NotifierFrequency();
notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString())); notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString()));
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY); operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY);
operation.setPayLoad(notifierFrequency.toJSON()); operation.setPayLoad(notifierFrequency.toJSON());
operation.setType(Operation.Type.CONFIG);
operation.setEnabled(true); operation.setEnabled(true);
AndroidAPIUtils.getDeviceManagementService().addOperation( AndroidAPIUtils.getDeviceManagementService().addOperation(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
@ -146,6 +149,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
} }
} }
} }
}
if (licenseEntry != null) { if (licenseEntry != null) {
configs.remove(licenseEntry); configs.remove(licenseEntry);

@ -282,7 +282,7 @@ function validateFileTransferParameters(payload) {
returnVal = "Please enter File URL"; returnVal = "Please enter File URL";
} else if (!payload.upload && !payload.fileURL) { } else if (!payload.upload && !payload.fileURL) {
returnVal = "Please enter the URL to upload file from device"; returnVal = "Please enter the URL to upload file from device";
} else if (protocol === "HTTP" && !(payload.fileURL).startsWith("http:")) { } else if (protocol === "HTTP" && !(payload.fileURL.startsWith("http:") || payload.fileURL.startsWith("https:"))) {
returnVal = "Please enter HTTP URL" returnVal = "Please enter HTTP URL"
} else if (protocol === "FTP" && !(payload.fileURL).startsWith("ftp:")) { } else if (protocol === "FTP" && !(payload.fileURL).startsWith("ftp:")) {
returnVal = "Please enter FTP URL" returnVal = "Please enter FTP URL"

@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException; 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.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -125,18 +126,20 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
} else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) { } else if (AndroidConstants.TenantConfigProperties.NOTIFIER_FREQUENCY.equals(entry.getName())) {
List<Device> deviceList = AndroidAPIUtils. List<Device> deviceList = AndroidAPIUtils.
getDeviceManagementService(). getDeviceManagementService().
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); getAllDevices(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, false);
List<DeviceIdentifier> deviceIdList = new ArrayList<>(); List<DeviceIdentifier> deviceIdList = new ArrayList<>();
for (Device device : deviceList) { for (Device device : deviceList) {
if (EnrolmentInfo.Status.REMOVED != device.getEnrolmentInfo().getStatus()) {
deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); deviceIdList.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
} }
}
if (!deviceIdList.isEmpty()) {
if (entry.getValue() != null) { if (entry.getValue() != null) {
NotifierFrequency notifierFrequency = new NotifierFrequency(); NotifierFrequency notifierFrequency = new NotifierFrequency();
notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString())); notifierFrequency.setValue(Integer.parseInt(entry.getValue().toString()));
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY); operation.setCode(AndroidConstants.OperationCodes.NOTIFIER_FREQUENCY);
operation.setPayLoad(notifierFrequency.toJSON()); operation.setPayLoad(notifierFrequency.toJSON());
operation.setType(Operation.Type.CONFIG);
operation.setEnabled(true); operation.setEnabled(true);
AndroidAPIUtils.getDeviceManagementService().addOperation( AndroidAPIUtils.getDeviceManagementService().addOperation(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
@ -147,6 +150,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
} }
} }
} }
}
if (licenseEntry != null) { if (licenseEntry != null) {
configs.remove(licenseEntry); configs.remove(licenseEntry);

Loading…
Cancel
Save