From c5bb7696984305013f196801f82d8e14743d3b85 Mon Sep 17 00:00:00 2001 From: shamalka Date: Fri, 13 Dec 2019 11:54:30 +0530 Subject: [PATCH] Remove unused imports --- .../impl/DeviceManagementAdminAPIImpl.java | 34 ---------- .../api/impl/EventReceiverAPIImpl.java | 21 +----- .../android/common/spi/AndroidService.java | 6 +- .../android/core/impl/AndroidServiceImpl.java | 64 +++++++++++-------- 4 files changed, 40 insertions(+), 85 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java index 4e18c9cc2..28d8da123 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/DeviceManagementAdminAPIImpl.java @@ -38,36 +38,12 @@ package org.wso2.carbon.device.mgt.mobile.android.api.impl; import com.google.api.client.http.HttpStatusCodes; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.device.mgt.mobile.android.api.DeviceManagementAdminAPI; -import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationInstallation; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationRestriction; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUninstallation; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.ApplicationUpdate; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.BlacklistApplications; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.Camera; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceEncryption; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceLock; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.DisplayMessage; import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.FileTransfer; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.GlobalProxy; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.LockCode; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.Notification; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.PasscodePolicy; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.UpgradeFirmware; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.Vpn; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.WebClip; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.Wifi; -import org.wso2.carbon.device.mgt.mobile.android.common.bean.WipeData; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationInstallationBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationRestrictionBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUninstallationBeanWrapper; @@ -89,10 +65,8 @@ import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WifiBeanWra import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.WipeDataBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; import org.wso2.carbon.device.mgt.mobile.android.common.exception.BadRequestExceptionDup; -import org.wso2.carbon.device.mgt.mobile.android.common.exception.UnexpectedServerErrorExceptionDup; import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; -import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; import javax.validation.Valid; import javax.ws.rs.Consumes; @@ -101,13 +75,6 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.List; @Path("/admin/devices") @@ -116,7 +83,6 @@ import java.util.List; public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI { private static final Log log = LogFactory.getLog(DeviceManagementAdminAPIImpl.class); - private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; @POST @Path("/file-transfer") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java index f9dce18a7..438a31f4e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/device/mgt/mobile/android/api/impl/EventReceiverAPIImpl.java @@ -20,18 +20,10 @@ package org.wso2.carbon.device.mgt.mobile.android.api.impl; import com.google.api.client.http.HttpStatusCodes; import com.google.gson.Gson; -import com.google.gson.JsonObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.device.mgt.mobile.android.api.EventReceiverAPI; -import org.wso2.carbon.device.mgt.mobile.android.common.AndroidConstants; import org.wso2.carbon.device.mgt.mobile.android.common.Message; import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState; import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; @@ -39,7 +31,6 @@ import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.EventBeanWr import org.wso2.carbon.device.mgt.mobile.android.common.exception.*; import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; -import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils; import javax.validation.Valid; import javax.validation.constraints.Size; @@ -53,18 +44,8 @@ import java.util.List; @Path("/events") public class EventReceiverAPIImpl implements EventReceiverAPI { - private static final String EVENT_STREAM_DEFINITION = "org.wso2.iot.LocationStream"; - private static final Log log = LogFactory.getLog(EventReceiverAPIImpl.class); - private Gson gson = new Gson(); - private static final String LONGITUDE = "longitude"; - private static final String LATITUDE = "latitude"; - private static final String ALTITUDE = "altitude"; - private static final String SPEED = "speed"; - private static final String DISTANCE = "distance"; - private static final String BEARING = "bearing"; - private static final String TIME_STAMP = "timeStamp"; - private static final String LOCATION_EVENT_TYPE = "location"; + private static final Log log = LogFactory.getLog(EventReceiverAPIImpl.class); @POST @Path("/publish") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java index 733144167..9467460ef 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/spi/AndroidService.java @@ -43,7 +43,7 @@ public interface AndroidService { * Method to retrieve platform configurations * * @return {@link PlatformConfiguration} - * @throws {@link DeviceManagementException} + * @throws {@link DeviceManagementException} If some unusual behaviour is observed while getting platform configurations */ PlatformConfiguration getPlatformConfig() throws DeviceManagementException; @@ -62,7 +62,7 @@ public interface AndroidService { * @param fileTransferBeanWrapper * @return {@link Activity} * @throws {@link AndroidDeviceMgtPluginException} - * @throws {@link OperationManagementException} + * @throws {@link OperationManagementException} If some unusual behaviour is observed while executing file transfer operation */ Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) throws AndroidDeviceMgtPluginException, OperationManagementException; @@ -73,7 +73,7 @@ public interface AndroidService { * @param deviceLockBeanWrapper * @return {@link Activity} * @throws {@link AndroidDeviceMgtPluginException} - * @throws {@link OperationManagementException} + * @throws {@link OperationManagementException} If some unusual behaviour is observed while executing device lock operation */ Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) throws OperationManagementException, AndroidDeviceMgtPluginException; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java index f45cf6cf0..1e1c9d06d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/main/java/org/wso2/carbon/device/mgt/mobile/android/core/impl/AndroidServiceImpl.java @@ -28,6 +28,7 @@ import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; + import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; @@ -67,8 +68,6 @@ import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidEnterpriseUtil import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; - -import javax.ws.rs.core.Response; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -889,7 +888,8 @@ public class AndroidServiceImpl implements AndroidService { @Override - public Message updateApplicationList(String id, List androidApplications) throws org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { + public Message updateApplicationList(String id, List androidApplications) + throws org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { Application application; List applications = new ArrayList<>(); for (AndroidApplication androidApplication : androidApplications) { @@ -932,26 +932,7 @@ public class AndroidServiceImpl implements AndroidService { log.debug("Invoking Android pending operations:" + deviceId); } if (resultOperations != null && !resultOperations.isEmpty()) { - for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : resultOperations) { - AndroidDeviceUtils.updateOperation(deviceId, operation); - if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) { - org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); - DeviceIdentifier id = new DeviceIdentifier(); - id.setId(deviceId); - id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); - String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName(); - notification.setOperationId(operation.getId()); - notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. - Status.NEW.toString()); - notification.setDescription( - operation.getCode() + " operation failed to execute on device " + deviceName + " (ID: " - + deviceId + ")"); - AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification); - } - if (log.isDebugEnabled()) { - log.debug("Updating operation '" + operation.toString() + "'"); - } - } + updateOperations(deviceId, resultOperations); } } catch (OperationManagementException e) { String msg = "Issue in retrieving operation management service instance"; @@ -961,12 +942,12 @@ public class AndroidServiceImpl implements AndroidService { String msg = "Issue in updating Monitoring operation"; log.error(msg, e); throw new DeviceManagementException(msg, e); - } catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) { - String msg = "Issue in retrieving application management service instance"; + } catch (NotificationManagementException e) { + String msg = "Issue in retrieving Notification management service instance"; log.error(msg, e); throw new DeviceManagementException(msg, e); - } catch (NotificationManagementException e) { - String msg = "Issue in retrieving Notification management service instance"; + } catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) { + String msg = "Issue in retrieving application management service instance"; log.error(msg, e); throw new DeviceManagementException(msg, e); } @@ -979,6 +960,32 @@ public class AndroidServiceImpl implements AndroidService { } } + private void updateOperations(String deviceId, List operations) + throws OperationManagementException, PolicyComplianceException, NotificationManagementException, + DeviceManagementException, org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { + for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) { + AndroidDeviceUtils.updateOperation(deviceId, operation); + if (OPERATION_ERROR_STATUS.equals(operation.getStatus().toString())) { + org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new + org.wso2.carbon.device.mgt.common.notification.mgt.Notification(); + DeviceIdentifier id = new DeviceIdentifier(); + id.setId(deviceId); + id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); + String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName(); + notification.setOperationId(operation.getId()); + notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. + Status.NEW.toString()); + notification.setDescription(operation.getCode() + " operation failed to execute on device " + + deviceName + " (ID: " + deviceId + ")"); + AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification); + } + if (log.isDebugEnabled()) { + log.debug("Updating operation '" + operation.toString() + "'"); + } + } + } + + @Override public Message enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException, AndroidDeviceMgtPluginException { @@ -1304,7 +1311,8 @@ public class AndroidServiceImpl implements AndroidService { } } - private List retrieveAlertByType(String deviceId, String type) throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup { + private List retrieveAlertByType(String deviceId, String type) + throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup { if (log.isDebugEnabled()) { log.debug("Retrieving events for given device identifier and type."); }