|
|
|
@ -29,11 +29,8 @@ import org.wso2.carbon.analytics.datasource.commons.Record;
|
|
|
|
|
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
|
=======
|
|
|
|
|
>>>>>>> 344232fc3287dc7566624756aa2ea17d7874dcf9
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
@ -48,11 +45,8 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtExcept
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.impl.Utils;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService;
|
|
|
|
|
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
|
|
|
|
=======
|
|
|
|
|
>>>>>>> 344232fc3287dc7566624756aa2ea17d7874dcf9
|
|
|
|
|
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
|
|
|
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
|
|
|
|
|
|
|
|
@ -99,16 +93,16 @@ public class AndroidAPIUtils {
|
|
|
|
|
return deviceManagementProviderService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public static GCMService getGCMService() {
|
|
|
|
|
// PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
|
// GCMService gcmService = (GCMService) ctx.getOSGiService(GCMService.class, null);
|
|
|
|
|
// if (gcmService == null) {
|
|
|
|
|
// String msg = "GCM service has not initialized.";
|
|
|
|
|
// log.error(msg);
|
|
|
|
|
// throw new IllegalStateException(msg);
|
|
|
|
|
// }
|
|
|
|
|
// return gcmService;
|
|
|
|
|
// }
|
|
|
|
|
public static GCMService getGCMService() {
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
|
GCMService gcmService = (GCMService) ctx.getOSGiService(GCMService.class, null);
|
|
|
|
|
if (gcmService == null) {
|
|
|
|
|
String msg = "GCM service has not initialized.";
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new IllegalStateException(msg);
|
|
|
|
|
}
|
|
|
|
|
return gcmService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MediaType getResponseMediaType(String acceptHeader) {
|
|
|
|
|
MediaType responseMediaType;
|
|
|
|
@ -129,7 +123,8 @@ public class AndroidAPIUtils {
|
|
|
|
|
message, responseMediaType);
|
|
|
|
|
|
|
|
|
|
List<DeviceIdentifier> validDeviceIds = deviceIDHolder.getValidDeviceIDList();
|
|
|
|
|
int status = getDeviceManagementService().addOperation(operation, validDeviceIds);
|
|
|
|
|
int status = getDeviceManagementService().addOperation(
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, validDeviceIds);
|
|
|
|
|
if (status > 0) {
|
|
|
|
|
GCMService gcmService = getGCMService();
|
|
|
|
|
if (gcmService.isGCMEnabled()) {
|
|
|
|
@ -142,12 +137,12 @@ public class AndroidAPIUtils {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) {
|
|
|
|
|
return Response.status(AndroidConstants.StatusCodes.
|
|
|
|
|
return javax.ws.rs.core.Response.status(AndroidConstants.StatusCodes.
|
|
|
|
|
MULTI_STATUS_HTTP_CODE).type(
|
|
|
|
|
responseMediaType).entity(deviceUtils.
|
|
|
|
|
convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build();
|
|
|
|
|
}
|
|
|
|
|
return Response.status(Response.Status.CREATED).
|
|
|
|
|
return javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.CREATED).
|
|
|
|
|
type(responseMediaType).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|