From be26b6d5c039e448629f4584475b44873708e70c Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 9 Aug 2017 15:11:19 +0530 Subject: [PATCH 01/27] adding user details --- .../analytics-view.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js index 3362ffbd0..1e722f5fa 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js @@ -28,6 +28,7 @@ function onRequest(context) { var jwtClient = jwtService.getJWTClient(); var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]); var token = ""; + var user = session.get(constants.USER_SESSION_KEY); if (encodedClientKeys) { var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"]; var resp = tokenUtil.decode(encodedClientKeys).split(":"); @@ -50,4 +51,4 @@ function onRequest(context) { } } return {"device": device, "websocketEndpoint": websocketEndpoint}; -} \ No newline at end of file +} From 704f511964a2dc1c89720e4322304a1bcfaeb4e3 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 14 Aug 2017 09:42:58 +0530 Subject: [PATCH 02/27] Adding initial file transfer feature --- .../android/bean/wrapper/FileTransfer.java | 44 +++++++++++ .../bean/wrapper/FileTransferBeanWrapper.java | 56 ++++++++++++++ .../DeviceManagementAdminService.java | 74 +++++++++++++++++++ .../DeviceManagementAdminServiceImpl.java | 58 +++++++++++---- 4 files changed, 217 insertions(+), 15 deletions(-) create mode 100644 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 create mode 100644 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 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/wrapper/FileTransfer.java new file mode 100644 index 000000000..7cca854a0 --- /dev/null +++ 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/FileTransfer.java @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +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.AndroidOperation; + +import java.io.Serializable; + + +@ApiModel(value = "FileTransfer", + description = "This class carries all information related to device lock operation.") +public class FileTransfer extends AndroidOperation implements Serializable { +//todo + @ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = false) + private String message; + @ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true) + + public String getFielLocation() { + return message; + } + + public void setFileLocation(String message) { + this.message = message; + } + + +} 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 new file mode 100644 index 000000000..4794b05d7 --- /dev/null +++ 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 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +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.DeviceLock; + +import java.util.List; + + + +/** + * This class is used to wrap the Notification bean with devices. + */ +@ApiModel(value = "FileTransferBeanWrapper", + description = "FileTransfer related Information.") +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) + private FileTransfer operation; + + public List getDeviceIDs() { + return deviceIDs; + } + + public void setDeviceIDs(List deviceIDs) { + this.deviceIDs = deviceIDs; + } + + public FileTransfer getOperation() { + return operation; + } + + public void setOperation(FileTransfer operation) { + this.operation = operation; + } + +} 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 f3c3c72b1..2a653b22c 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 @@ -216,11 +216,85 @@ import java.util.List; description = "Setting a Web Clip on Android Devices", key = "perm:android:set-webclip", permissions = {"/device-mgt/devices/owning-device/operations/android/webclip"} + ), + @Scope( + name = "File Transfer", + description = "Transferring a file to android devices", + key = "perm:android:file-transfer", + permissions = {"/device-mgt/devices/owning-device/operations/android/file-transfer"} ) } ) public interface DeviceManagementAdminService { + /////////////////////// + @POST + @Path("/file-transfer") + @ApiOperation( + 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.", + //// + response = Activity.class, + tags = "Android Device Management Administrative Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:file-transfer") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + //todo + message = "Created. \n Successfully scheduled the device lock operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while locking the device.") + }) + 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. ", + required = true) FileTransferBeanWrapper fileTransferBeanWrapper); +//////////////////////////////////// @POST @Path("/lock-devices") @ApiOperation( 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 22182b5b1..537b54372 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 @@ -43,21 +43,7 @@ import org.wso2.carbon.mdm.services.android.bean.Vpn; import org.wso2.carbon.mdm.services.android.bean.WebClip; import org.wso2.carbon.mdm.services.android.bean.Wifi; import org.wso2.carbon.mdm.services.android.bean.WipeData; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; -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.LockCodeBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; -import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.*; import org.wso2.carbon.mdm.services.android.exception.BadRequestException; import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService; @@ -87,7 +73,49 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe private static final Log log = LogFactory.getLog(DeviceManagementAdminServiceImpl.class); private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; +///////////////////////////////////////////////////////////////////////////////////// +@POST +@Path("/file-transfer") +@Override +public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android device lock operation"); + } + + try { + if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { + String errorMessage = "Lock bean is empty."; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } + FileTransfer file = fileTransferBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); + operation.setType(Operation.Type.PROFILE); + operation.setEnabled(true); + operation.setPayLoad(file.toJSON()); + return AndroidAPIUtils.getOperationResponse(fileTransferBeanWrapper.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()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } +} + + /////////////////////////////////////////////////////////// @POST @Path("/lock-devices") @Override From 7ed6552a57a869833540e27d0488cbdd2ed802d6 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Tue, 22 Aug 2017 11:25:48 +0530 Subject: [PATCH 03/27] adding form parameters --- .../android/bean/wrapper/FileTransfer.java | 36 +++++++++--- .../DeviceManagementAdminService.java | 57 ++++++++++--------- .../DeviceManagementAdminServiceImpl.java | 2 +- 3 files changed, 59 insertions(+), 36 deletions(-) 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/wrapper/FileTransfer.java index 7cca854a0..34c0baf41 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/wrapper/FileTransfer.java @@ -25,19 +25,41 @@ import java.io.Serializable; @ApiModel(value = "FileTransfer", - description = "This class carries all information related to device lock operation.") + //todo + description = "This class carries all information related to file transfer operation.") public class FileTransfer extends AndroidOperation implements Serializable { //todo - @ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = false) - private String message; - @ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true) + @ApiModelProperty(name = "file-location", value = "FTP URL of file", required = true) + private String location; + + @ApiModelProperty(name = "ftp-username", value = "FTP User name", required = true) + private String userName; + + @ApiModelProperty(name = "ftp-password", value = "FTP password", required = true) + private String password; public String getFielLocation() { - return message; + return location; + } + + public void setFileLocation(String location) { + this.location = location; + } + + public String getFtpUserName() { + return userName; + } + + public void setFtpUserName(String userName) { + this.userName = userName; + } + + public String getFtpPassword() { + return password; } - public void setFileLocation(String message) { - this.message = message; + public void setFtpPassword(String password) { + this.password = password; } 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 2a653b22c..0a510418d 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 @@ -294,7 +294,8 @@ public interface DeviceManagementAdminService { "screen lock the device." + "Multiple device IDs can be added by using comma separated values. ", required = true) FileTransferBeanWrapper fileTransferBeanWrapper); -//////////////////////////////////// + + //////////////////////////////////// @POST @Path("/lock-devices") @ApiOperation( @@ -417,7 +418,7 @@ public interface DeviceManagementAdminService { name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", required = true) - List deviceIDs); + List deviceIDs); @POST @@ -479,7 +480,7 @@ public interface DeviceManagementAdminService { name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/clear-password") @@ -537,7 +538,7 @@ public interface DeviceManagementAdminService { Response removePassword( @ApiParam(name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", - required = true) List deviceIDs); + required = true) List deviceIDs); @POST @Path("/control-camera") @@ -552,7 +553,7 @@ public interface DeviceManagementAdminService { @Extension(properties = { @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:control-camera") }) - } ) + }) @ApiResponses(value = { @ApiResponse( code = 201, @@ -599,7 +600,7 @@ public interface DeviceManagementAdminService { "camera on the device to function by defining false as the value and the ID of the Android device. " + "Multiple device IDs can be added by using comma separated values. ", required = true) - CameraBeanWrapper cameraBeanWrapper); + CameraBeanWrapper cameraBeanWrapper); @POST @Path("/info") @@ -662,7 +663,7 @@ public interface DeviceManagementAdminService { name = "deviceIds", value = "Provide the device ID of the Android device. Multiple device IDs can be added by using comma separated values.", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/logcat") @@ -697,11 +698,11 @@ public interface DeviceManagementAdminService { @ResponseHeader( name = "ETag", description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), + "Used by caches, or in conditional requests."), @ResponseHeader( name = "Last-Modified", description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), + "Used by caches, or in conditional requests.")}), @ApiResponse( code = 303, message = "See Other. \n The source can be retrieved from the URL specified in the location header.", @@ -718,7 +719,7 @@ public interface DeviceManagementAdminService { @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while adding a new device logcat operation.") + "Server error occurred while adding a new device logcat operation.") }) Response getDeviceLogcat( @ApiParam( @@ -786,7 +787,7 @@ public interface DeviceManagementAdminService { name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/wipe") @@ -847,7 +848,7 @@ public interface DeviceManagementAdminService { value = "Provide the the passcode, which is the passcode that the Android agent prompts the device owner to set at the time of device enrollment, " + "to enable the factory reset operation, and the ID of the Android device. Multiple device IDs can be added by using comma separated values. ", required = true) - WipeDataBeanWrapper wipeDataBeanWrapper); + WipeDataBeanWrapper wipeDataBeanWrapper); @POST @Path("/applications") @@ -909,9 +910,9 @@ public interface DeviceManagementAdminService { Response getApplications( @ApiParam( name = "deviceIDs", - value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values." , + value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values.", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/ring") @@ -971,7 +972,7 @@ public interface DeviceManagementAdminService { name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values.", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/reboot") @@ -1031,7 +1032,7 @@ public interface DeviceManagementAdminService { name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/mute") @@ -1091,7 +1092,7 @@ public interface DeviceManagementAdminService { name = "deviceIDs", value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", required = true) - List deviceIDs); + List deviceIDs); @POST @Path("/install-application") @@ -1155,7 +1156,7 @@ public interface DeviceManagementAdminService { " URL and name of the application, the date and time for the scheduled installation, and the ID of the " + "Android device. Multiple device IDs can be added by using comma separated values.", required = true) - ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); + ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); @POST @Path("/update-application") @@ -1220,7 +1221,7 @@ public interface DeviceManagementAdminService { "URL and name of the application, the date and time for the scheduled installation, and the ID of the" + "Android device. Multiple device IDs can be added by using comma separated values.", required = true) - ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); + ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); @POST @Path("/uninstall-application") @@ -1282,7 +1283,7 @@ public interface DeviceManagementAdminService { "URL and name of the application, the date and time for the scheduled installation, and the ID of the" + "Android device. Multiple device IDs can be added by using comma separated values.", required = true) - ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper); + ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper); @POST @Path("/blacklist-applications") @@ -1411,7 +1412,7 @@ public interface DeviceManagementAdminService { "(example: http//abc.com, http://abc.com/ota), " + "and the ID of the Android device. Multiple device IDs can be added by using comma separated values.", required = true) - UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper); + UpgradeFirmwareBeanWrapper upgradeFirmwareBeanWrapper); @POST @Path("/configure-vpn") @@ -1472,7 +1473,7 @@ public interface DeviceManagementAdminService { name = "vpnBean", value = "VPN configuration and DeviceIds", required = true) - VpnBeanWrapper vpnBeanWrapper); + VpnBeanWrapper vpnBeanWrapper); @POST @Path("/send-notification") @@ -1533,7 +1534,7 @@ public interface DeviceManagementAdminService { value = "The properties required to send a notification. Provide the message you wish to send and the ID of the " + "Android device. Multiple device IDs can be added by using comma separated values.", required = true) - NotificationBeanWrapper notificationBeanWrapper); + NotificationBeanWrapper notificationBeanWrapper); @POST @Path("/configure-wifi") @@ -1595,7 +1596,7 @@ public interface DeviceManagementAdminService { "the ssid or the name of the Wi-Fi network that you wish to configure and the ID of the Android device." + " Multiple device IDs can be added by using comma separated values.", required = true) - WifiBeanWrapper wifiBeanWrapper); + WifiBeanWrapper wifiBeanWrapper); @POST @Path("/encrypt-storage") @@ -1657,7 +1658,7 @@ public interface DeviceManagementAdminService { "true as the value or do not encrypt the storage on the device by assigning false as the value and " + "provide the ID of the Android device. Multiple device IDs can be added by using comma separated values.", required = true) - EncryptionBeanWrapper encryptionBeanWrapper); + EncryptionBeanWrapper encryptionBeanWrapper); @POST @Path("/change-lock-code") @@ -1719,7 +1720,7 @@ public interface DeviceManagementAdminService { "the ID of the Android device. Multiple device IDs can be added by using comma separated values. " + "If a passcode policy has been set in EMM, the lock code should comply to the passcode policy.\t", required = true) - LockCodeBeanWrapper lockCodeBeanWrapper); + LockCodeBeanWrapper lockCodeBeanWrapper); @POST @Path("/set-password-policy") @@ -1779,7 +1780,7 @@ public interface DeviceManagementAdminService { name = "passwordPolicy", value = "The properties required to set a password policy.", required = true) - PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); + PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); @POST @Path("/set-webclip") @@ -1839,7 +1840,7 @@ public interface DeviceManagementAdminService { name = "webClip", value = "The properties to set the web clip.", required = true) - WebClipBeanWrapper webClipBeanWrapper); + WebClipBeanWrapper webClipBeanWrapper); } 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 537b54372..3d2f96185 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 @@ -91,7 +91,7 @@ public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { } FileTransfer file = fileTransferBeanWrapper.getOperation(); ProfileOperation operation = new ProfileOperation(); - operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK); + operation.setCode("FILE_TRANSFER"); operation.setType(Operation.Type.PROFILE); operation.setEnabled(true); operation.setPayLoad(file.toJSON()); From 56384bcc530bc33ccefa589ab313c368add69db9 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Tue, 22 Aug 2017 11:51:35 +0530 Subject: [PATCH 04/27] modifying form parameters --- .../android/bean/wrapper/FileTransfer.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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/wrapper/FileTransfer.java index 34c0baf41..d11a3da56 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/wrapper/FileTransfer.java @@ -29,37 +29,37 @@ import java.io.Serializable; description = "This class carries all information related to file transfer operation.") public class FileTransfer extends AndroidOperation implements Serializable { //todo - @ApiModelProperty(name = "file-location", value = "FTP URL of file", required = true) - private String location; + @ApiModelProperty(name = "fileLocation", value = "FTP URL of file", required = true) + private String fileLocation; - @ApiModelProperty(name = "ftp-username", value = "FTP User name", required = true) - private String userName; + @ApiModelProperty(name = "ftpUserName", value = "FTP User name", required = true) + private String ftpUserName; - @ApiModelProperty(name = "ftp-password", value = "FTP password", required = true) - private String password; + @ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true) + private String ftpPassword; - public String getFielLocation() { - return location; + public String getFileLocation() { + return fileLocation; } - public void setFileLocation(String location) { - this.location = location; + public void setFileLocation(String fileLocation) { + this.fileLocation = fileLocation; } public String getFtpUserName() { - return userName; + return ftpUserName; } - public void setFtpUserName(String userName) { - this.userName = userName; + public void setFtpUserName(String ftpUserName) { + this.ftpUserName = ftpUserName; } public String getFtpPassword() { - return password; + return ftpPassword; } - public void setFtpPassword(String password) { - this.password = password; + public void setFtpPassword(String ftpPassword) { + this.ftpPassword = ftpPassword; } From ac834fbe592212b2c3d519a9d3d29c3094f70686 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 09:04:17 +0530 Subject: [PATCH 05/27] adding file Name parameter --- .../services/android/bean/wrapper/FileTransfer.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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/wrapper/FileTransfer.java index d11a3da56..c1b8c5ac9 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/wrapper/FileTransfer.java @@ -38,6 +38,18 @@ public class FileTransfer extends AndroidOperation implements Serializable { @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 String setFileName(){ + this.fileName = fileName; + } + + public String getFileLocation() { return fileLocation; } From 9432e498e989466d8223cbb8f611dc3581beef68 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 09:05:00 +0530 Subject: [PATCH 06/27] adding file Name parameter --- .../carbon/mdm/services/android/bean/wrapper/FileTransfer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/wrapper/FileTransfer.java index c1b8c5ac9..6da7462d0 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/wrapper/FileTransfer.java @@ -45,7 +45,7 @@ public class FileTransfer extends AndroidOperation implements Serializable { return fileName; } - public String setFileName(){ + public String setFileName(String fileName){ this.fileName = fileName; } From 989248e711964241090c837630b908c46cb2ec3c Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 09:05:25 +0530 Subject: [PATCH 07/27] adding file Name parameter --- .../carbon/mdm/services/android/bean/wrapper/FileTransfer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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/wrapper/FileTransfer.java index 6da7462d0..4ed253b41 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/wrapper/FileTransfer.java @@ -45,7 +45,7 @@ public class FileTransfer extends AndroidOperation implements Serializable { return fileName; } - public String setFileName(String fileName){ + public void setFileName(String fileName){ this.fileName = fileName; } From d1c4a1be121f85582c1e77dace143ddb79ea7862 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 12:09:13 +0530 Subject: [PATCH 08/27] addinf file transfer operation UI --- .../operation-bar.hbs | 6 ++++ .../public/js/operation-bar.js | 13 +++++++- .../private/config.json | 31 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) 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 8cf7a0d74..d312f51ea 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 @@ -102,6 +102,12 @@ {{this.label}}
{{/equal}} + {{#equal this.type "password"}} + +
+ {{/equal}} {{#equal this.type "text"}} Date: Thu, 24 Aug 2017 12:10:29 +0530 Subject: [PATCH 09/27] addinf file transfer operation UI --- .../private/config.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 fc8e6656d..a31fc5cf9 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 @@ -143,8 +143,7 @@ "id": "fileLocation", "optional": false, "label": "FTP Server Address" - } - , + }, { "type": "text", "id": "ftpUserName", From 4234bcf482fb5bf2021870061597c260a1653485 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 12:12:35 +0530 Subject: [PATCH 10/27] addinf file transfer operation UI --- .../public/js/operation-bar.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 a97d78813..e07977b26 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 @@ -239,7 +239,7 @@ var generatePayload = function (operationCode, operationData, deviceList) { } }; break; - case "FILE_TRANSFER": + case androidOperationConstants["FILE_TRANSFER"]: operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { @@ -444,5 +444,6 @@ var androidOperationConstants = { "SET_STATUS_BAR_DISABLED": "SET_STATUS_BAR_DISABLED", "APPLICATION_OPERATION_CODE": "APP-RESTRICTION", "SYSTEM_UPDATE_POLICY_CODE": "SYSTEM_UPDATE_POLICY", - "KIOSK_APPS_CODE": "KIOSK_APPS" + "KIOSK_APPS_CODE": "KIOSK_APPS", + "FILE_TRANSFER": "FILE_TRANSFER" }; From 8ce3b6a8c36f2809d0031a18fc00416f0d34b349 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 12:21:19 +0530 Subject: [PATCH 11/27] code formatting --- .../android/bean/wrapper/FileTransfer.java | 23 ++++++++----------- .../bean/wrapper/FileTransferBeanWrapper.java | 3 --- 2 files changed, 10 insertions(+), 16 deletions(-) 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/wrapper/FileTransfer.java index 4ed253b41..9aa5b5fa0 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/wrapper/FileTransfer.java @@ -25,12 +25,11 @@ import java.io.Serializable; @ApiModel(value = "FileTransfer", - //todo description = "This class carries all information related to file transfer operation.") public class FileTransfer extends AndroidOperation implements Serializable { -//todo - @ApiModelProperty(name = "fileLocation", value = "FTP URL of file", required = true) - private String fileLocation; + + @ApiModelProperty(name = "ftpServerAddress", value = "FTP Server Address", required = true) + private String ftpServerAddress; @ApiModelProperty(name = "ftpUserName", value = "FTP User name", required = true) private String ftpUserName; @@ -41,21 +40,20 @@ public class FileTransfer extends AndroidOperation implements Serializable { @ApiModelProperty(name = "fileName", value = "File name", required = true) private String fileName; - public String getFileName(){ + public String getFileName() { return fileName; } - public void setFileName(String fileName){ + public void setFileName(String fileName) { this.fileName = fileName; } - - public String getFileLocation() { - return fileLocation; + public String getFtpServerAddress() { + return ftpServerAddress; } - public void setFileLocation(String fileLocation) { - this.fileLocation = fileLocation; + public void setFtpServerAddress(String ftpServerAddress) { + this.ftpServerAddress = ftpServerAddress; } public String getFtpUserName() { @@ -73,6 +71,5 @@ public class FileTransfer extends AndroidOperation implements Serializable { public void setFtpPassword(String ftpPassword) { this.ftpPassword = ftpPassword; } - - } + 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 4794b05d7..8fe429e1c 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,12 +19,9 @@ 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.DeviceLock; import java.util.List; - - /** * This class is used to wrap the Notification bean with devices. */ From a90658b5e7443121b845c1575bb25e3138901ddb Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 12:29:09 +0530 Subject: [PATCH 12/27] code formatting --- .../android/bean/wrapper/FileTransfer.java | 1 - .../bean/wrapper/FileTransferBeanWrapper.java | 1 + .../DeviceManagementAdminService.java | 3 - .../DeviceManagementAdminServiceImpl.java | 72 +++++++++---------- 4 files changed, 36 insertions(+), 41 deletions(-) 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/wrapper/FileTransfer.java index 9aa5b5fa0..099cd8d86 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/wrapper/FileTransfer.java @@ -72,4 +72,3 @@ public class FileTransfer extends AndroidOperation implements Serializable { this.ftpPassword = ftpPassword; } } - 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 8fe429e1c..64ce960fa 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 @@ -31,6 +31,7 @@ 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) private FileTransfer operation; 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 0a510418d..f745c2489 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 @@ -227,7 +227,6 @@ import java.util.List; ) public interface DeviceManagementAdminService { - /////////////////////// @POST @Path("/file-transfer") @ApiOperation( @@ -237,7 +236,6 @@ public interface DeviceManagementAdminService { 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.", - //// response = Activity.class, tags = "Android Device Management Administrative Service", extensions = { @@ -295,7 +293,6 @@ public interface DeviceManagementAdminService { "Multiple device IDs can be added by using comma separated values. ", required = true) FileTransferBeanWrapper fileTransferBeanWrapper); - //////////////////////////////////// @POST @Path("/lock-devices") @ApiOperation( 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 3d2f96185..d497e51bb 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 @@ -73,49 +73,47 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe private static final Log log = LogFactory.getLog(DeviceManagementAdminServiceImpl.class); private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; -///////////////////////////////////////////////////////////////////////////////////// -@POST -@Path("/file-transfer") -@Override -public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android device lock operation"); - } - try { - if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { - String errorMessage = "Lock bean is empty."; - log.error(errorMessage); + @POST + @Path("/file-transfer") + @Override + public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android file transfer operation"); + } + + try { + if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { + String errorMessage = "Lock bean is empty."; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } + FileTransfer file = fileTransferBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode("FILE_TRANSFER"); + operation.setType(Operation.Type.PROFILE); + operation.setEnabled(true); + operation.setPayLoad(file.toJSON()); + return AndroidAPIUtils.getOperationResponse(fileTransferBeanWrapper.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()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); } - FileTransfer file = fileTransferBeanWrapper.getOperation(); - ProfileOperation operation = new ProfileOperation(); - operation.setCode("FILE_TRANSFER"); - operation.setType(Operation.Type.PROFILE); - operation.setEnabled(true); - operation.setPayLoad(file.toJSON()); - return AndroidAPIUtils.getOperationResponse(fileTransferBeanWrapper.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()); - } catch (OperationManagementException e) { - String errorMessage = "Issue in retrieving operation management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); - } catch (DeviceManagementException e) { - String errorMessage = "Issue in retrieving device management service instance"; - log.error(errorMessage, e); - throw new UnexpectedServerErrorException( - new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); } -} - - /////////////////////////////////////////////////////////// @POST @Path("/lock-devices") @Override From 939a770c298fe2551d4155c8021f198f7f97cbf0 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 15:57:32 +0530 Subject: [PATCH 13/27] replacing with single imports --- .../impl/DeviceManagementAdminServiceImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 d497e51bb..a02060771 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 @@ -43,7 +43,23 @@ import org.wso2.carbon.mdm.services.android.bean.Vpn; import org.wso2.carbon.mdm.services.android.bean.WebClip; import org.wso2.carbon.mdm.services.android.bean.Wifi; import org.wso2.carbon.mdm.services.android.bean.WipeData; -import org.wso2.carbon.mdm.services.android.bean.wrapper.*; +import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; +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.wrapper.FileTransferBeanWrapper; +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.PasswordPolicyBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; import org.wso2.carbon.mdm.services.android.exception.BadRequestException; import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService; From 95f25ad9cb0b81db699c2ea9e48be5f9768365e7 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 24 Aug 2017 15:57:58 +0530 Subject: [PATCH 14/27] changinh variable name more meaningful --- .../public/js/operation-bar.js | 2 +- .../cdmf.unit.device.type.android.type-view/private/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 e07977b26..6e59ead6a 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 @@ -243,7 +243,7 @@ var generatePayload = function (operationCode, operationData, deviceList) { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "fileLocation": operationData["fileLocation"], + "ftpServerAddress": operationData["ftpServerAddress"], "ftpUserName": operationData["ftpUserName"], "ftpPassword": operationData["ftpPassword"], "fileName": operationData["fileName"] 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 a31fc5cf9..9ea5c964a 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 @@ -140,7 +140,7 @@ "formParams": [ { "type": "text", - "id": "fileLocation", + "id": "ftpServerAddress", "optional": false, "label": "FTP Server Address" }, From 5049f17b6dbb18d0739b0dcf839c81852cd5cdae Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 28 Aug 2017 13:33:10 +0530 Subject: [PATCH 15/27] androif file transfer feature --- .../public/js/operation-bar.js | 13 ++++++++++++- .../private/config.json | 3 ++- .../src/main/resources/devicetypes/android.xml | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) 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 6e59ead6a..877e066fa 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 @@ -53,7 +53,7 @@ function submitForm(formId) { } else if (input.data("param-type") == "form") { var prefix = (uriencodedFormStr == "") ? "" : "&"; uriencodedFormStr += prefix + input.attr("id") + "=" + input.val(); - if (input.attr("type") == "text") { + if (input.attr("type") == "text" || input.attr("type") == "password") { payload[input.attr("id")] = input.val(); } else if (input.attr("type") == "checkbox") { payload[input.attr("id")] = input.is(":checked"); @@ -179,6 +179,17 @@ function validatePayload(operationCode, payload) { returnVal = "Message Body Can't be empty !"; } break; + case "FILE_TRANSFER": + if (!payload.ftpServerAddress) { + returnVal = "Please enter FTP server address"; + }else if(!payload.ftpUserName){ + returnVal = "Please enter FTP user name"; + }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"; + } + break; default: 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 9ea5c964a..cf4370731 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 @@ -6,6 +6,7 @@ "analyticsEnabled": "false", "groupingEnabled": "false", "scopes" : [ + "perm:android:file-transfer", "perm:android:enroll", "perm:android:wipe", "perm:android:ring", @@ -136,7 +137,7 @@ "permission": "/device-mgt/devices/owning-device/operations/android/enterprise-wipe" }, "FILE_TRANSFER": { - "icon": "fw-block", + "icon": "fw-save", "formParams": [ { "type": "text", diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml index 00084f14f..a60016378 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -87,6 +87,12 @@ + + File Transfer + Transfer file to the device + + + Ring Ring the device @@ -380,4 +386,4 @@ 900 600 - \ No newline at end of file + From 118587ae6e321020cb00c84a4345c80bbca73ee7 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 6 Sep 2017 13:39:51 +0530 Subject: [PATCH 16/27] file transfer feature --- .../bean/{wrapper => }/FileTransfer.java | 44 +++++++------------ .../bean/wrapper/FileTransferBeanWrapper.java | 7 +-- .../DeviceManagementAdminService.java | 13 ++---- .../DeviceManagementAdminServiceImpl.java | 4 +- .../android/util/AndroidConstants.java | 1 + .../public/js/operation-bar.js | 15 +++---- .../private/config.json | 14 ++---- 7 files changed, 38 insertions(+), 60 deletions(-) rename 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 (60%) 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" From 85752584bb3adf652e335ff3ebb22f90fc1a08d1 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 7 Sep 2017 12:09:54 +0530 Subject: [PATCH 17/27] modifying messages --- .../android/services/impl/DeviceManagementAdminServiceImpl.java | 2 +- .../cdmf.unit.device.type.android.type-view/private/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 22a12b4bf..2cb381275 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 @@ -35,6 +35,7 @@ import org.wso2.carbon.mdm.services.android.bean.Camera; import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; import org.wso2.carbon.mdm.services.android.bean.DeviceLock; import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; +import org.wso2.carbon.mdm.services.android.bean.FileTransfer; import org.wso2.carbon.mdm.services.android.bean.LockCode; import org.wso2.carbon.mdm.services.android.bean.Notification; import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; @@ -50,7 +51,6 @@ 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.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; 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 eb9c79782..81caeadfd 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 @@ -143,7 +143,7 @@ "type": "text", "id": "fileURL", "optional": false, - "label": "URL of the file to be sent" + "label": "FTP URL of the file to be sent" }, { "type": "password", From 80941b8d2b4252d572fa7bb98501ae2a7908c923 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 7 Sep 2017 12:29:59 +0530 Subject: [PATCH 18/27] making error messages more meaningful --- .../android/bean/wrapper/FileTransferBeanWrapper.java | 2 +- .../android/services/DeviceManagementAdminService.java | 1 - .../impl/DeviceManagementAdminServiceImpl.java | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) 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 810cb6a22..54accca6f 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,7 +30,7 @@ import java.util.List; description = "FileTransfer related Information.") 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 to which the operation to be executed.", required = true) private List deviceIDs; @ApiModelProperty(name = "operation", value = "Information of the File Transfer Operation.", required = true) 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 a672d1cc3..b0e8f80db 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 @@ -232,7 +232,6 @@ public interface DeviceManagementAdminService { @ApiOperation( consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", - //todo 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, 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 2cb381275..033899260 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 @@ -95,12 +95,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe @Override public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { if (log.isDebugEnabled()) { - log.debug("Invoking Android file transfer operation"); + log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); } try { if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { - String errorMessage = "Lock bean is empty."; + String errorMessage = "The payload of the file transfer operation is incorrect."; log.error(errorMessage); throw new BadRequestException( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); @@ -113,17 +113,17 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe operation.setPayLoad(file.toJSON()); return AndroidAPIUtils.getOperationResponse(fileTransferBeanWrapper.getDeviceIDs(), operation); } catch (InvalidDeviceException e) { - String errorMessage = "Invalid Device Identifiers found."; + String errorMessage = "Invalid Device Identifiers ( " + fileTransferBeanWrapper.getDeviceIDs() + " ) 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"; + String errorMessage = "Issue in retrieving operation management service instance for file transfer operation"; log.error(errorMessage, e); throw new UnexpectedServerErrorException( new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); } catch (DeviceManagementException e) { - String errorMessage = "Issue in retrieving device management service instance"; + String errorMessage = "Issue in retrieving device management service instance for file transfer operation"; log.error(errorMessage, e); throw new UnexpectedServerErrorException( new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); From c9bac2c8603300a164e28c7f0b6aca784ba9ccfa Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 11 Sep 2017 13:10:42 +0530 Subject: [PATCH 19/27] fileTransferfeature, uploading files from device to ftp server --- .../services/android/bean/FileTransfer.java | 16 +++++---- .../bean/wrapper/FileTransferBeanWrapper.java | 12 ++++++- .../DeviceManagementAdminServiceImpl.java | 24 +++++++------ .../android/util/AndroidConstants.java | 3 +- .../operation-bar.hbs | 22 ++++++++++++ .../public/js/operation-bar.js | 34 +++++++++++++++---- .../private/config.json | 14 ++++++-- 7 files changed, 96 insertions(+), 29 deletions(-) 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 a56cdf135..e4488952d 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 54accca6f..851a90a47 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 033899260..7974f00cb 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 b115af698..676ef4f4d 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 d312f51ea..ffe4691df 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"}} Date: Tue, 12 Sep 2017 17:05:08 +0530 Subject: [PATCH 20/27] changing operation names --- .../carbon/mdm/services/android/util/AndroidConstants.java | 4 ++-- .../private/config.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 676ef4f4d..b92afb97e 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,8 +74,8 @@ public final class AndroidConstants { } public static final String DEVICE_LOCK = "DEVICE_LOCK"; - 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 FILE_DOWNLOAD = "FILE_UPLOAD"; + public static final String FILE_UPLOAD = "FILE_DOWNLOAD"; 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.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 f3cf7a1ca..63fcf74c2 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 @@ -144,8 +144,8 @@ "name": "selection", "id": "upload", "optional": false, - "yesValue": "Upload by the Device", - "noValue": "Upload to the Device" + "yesValue": "FILE DOWNLOAD", + "noValue": "FILE UPLOAD" }, { "type": "text", From a79580b8acbe3fdc3e9f7f032682aed7998fa107 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Tue, 19 Sep 2017 18:59:51 +0530 Subject: [PATCH 21/27] code formatting --- .../android/bean/wrapper/FileTransferBeanWrapper.java | 3 ++- .../android/services/DeviceManagementAdminService.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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 851a90a47..d34b00e66 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 @@ -33,7 +33,8 @@ public class FileTransferBeanWrapper { @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) + @ApiModelProperty(name = "upload", value = "Upload / Download w.r.t device.", + notes = "upload = true , If file is to be uploaded to the device.", required = true) private boolean upload; @ApiModelProperty(name = "operation", value = "Information of the File Transfer Operation.", required = true) 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 b0e8f80db..90fd3e877 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 @@ -279,12 +279,12 @@ public interface DeviceManagementAdminService { @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while locking the device.") + "Server error occurred while file transfer operation.") }) Response fileTransfer( @ApiParam( name = "fileTransfer", - 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. Multiple device IDs can be added by using comma separated values.", required = true) FileTransferBeanWrapper fileTransferBeanWrapper); @POST From 2ddfbed6db8a1d209bcba3b7822b4bca0bd84ee8 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 21 Sep 2017 14:05:30 +0530 Subject: [PATCH 22/27] changing variable names --- .../mdm/services/android/util/AndroidConstants.java | 4 ++-- .../public/js/operation-bar.js | 8 +++----- .../private/config.json | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) 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 b92afb97e..3a93305bd 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,8 +74,8 @@ public final class AndroidConstants { } public static final String DEVICE_LOCK = "DEVICE_LOCK"; - public static final String FILE_DOWNLOAD = "FILE_UPLOAD"; - public static final String FILE_UPLOAD = "FILE_DOWNLOAD"; + public static final String FILE_DOWNLOAD = "FILE_UPLOAD_TO_THE_DEVICE"; + public static final String FILE_UPLOAD = "FILE_DOWNLOAD_FROM_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/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 59302a67f..aebf833f0 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 @@ -37,7 +37,7 @@ function changeLabel(type) { if (type == "no") { $(".modal #operation-warn-msg span").text("File will be saved in default location if not specified."); $(".modal #operation-warn-msg").removeClass("hidden"); - document.getElementById('fileURL').placeholder = "FTP URL of the file"; + document.getElementById('fileURL').placeholder = "HTTP/FTP URL of the file"; document.getElementById('fileLocation').placeholder = "Location to save file in device"; } else { $(".modal #operation-warn-msg").addClass("hidden"); @@ -197,13 +197,11 @@ function validatePayload(operationCode, payload) { break; case "FILE_TRANSFER": if (payload.upload && !payload.fileURL) { - returnVal = "Please enter the FTP URL of the file"; + returnVal = "Please enter the URL of the file"; } else if (!payload.upload && !payload.fileURL) { returnVal = "Please enter the FTP URL of the folder to upload file"; } - else if (!payload.ftpPassword) { - returnVal = "Please enter FTP password"; - } else if (!payload.upload && !payload.fileLocation) { + else if (!payload.upload && !payload.fileLocation) { returnVal = "Please specify the file location in device"; } 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 63fcf74c2..05b8e1432 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 @@ -157,7 +157,7 @@ "type": "password", "id": "ftpPassword", "optional": false, - "label": "FTP Password" + "label": "Password (Ignore if you don't need any)" }, { "type": "text", From cff69459bed7fda04bb4f41b310c5aa561cc2d50 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Thu, 21 Sep 2017 17:18:57 +0530 Subject: [PATCH 23/27] code formatting and updating comments, descriptions --- .../services/android/bean/FileTransfer.java | 1 - .../DeviceManagementAdminService.java | 7 ++++--- .../DeviceManagementAdminServiceImpl.java | 21 +++++++++---------- .../public/js/operation-bar.js | 5 +++++ 4 files changed, 19 insertions(+), 15 deletions(-) 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 e4488952d..0ecf3d4fe 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 @@ -47,7 +47,6 @@ public class FileTransfer extends AndroidOperation implements Serializable { this.fileURL = fileURL; } - public String getFtpPassword() { return ftpPassword; } 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 90fd3e877..c8bd68d9c 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,7 +233,8 @@ public interface DeviceManagementAdminService { consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", 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.", + notes = "Using this API you have the option to transfer a file from SFTP/FTP server or using an " + + "HTTP link to the device or retrieve file from the device to FTP/SFTP server .", response = Activity.class, tags = "Android Device Management Administrative Service", extensions = { @@ -245,7 +246,6 @@ public interface DeviceManagementAdminService { @ApiResponses(value = { @ApiResponse( code = 201, - //todo message = "File transferred.", response = Activity.class, responseHeaders = { @@ -284,7 +284,8 @@ public interface DeviceManagementAdminService { Response fileTransfer( @ApiParam( name = "fileTransfer", - 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. 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 7974f00cb..6fa0d1fd2 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 @@ -94,17 +94,16 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe @Path("/file-transfer") @Override public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { - if (log.isDebugEnabled()) { - log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); - } - - try { - if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the file transfer operation is incorrect."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } + try { + if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the file transfer operation is incorrect."; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } + if (fileTransferBeanWrapper.getDeviceIDs() != null && log.isDebugEnabled()) { + log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); + } FileTransfer file = fileTransferBeanWrapper.getOperation(); ProfileOperation operation = new ProfileOperation(); if (fileTransferBeanWrapper.isUpload()) { 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 aebf833f0..ea8c424da 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 @@ -32,6 +32,11 @@ var resetLoader = function () { $('#lbl-execution').addClass("hidden"); }; +/** + * This changes the text box label when the operation is toggled between FILE UPLOAD and FILE DOWNLOAD + * and shows an info label for FILE UPLOAD regarding saving location. + * @param type + */ function changeLabel(type) { $(".modal #operation-error-msg").addClass("hidden"); if (type == "no") { From d217a728518e60baccaba54184b3ce0249eadcbc Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Tue, 3 Oct 2017 13:53:01 +0530 Subject: [PATCH 24/27] adding userName parameter to API --- .../services/android/bean/FileTransfer.java | 11 +++++++ .../DeviceManagementAdminServiceImpl.java | 23 ++++++++------- .../public/js/operation-bar.js | 29 +++++++++++++++++-- .../private/config.json | 10 +++++-- 4 files changed, 57 insertions(+), 16 deletions(-) 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 0ecf3d4fe..2e8af23a7 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 @@ -33,6 +33,9 @@ public class FileTransfer extends AndroidOperation implements Serializable { @ApiModelProperty(name = "fileURL", value = "File URL", required = true) private String fileURL; + @ApiModelProperty(name = "userName", value = "User Name", required = true) + private String userName; + @ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true) private String ftpPassword; @@ -62,4 +65,12 @@ public class FileTransfer extends AndroidOperation implements Serializable { public void setFileLocation(String fileLocation) { this.fileLocation = fileLocation; } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } } 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 6fa0d1fd2..eb25d917b 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 @@ -94,16 +94,17 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe @Path("/file-transfer") @Override public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { - try { - if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { - String errorMessage = "The payload of the file transfer operation is incorrect."; - log.error(errorMessage); - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); - } - if (fileTransferBeanWrapper.getDeviceIDs() != null && log.isDebugEnabled()) { - log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); - } + try { + if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null + || fileTransferBeanWrapper.getDeviceIDs() == null) { + String errorMessage = "The payload of the file transfer operation is incorrect."; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } + if (log.isDebugEnabled()) { + log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); + } FileTransfer file = fileTransferBeanWrapper.getOperation(); ProfileOperation operation = new ProfileOperation(); if (fileTransferBeanWrapper.isUpload()) { @@ -1105,7 +1106,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } } - private static void validateScheduleDate(String dateString){ + private static void validateScheduleDate(String dateString) { try { if (dateString != null && !dateString.isEmpty()) { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); 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 ea8c424da..8d7b74d77 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 @@ -24,6 +24,9 @@ function operationSelect(selection) { $(modalPopupContent).addClass("operation-data"); $(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html()); $(modalPopupContent).data("operation-code", selection); + if (selection === "FILE_TRANSFER") { + fillUserName(); + } showPopup(); } @@ -32,6 +35,24 @@ var resetLoader = function () { $('#lbl-execution').addClass("hidden"); }; +function fillUserName() { + var inputBox = document.getElementById('fileURL'); + var regexp = ':\/\/[^\/]*@'; + var pattern = new RegExp(regexp); + jQuery(inputBox).on('input', function () { + var fileUrl = inputBox.value; + var res = pattern.test(fileUrl); + if (res) { + var name = fileUrl.match(regexp).toString(); + document.getElementById('userName').value = name.substring(3, name.length - 1); + } else { + document.getElementById('userName').value = ""; + document.getElementById('userName').placeholder = "User Name" + } + } + ); +} + /** * This changes the text box label when the operation is toggled between FILE UPLOAD and FILE DOWNLOAD * and shows an info label for FILE UPLOAD regarding saving location. @@ -42,13 +63,14 @@ function changeLabel(type) { if (type == "no") { $(".modal #operation-warn-msg span").text("File will be saved in default location if not specified."); $(".modal #operation-warn-msg").removeClass("hidden"); - document.getElementById('fileURL').placeholder = "HTTP/FTP URL of the file"; + document.getElementById('fileURL').placeholder = "File URL"; document.getElementById('fileLocation').placeholder = "Location to save file in device"; } else { $(".modal #operation-warn-msg").addClass("hidden"); - document.getElementById('fileURL').placeholder = "FTP URL of the folder to upload file"; + document.getElementById('fileURL').placeholder = "URL for file upload"; document.getElementById('fileLocation').placeholder = "File location in the device"; } + fillUserName(); } function submitForm(formId) { @@ -97,7 +119,7 @@ function submitForm(formId) { var defaultStatusClasses = "fw fw-stack-1x"; var content = $("#operation-response-template").find(".content"); var title = content.find("#title"); - title.attr("class","center-block text-center"); + title.attr("class", "center-block text-center"); var statusIcon = content.find("#status-icon"); var description = content.find("#description"); description.html(""); @@ -275,6 +297,7 @@ var generatePayload = function (operationCode, operationData, deviceList) { payload = { "operation": { "fileURL": operationData["fileURL"], + "userName": operationData["userName"], "ftpPassword": operationData["ftpPassword"], "fileLocation": operationData["fileLocation"] }, 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 05b8e1432..de5969c5c 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 @@ -151,13 +151,19 @@ "type": "text", "id": "fileURL", "optional": false, - "label": "FTP URL of the folder to upload file" + "label": "URL for file upload" + }, + { + "type": "text", + "id": "userName", + "optional": false, + "label": "User Name (Ignore if you don't need authentication.)" }, { "type": "password", "id": "ftpPassword", "optional": false, - "label": "Password (Ignore if you don't need any)" + "label": "Password (Ignore if you don't need authentication.)" }, { "type": "text", From 5aea03c66fc29ec37126f42cd42d472ff4ec93d2 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 18 Oct 2017 11:31:54 +0530 Subject: [PATCH 25/27] reordering operations --- .../src/main/resources/devicetypes/android.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml index a60016378..2938ffaa8 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -87,12 +87,6 @@ - - File Transfer - Transfer file to the device - - - Ring Ring the device @@ -147,6 +141,12 @@ + + File Transfer + Transfer file to the device + + + Enterprise Wipe Remove enterprise applications From d428901b2227df7fbd5fcfc238855232e8a19930 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 18 Oct 2017 11:54:03 +0530 Subject: [PATCH 26/27] ui-improvements --- .../operation-bar.hbs | 33 +++-- .../public/js/operation-bar.js | 115 +++++++++++++----- .../private/config.json | 52 ++++++-- 3 files changed, 146 insertions(+), 54 deletions(-) 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 c257d886e..d61c6331e 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 @@ -98,23 +98,23 @@
{{/each}} {{#each uiParams}} - {{#equal this.type "bi-radio"}} - - {{this.yesValue}} + {{#equal this.type "select"}} +
+ +
+ {{/equal}} + {{#equal this.type "radio"}} - {{this.noValue}} -

+ {{this.value}} {{/equal}} {{#equal this.type "checkbox"}}
{{/equal}} + {{#equal this.type "info"}} +
+ + + {{this.value}} + +
+ {{/equal}} {{/each}}