diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java index a56cdf1355..e4488952d0 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/FileTransfer.java @@ -23,7 +23,9 @@ import org.wso2.carbon.mdm.services.android.bean.AndroidOperation; import java.io.Serializable; - +/** + * This class represents the information of file transfer operation payload. + */ @ApiModel(value = "FileTransfer", description = "This class carries all information related to file transfer operation.") public class FileTransfer extends AndroidOperation implements Serializable { @@ -34,8 +36,8 @@ public class FileTransfer extends AndroidOperation implements Serializable { @ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true) private String ftpPassword; - @ApiModelProperty(name = "savingDirectory", value = "savingDirectory", required = true) - private String savingDirectory; + @ApiModelProperty(name = "fileLocation", value = "fileLocation", required = true) + private String fileLocation; public String getFileURL() { return fileURL; @@ -54,11 +56,11 @@ public class FileTransfer extends AndroidOperation implements Serializable { this.ftpPassword = ftpPassword; } - public String getSavingDirectory() { - return savingDirectory; + public String getFileLocation() { + return fileLocation; } - public void setSavingDirectory(String savingDirectory) { - this.savingDirectory = savingDirectory; + public void setFileLocation(String fileLocation) { + this.fileLocation = fileLocation; } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java index 54accca6f0..851a90a473 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransferBeanWrapper.java @@ -30,9 +30,12 @@ import java.util.List; description = "FileTransfer related Information.") public class FileTransferBeanWrapper { - @ApiModelProperty(name = "deviceIDs", value = "Device id list to which the operation to be executed.", required = true) + @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) private List deviceIDs; + @ApiModelProperty(name = "upload", value = "This is an inbound file transfer or out bound file transfer respective to the device.", required = true) + private boolean upload; + @ApiModelProperty(name = "operation", value = "Information of the File Transfer Operation.", required = true) private FileTransfer operation; @@ -52,4 +55,11 @@ public class FileTransferBeanWrapper { this.operation = operation; } + public boolean isUpload() { + return upload; + } + + public void setUpload(boolean upload) { + this.upload = upload; + } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java index 033899260c..7974f00cbb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java @@ -107,7 +107,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } FileTransfer file = fileTransferBeanWrapper.getOperation(); ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.FILE_TRANSFER); + if (fileTransferBeanWrapper.isUpload()) { + operation.setCode(AndroidConstants.OperationCodes.FILE_DOWNLOAD); + } else { + operation.setCode(AndroidConstants.OperationCodes.FILE_UPLOAD); + } operation.setType(Operation.Type.PROFILE); operation.setEnabled(true); operation.setPayLoad(file.toJSON()); @@ -153,10 +157,10 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe operation.setPayLoad(lock.toJSON()); return AndroidAPIUtils.getOperationResponse(deviceLockBeanWrapper.getDeviceIDs(), operation); } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; - log.error(errorMessage, e); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } catch (OperationManagementException e) { String errorMessage = "Issue in retrieving operation management service instance"; log.error(errorMessage, e); @@ -568,7 +572,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe try { if (applicationInstallationBeanWrapper == null || applicationInstallationBeanWrapper.getOperation() == - null) { + null) { String errorMessage = "The payload of the application installing operation is incorrect"; log.error(errorMessage); throw new BadRequestException( @@ -585,7 +589,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe operation.setType(Operation.Type.PROFILE); operation.setPayLoad(applicationInstallation.toJSON()); return AndroidAPIUtils.getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(), - operation); + operation); } catch (JSONException e) { String errorMessage = "Invalid payload for the operation."; log.error(errorMessage); @@ -1065,7 +1069,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe try { URL url = new URL(apkUrl); URLConnection conn = url.openConnection(); - if(((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) { + if (((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) { String errorMessage = "URL is not pointed to a downloadable file."; log.error(errorMessage); throw new BadRequestException( @@ -1087,8 +1091,8 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe private static void validateApplicationType(String type) { if (type != null) { if (!"enterprise".equalsIgnoreCase(type) - && !"public".equalsIgnoreCase(type) - && !"webapp".equalsIgnoreCase(type)) { + && !"public".equalsIgnoreCase(type) + && !"webapp".equalsIgnoreCase(type)) { String errorMessage = "Invalid application type."; log.error(errorMessage); throw new BadRequestException( diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java index b115af6988..676ef4f4d8 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java @@ -74,7 +74,8 @@ public final class AndroidConstants { } public static final String DEVICE_LOCK = "DEVICE_LOCK"; - public static final String FILE_TRANSFER = "FILE_TRANSFER"; + public static final String FILE_DOWNLOAD = "FILE_UPLOAD_TO_THE_DEVICE"; + public static final String FILE_UPLOAD = "FILE_UPLOAD_BY_THE_DEVICE"; public static final String DEVICE_UNLOCK = "DEVICE_UNLOCK"; public static final String DEVICE_LOCATION = "DEVICE_LOCATION"; public static final String WIFI = "WIFI"; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs index d312f51ea0..ffe4691dff 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/operation-bar.hbs @@ -71,6 +71,10 @@ + +
{{/each}} {{#each uiParams}} + {{#equal this.type "bi-radio"}} + + {{this.yesValue}} + + {{this.noValue}} +

+ {{/equal}} {{#equal this.type "checkbox"}}