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/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 similarity index 60% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/FileTransfer.java rename to 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 099cd8d86..a56cdf135 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/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 @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.mdm.services.android.bean.wrapper; +package org.wso2.carbon.mdm.services.android.bean; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -28,41 +28,23 @@ import java.io.Serializable; description = "This class carries all information related to file transfer operation.") public class FileTransfer extends AndroidOperation implements Serializable { - @ApiModelProperty(name = "ftpServerAddress", value = "FTP Server Address", required = true) - private String ftpServerAddress; - - @ApiModelProperty(name = "ftpUserName", value = "FTP User name", required = true) - private String ftpUserName; + @ApiModelProperty(name = "fileURL", value = "File URL", required = true) + private String fileURL; @ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true) private String ftpPassword; - @ApiModelProperty(name = "fileName", value = "File name", required = true) - private String fileName; - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getFtpServerAddress() { - return ftpServerAddress; - } + @ApiModelProperty(name = "savingDirectory", value = "savingDirectory", required = true) + private String savingDirectory; - public void setFtpServerAddress(String ftpServerAddress) { - this.ftpServerAddress = ftpServerAddress; + public String getFileURL() { + return fileURL; } - public String getFtpUserName() { - return ftpUserName; + public void setFileURL(String fileURL) { + this.fileURL = fileURL; } - public void setFtpUserName(String ftpUserName) { - this.ftpUserName = ftpUserName; - } public String getFtpPassword() { return ftpPassword; @@ -71,4 +53,12 @@ public class FileTransfer extends AndroidOperation implements Serializable { public void setFtpPassword(String ftpPassword) { this.ftpPassword = ftpPassword; } + + public String getSavingDirectory() { + return savingDirectory; + } + + public void setSavingDirectory(String savingDirectory) { + this.savingDirectory = savingDirectory; + } } 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 64ce960fa..810cb6a22 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 @@ -19,20 +19,21 @@ package org.wso2.carbon.mdm.services.android.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.mdm.services.android.bean.FileTransfer; import java.util.List; /** - * This class is used to wrap the Notification bean with devices. + * This class is used to wrap the File Transfer bean with devices. */ @ApiModel(value = "FileTransferBeanWrapper", description = "FileTransfer related Information.") -public class FileTransferBeanWrapper{ +public class FileTransferBeanWrapper { @ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true) private List deviceIDs; - @ApiModelProperty(name = "operation", value = "Information of the Device lock operation.", required = true) + @ApiModelProperty(name = "operation", value = "Information of the File Transfer Operation.", required = true) private FileTransfer operation; public List getDeviceIDs() { 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/DeviceManagementAdminService.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/DeviceManagementAdminService.java index f745c2489..a672d1cc3 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/DeviceManagementAdminService.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/DeviceManagementAdminService.java @@ -233,9 +233,8 @@ public interface DeviceManagementAdminService { consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", //todo - value = "Adding a Screen Lock on Android devices", - notes = "Using this API you have the option of hard locking an Android device, where the Administrator " + - "permanently locks the device or screen locking an Android device.", + value = "Transferring file to the device.", + notes = "Using this API you have the option to transfer a file from FTP server to an Android device.", response = Activity.class, tags = "Android Device Management Administrative Service", extensions = { @@ -248,7 +247,7 @@ public interface DeviceManagementAdminService { @ApiResponse( code = 201, //todo - message = "Created. \n Successfully scheduled the device lock operation.", + message = "File transferred.", response = Activity.class, responseHeaders = { @ResponseHeader( @@ -286,11 +285,7 @@ public interface DeviceManagementAdminService { Response fileTransfer( @ApiParam( name = "fileTransfer", - //todo - value = "Provide the ID of the Android device, the message that needs to be sent out when locking the device, " + - "and define true as the value if you need to hard lock the device or define false as the value to " + - "screen lock the device." + - "Multiple device IDs can be added by using comma separated values. ", + value ="Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", required = true) FileTransferBeanWrapper fileTransferBeanWrapper); @POST 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 a02060771..22a12b4bf 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 @@ -50,7 +50,7 @@ import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBe import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.FileTransfer; +import org.wso2.carbon.mdm.services.android.bean.FileTransfer; import org.wso2.carbon.mdm.services.android.bean.wrapper.FileTransferBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; @@ -107,7 +107,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } FileTransfer file = fileTransferBeanWrapper.getOperation(); ProfileOperation operation = new ProfileOperation(); - operation.setCode("FILE_TRANSFER"); + operation.setCode(AndroidConstants.OperationCodes.FILE_TRANSFER); operation.setType(Operation.Type.PROFILE); operation.setEnabled(true); operation.setPayLoad(file.toJSON()); 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 c1e09b4c0..b115af698 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,6 +74,7 @@ public final class AndroidConstants { } public static final String DEVICE_LOCK = "DEVICE_LOCK"; + public static final String FILE_TRANSFER = "FILE_TRANSFER"; 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/public/js/operation-bar.js 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/public/js/operation-bar.js index 877e066fa..a3faf1355 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/public/js/operation-bar.js +++ 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/public/js/operation-bar.js @@ -180,14 +180,12 @@ function validatePayload(operationCode, payload) { } break; case "FILE_TRANSFER": - if (!payload.ftpServerAddress) { - returnVal = "Please enter FTP server address"; - }else if(!payload.ftpUserName){ - returnVal = "Please enter FTP user name"; + if (!payload.fileURL) { + returnVal = "Please enter the URL of the file in server"; }else if(!payload.ftpPassword){ returnVal = "Please enter FTP password"; - }else if(!payload.fileName){ - returnVal = "Please enter the name of the file you want to transfer"; + }else if(!payload.savingDirectory){ + returnVal = "Please enter the location in device where you wan to save the file"; } break; default: @@ -254,10 +252,9 @@ var generatePayload = function (operationCode, operationData, deviceList) { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "ftpServerAddress": operationData["ftpServerAddress"], - "ftpUserName": operationData["ftpUserName"], + "fileURL": operationData["fileURL"], "ftpPassword": operationData["ftpPassword"], - "fileName": operationData["fileName"] + "savingDirectory": operationData["savingDirectory"] } }; break; 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.type-view/private/config.json 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.type-view/private/config.json index cf4370731..eb9c79782 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.type-view/private/config.json +++ 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.type-view/private/config.json @@ -141,15 +141,9 @@ "formParams": [ { "type": "text", - "id": "ftpServerAddress", + "id": "fileURL", "optional": false, - "label": "FTP Server Address" - }, - { - "type": "text", - "id": "ftpUserName", - "optional": false, - "label": "FTP User Name" + "label": "URL of the file to be sent" }, { "type": "password", @@ -159,9 +153,9 @@ }, { "type": "text", - "id": "fileName", + "id": "savingDirectory", "optional": false, - "label": "File Name" + "label": "Location in device to save file" } ], "permission": "/device-mgt/devices/owning-device/operations/android/file-transfer"