mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
file transfer feature
This commit is contained in:
parent
5049f17b6d
commit
118587ae6e
@ -15,7 +15,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* 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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -28,41 +28,23 @@ import java.io.Serializable;
|
|||||||
description = "This class carries all information related to file transfer operation.")
|
description = "This class carries all information related to file transfer operation.")
|
||||||
public class FileTransfer extends AndroidOperation implements Serializable {
|
public class FileTransfer extends AndroidOperation implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(name = "ftpServerAddress", value = "FTP Server Address", required = true)
|
@ApiModelProperty(name = "fileURL", value = "File URL", required = true)
|
||||||
private String ftpServerAddress;
|
private String fileURL;
|
||||||
|
|
||||||
@ApiModelProperty(name = "ftpUserName", value = "FTP User name", required = true)
|
|
||||||
private String ftpUserName;
|
|
||||||
|
|
||||||
@ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true)
|
@ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true)
|
||||||
private String ftpPassword;
|
private String ftpPassword;
|
||||||
|
|
||||||
@ApiModelProperty(name = "fileName", value = "File name", required = true)
|
@ApiModelProperty(name = "savingDirectory", value = "savingDirectory", required = true)
|
||||||
private String fileName;
|
private String savingDirectory;
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileURL() {
|
||||||
return fileName;
|
return fileURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileName(String fileName) {
|
public void setFileURL(String fileURL) {
|
||||||
this.fileName = fileName;
|
this.fileURL = fileURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFtpServerAddress() {
|
|
||||||
return ftpServerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFtpServerAddress(String ftpServerAddress) {
|
|
||||||
this.ftpServerAddress = ftpServerAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFtpUserName() {
|
|
||||||
return ftpUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFtpUserName(String ftpUserName) {
|
|
||||||
this.ftpUserName = ftpUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFtpPassword() {
|
public String getFtpPassword() {
|
||||||
return ftpPassword;
|
return ftpPassword;
|
||||||
@ -71,4 +53,12 @@ public class FileTransfer extends AndroidOperation implements Serializable {
|
|||||||
public void setFtpPassword(String ftpPassword) {
|
public void setFtpPassword(String ftpPassword) {
|
||||||
this.ftpPassword = 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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.FileTransfer;
|
||||||
|
|
||||||
import java.util.List;
|
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",
|
@ApiModel(value = "FileTransferBeanWrapper",
|
||||||
description = "FileTransfer related Information.")
|
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)
|
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||||
private List<String> deviceIDs;
|
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;
|
private FileTransfer operation;
|
||||||
|
|
||||||
public List<String> getDeviceIDs() {
|
public List<String> getDeviceIDs() {
|
||||||
|
|||||||
@ -233,9 +233,8 @@ public interface DeviceManagementAdminService {
|
|||||||
consumes = MediaType.APPLICATION_JSON,
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
httpMethod = "POST",
|
httpMethod = "POST",
|
||||||
//todo
|
//todo
|
||||||
value = "Adding a Screen Lock on Android devices",
|
value = "Transferring file to the device.",
|
||||||
notes = "Using this API you have the option of hard locking an Android device, where the Administrator " +
|
notes = "Using this API you have the option to transfer a file from FTP server to an Android device.",
|
||||||
"permanently locks the device or screen locking an Android device.",
|
|
||||||
response = Activity.class,
|
response = Activity.class,
|
||||||
tags = "Android Device Management Administrative Service",
|
tags = "Android Device Management Administrative Service",
|
||||||
extensions = {
|
extensions = {
|
||||||
@ -248,7 +247,7 @@ public interface DeviceManagementAdminService {
|
|||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 201,
|
code = 201,
|
||||||
//todo
|
//todo
|
||||||
message = "Created. \n Successfully scheduled the device lock operation.",
|
message = "File transferred.",
|
||||||
response = Activity.class,
|
response = Activity.class,
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
@ -286,11 +285,7 @@ public interface DeviceManagementAdminService {
|
|||||||
Response fileTransfer(
|
Response fileTransfer(
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "fileTransfer",
|
name = "fileTransfer",
|
||||||
//todo
|
value ="Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ",
|
||||||
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. ",
|
|
||||||
required = true) FileTransferBeanWrapper fileTransferBeanWrapper);
|
required = true) FileTransferBeanWrapper fileTransferBeanWrapper);
|
||||||
|
|
||||||
@POST
|
@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.CameraBeanWrapper;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper;
|
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.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.FileTransferBeanWrapper;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper;
|
||||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper;
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper;
|
||||||
@ -107,7 +107,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
|
|||||||
}
|
}
|
||||||
FileTransfer file = fileTransferBeanWrapper.getOperation();
|
FileTransfer file = fileTransferBeanWrapper.getOperation();
|
||||||
ProfileOperation operation = new ProfileOperation();
|
ProfileOperation operation = new ProfileOperation();
|
||||||
operation.setCode("FILE_TRANSFER");
|
operation.setCode(AndroidConstants.OperationCodes.FILE_TRANSFER);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
operation.setEnabled(true);
|
operation.setEnabled(true);
|
||||||
operation.setPayLoad(file.toJSON());
|
operation.setPayLoad(file.toJSON());
|
||||||
|
|||||||
@ -74,6 +74,7 @@ public final class AndroidConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String DEVICE_LOCK = "DEVICE_LOCK";
|
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_UNLOCK = "DEVICE_UNLOCK";
|
||||||
public static final String DEVICE_LOCATION = "DEVICE_LOCATION";
|
public static final String DEVICE_LOCATION = "DEVICE_LOCATION";
|
||||||
public static final String WIFI = "WIFI";
|
public static final String WIFI = "WIFI";
|
||||||
|
|||||||
@ -180,14 +180,12 @@ function validatePayload(operationCode, payload) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "FILE_TRANSFER":
|
case "FILE_TRANSFER":
|
||||||
if (!payload.ftpServerAddress) {
|
if (!payload.fileURL) {
|
||||||
returnVal = "Please enter FTP server address";
|
returnVal = "Please enter the URL of the file in server";
|
||||||
}else if(!payload.ftpUserName){
|
|
||||||
returnVal = "Please enter FTP user name";
|
|
||||||
}else if(!payload.ftpPassword){
|
}else if(!payload.ftpPassword){
|
||||||
returnVal = "Please enter FTP password";
|
returnVal = "Please enter FTP password";
|
||||||
}else if(!payload.fileName){
|
}else if(!payload.savingDirectory){
|
||||||
returnVal = "Please enter the name of the file you want to transfer";
|
returnVal = "Please enter the location in device where you wan to save the file";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -254,10 +252,9 @@ var generatePayload = function (operationCode, operationData, deviceList) {
|
|||||||
operationType = operationTypeConstants["PROFILE"];
|
operationType = operationTypeConstants["PROFILE"];
|
||||||
payload = {
|
payload = {
|
||||||
"operation": {
|
"operation": {
|
||||||
"ftpServerAddress": operationData["ftpServerAddress"],
|
"fileURL": operationData["fileURL"],
|
||||||
"ftpUserName": operationData["ftpUserName"],
|
|
||||||
"ftpPassword": operationData["ftpPassword"],
|
"ftpPassword": operationData["ftpPassword"],
|
||||||
"fileName": operationData["fileName"]
|
"savingDirectory": operationData["savingDirectory"]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -141,15 +141,9 @@
|
|||||||
"formParams": [
|
"formParams": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"id": "ftpServerAddress",
|
"id": "fileURL",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"label": "FTP Server Address"
|
"label": "URL of the file to be sent"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"id": "ftpUserName",
|
|
||||||
"optional": false,
|
|
||||||
"label": "FTP User Name"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "password",
|
"type": "password",
|
||||||
@ -159,9 +153,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"id": "fileName",
|
"id": "savingDirectory",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"label": "File Name"
|
"label": "Location in device to save file"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"permission": "/device-mgt/devices/owning-device/operations/android/file-transfer"
|
"permission": "/device-mgt/devices/owning-device/operations/android/file-transfer"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user