file transfer feature

revert-dabc3590
Nirothipan 7 years ago
parent 5049f17b6d
commit 118587ae6e

@ -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;
}
}

@ -19,11 +19,12 @@ 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.")
@ -32,7 +33,7 @@ public class FileTransferBeanWrapper{
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
private List<String> 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<String> getDeviceIDs() {

@ -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

@ -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());

@ -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";

@ -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;

@ -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"

Loading…
Cancel
Save