Merge pull request #694 from harshanL/master

Prevented getDevice calls from loading uncessary device-info.
revert-dabc3590
Geeth 8 years ago committed by GitHub
commit a99749681d

@ -189,7 +189,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
DeviceIdentifier id = new DeviceIdentifier(); DeviceIdentifier id = new DeviceIdentifier();
id.setId(deviceId); id.setId(deviceId);
id.setType(AndroidConstants.DEVICE_TYPE_ANDROID); id.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName(); String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id, false).getName();
notification.setOperationId(operation.getId()); notification.setOperationId(operation.getId());
notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification. notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
Status.NEW.toString()); Status.NEW.toString());
@ -477,7 +477,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
location.setLatitude(Double.valueOf(latitude)); location.setLatitude(Double.valueOf(latitude));
location.setLongitude(Double.valueOf(longitude)); location.setLongitude(Double.valueOf(longitude));
location.setDeviceIdentifier(deviceIdentifier); location.setDeviceIdentifier(deviceIdentifier);
Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false);
location.setDeviceId(savedDevice.getId()); location.setDeviceId(savedDevice.getId());
} }
return location; return location;

@ -83,7 +83,7 @@ public class AndroidDeviceUtils {
public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
Device device = AndroidAPIUtils.getDeviceManagementService(). Device device = AndroidAPIUtils.getDeviceManagementService().
getDevice(deviceIdentifier); getDevice(deviceIdentifier, false);
if (device == null || device.getDeviceIdentifier() == null || if (device == null || device.getDeviceIdentifier() == null ||
device.getDeviceIdentifier().isEmpty() || device.getEnrolmentInfo() == null) { device.getDeviceIdentifier().isEmpty() || device.getEnrolmentInfo() == null) {
return false; return false;

@ -26,12 +26,10 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.device.details.*;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; 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.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.CacheEntry;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.SyncmlMessageFormatException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.SyncmlMessageFormatException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.SyncmlOperationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.SyncmlOperationException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
@ -39,13 +37,18 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDe
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.AuthenticationInfo; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.AuthenticationInfo;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.DeviceUtil; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.DeviceUtil;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.ItemTag;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.*; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.ReplaceTag;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.DeviceInfo; import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlDocument;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlHeader;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.WindowsOperationException;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.OperationCode;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.OperationHandler;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.OperationReply;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.SyncmlParser;
import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService; import org.wso2.carbon.device.mgt.mobile.windows.api.services.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileCacheEntry; import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileCacheEntry;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.ArrayList; import java.util.ArrayList;
@ -116,7 +119,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.ok().entity(operationReply.generateReply( return Response.ok().entity(operationReply.generateReply(
syncmlDocument, pendingOperations)).build(); syncmlDocument, pendingOperations)).build();
} else { } else {
if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) { if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false) != null) {
WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
return Response.ok().entity(operationReply.generateReply(syncmlDocument, null)).build(); return Response.ok().entity(operationReply.generateReply(syncmlDocument, null)).build();
} else { } else {

@ -190,7 +190,7 @@ public class SyncmlServiceImpl implements SyncmlService {
pendingOperations = operationHandler.getPendingOperations(syncmlDocument); pendingOperations = operationHandler.getPendingOperations(syncmlDocument);
return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build(); return Response.ok().entity(generateReply(syncmlDocument, pendingOperations)).build();
} else { } else {
if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier) != null) { if (WindowsAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false) != null) {
WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); WindowsAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
return Response.ok().entity(generateReply(syncmlDocument, null)).build(); return Response.ok().entity(generateReply(syncmlDocument, null)).build();
} else { } else {

Loading…
Cancel
Save