|
|
@ -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.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|