Remove unused imports

revert-dabc3590
shamalka 5 years ago
parent 1baf84089b
commit c5bb769698

@ -38,36 +38,12 @@ package org.wso2.carbon.device.mgt.mobile.android.api.impl;
import com.google.api.client.http.HttpStatusCodes; import com.google.api.client.http.HttpStatusCodes;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.exceptions.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; 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.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.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.mobile.android.api.DeviceManagementAdminAPI; 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.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.ApplicationInstallationBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationRestrictionBeanWrapper; import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationRestrictionBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.wrapper.ApplicationUninstallationBeanWrapper; 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.bean.wrapper.WipeDataBeanWrapper;
import org.wso2.carbon.device.mgt.mobile.android.common.exception.AndroidDeviceMgtPluginException; 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.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.common.spi.AndroidService;
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidAPIUtils; 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.Valid;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -101,13 +75,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; 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; import java.util.List;
@Path("/admin/devices") @Path("/admin/devices")
@ -116,7 +83,6 @@ import java.util.List;
public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI { public class DeviceManagementAdminAPIImpl implements DeviceManagementAdminAPI {
private static final Log log = LogFactory.getLog(DeviceManagementAdminAPIImpl.class); private static final Log log = LogFactory.getLog(DeviceManagementAdminAPIImpl.class);
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
@POST @POST
@Path("/file-transfer") @Path("/file-transfer")

@ -20,18 +20,10 @@ package org.wso2.carbon.device.mgt.mobile.android.api.impl;
import com.google.api.client.http.HttpStatusCodes; import com.google.api.client.http.HttpStatusCodes;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.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.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.Message;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState; import org.wso2.carbon.device.mgt.mobile.android.common.bean.DeviceState;
import org.wso2.carbon.device.mgt.mobile.android.common.bean.ErrorResponse; 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.exception.*;
import org.wso2.carbon.device.mgt.mobile.android.common.spi.AndroidService; 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.AndroidAPIUtils;
import org.wso2.carbon.device.mgt.mobile.android.core.util.AndroidDeviceUtils;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
@ -53,18 +44,8 @@ import java.util.List;
@Path("/events") @Path("/events")
public class EventReceiverAPIImpl implements EventReceiverAPI { 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 Log log = LogFactory.getLog(EventReceiverAPIImpl.class);
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";
@POST @POST
@Path("/publish") @Path("/publish")

@ -43,7 +43,7 @@ public interface AndroidService {
* Method to retrieve platform configurations * Method to retrieve platform configurations
* *
* @return {@link PlatformConfiguration} * @return {@link PlatformConfiguration}
* @throws {@link DeviceManagementException} * @throws {@link DeviceManagementException} If some unusual behaviour is observed while getting platform configurations
*/ */
PlatformConfiguration getPlatformConfig() throws DeviceManagementException; PlatformConfiguration getPlatformConfig() throws DeviceManagementException;
@ -62,7 +62,7 @@ public interface AndroidService {
* @param fileTransferBeanWrapper * @param fileTransferBeanWrapper
* @return {@link Activity} * @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException} * @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException} * @throws {@link OperationManagementException} If some unusual behaviour is observed while executing file transfer operation
*/ */
Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) Activity fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper)
throws AndroidDeviceMgtPluginException, OperationManagementException; throws AndroidDeviceMgtPluginException, OperationManagementException;
@ -73,7 +73,7 @@ public interface AndroidService {
* @param deviceLockBeanWrapper * @param deviceLockBeanWrapper
* @return {@link Activity} * @return {@link Activity}
* @throws {@link AndroidDeviceMgtPluginException} * @throws {@link AndroidDeviceMgtPluginException}
* @throws {@link OperationManagementException} * @throws {@link OperationManagementException} If some unusual behaviour is observed while executing device lock operation
*/ */
Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper) Activity configureDeviceLock(DeviceLockBeanWrapper deviceLockBeanWrapper)
throws OperationManagementException, AndroidDeviceMgtPluginException; throws OperationManagementException, AndroidDeviceMgtPluginException;

@ -28,6 +28,7 @@ import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException
import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; 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.analytics.data.publisher.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; 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.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.ws.rs.core.Response;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -889,7 +888,8 @@ public class AndroidServiceImpl implements AndroidService {
@Override @Override
public Message updateApplicationList(String id, List<AndroidApplication> androidApplications) throws org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException { public Message updateApplicationList(String id, List<AndroidApplication> androidApplications)
throws org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException {
Application application; Application application;
List<Application> applications = new ArrayList<>(); List<Application> applications = new ArrayList<>();
for (AndroidApplication androidApplication : androidApplications) { for (AndroidApplication androidApplication : androidApplications) {
@ -932,26 +932,7 @@ public class AndroidServiceImpl implements AndroidService {
log.debug("Invoking Android pending operations:" + deviceId); log.debug("Invoking Android pending operations:" + deviceId);
} }
if (resultOperations != null && !resultOperations.isEmpty()) { if (resultOperations != null && !resultOperations.isEmpty()) {
for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : resultOperations) { updateOperations(deviceId, 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() + "'");
}
}
} }
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String msg = "Issue in retrieving operation management service instance"; 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"; String msg = "Issue in updating Monitoring operation";
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) { } catch (NotificationManagementException e) {
String msg = "Issue in retrieving application management service instance"; String msg = "Issue in retrieving Notification management service instance";
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} catch (NotificationManagementException e) { } catch (org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException e) {
String msg = "Issue in retrieving Notification management service instance"; String msg = "Issue in retrieving application management service instance";
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} }
@ -979,6 +960,32 @@ public class AndroidServiceImpl implements AndroidService {
} }
} }
private void updateOperations(String deviceId, List<? extends Operation> 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 @Override
public Message enrollDevice(AndroidDevice androidDevice) public Message enrollDevice(AndroidDevice androidDevice)
throws DeviceManagementException, AndroidDeviceMgtPluginException { throws DeviceManagementException, AndroidDeviceMgtPluginException {
@ -1304,7 +1311,8 @@ public class AndroidServiceImpl implements AndroidService {
} }
} }
private List<DeviceState> retrieveAlertByType(String deviceId, String type) throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup { private List<DeviceState> retrieveAlertByType(String deviceId, String type)
throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Retrieving events for given device identifier and type."); log.debug("Retrieving events for given device identifier and type.");
} }

Loading…
Cancel
Save