Merge branch 'master' into 'master'

Performance improvements

See merge request entgra/carbon-device-mgt-plugins!155
revert-dabc3590
Charitha Goonetilleke 5 years ago
commit 772d566dd5

@ -223,10 +223,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
private void updateOperations(Device device, List<? extends Operation> operations) private void updateOperations(Device device, List<? extends Operation> operations)
throws OperationManagementException, PolicyComplianceException, throws OperationManagementException, PolicyComplianceException,
ApplicationManagementException, NotificationManagementException, DeviceManagementException { ApplicationManagementException, NotificationManagementException {
DeviceIdentifier id = new DeviceIdentifier();
id.setId(device.getDeviceIdentifier());
id.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
String deviceName = device.getName(); String deviceName = device.getName();
for (Operation operation : operations) { for (Operation operation : operations) {
AndroidDeviceUtils.updateOperation(device, operation); AndroidDeviceUtils.updateOperation(device, operation);
@ -238,7 +235,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
Status.NEW.toString()); Status.NEW.toString());
notification.setDescription(operation.getCode() + " operation failed to execute on device " + notification.setDescription(operation.getCode() + " operation failed to execute on device " +
deviceName + " (ID: " + device.getDeviceIdentifier() + ")"); deviceName + " (ID: " + device.getDeviceIdentifier() + ")");
AndroidAPIUtils.getNotificationManagementService().addNotification(id, notification); AndroidAPIUtils.getNotificationManagementService().addNotification(device, notification);
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Updating operation '" + operation.toString() + "'"); log.debug("Updating operation '" + operation.toString() + "'");
@ -358,7 +355,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) { public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) {
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id);
try { try {
Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false);
if (device != null) { if (device != null) {
String status = String.valueOf(device.getEnrolmentInfo().getStatus()); String status = String.valueOf(device.getEnrolmentInfo().getStatus());
Message responseMessage = new Message(); Message responseMessage = new Message();
@ -389,7 +386,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
deviceIdentifier.setId(id); deviceIdentifier.setId(id);
deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID); deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
try { try {
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" + String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" +
id + "'"; id + "'";

@ -76,7 +76,7 @@ public class EventReceiverServiceImpl implements EventReceiverService {
} }
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(), DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(),
AndroidConstants.DEVICE_TYPE_ANDROID); AndroidConstants.DEVICE_TYPE_ANDROID);
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false);
if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){ if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){
return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build(); return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build();
} else if (device == null){ } else if (device == null){

@ -167,8 +167,8 @@ public class AndroidDeviceUtils {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Received compliance status from MONITOR operation ID: " + operation.getId()); log.debug("Received compliance status from MONITOR operation ID: " + operation.getId());
} }
AndroidAPIUtils.getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, AndroidAPIUtils.getPolicyManagerService().checkPolicyCompliance(device,
getComplianceFeatures(operation.getPayLoad())); getComplianceFeatures(operation.getPayLoad()));
} else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants. } else if (!Operation.Status.ERROR.equals(operation.getStatus()) && AndroidConstants.
OperationCodes.APPLICATION_LIST.equals(operation.getCode())) { OperationCodes.APPLICATION_LIST.equals(operation.getCode())) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

@ -26,6 +26,11 @@ public class DeviceInformationManagerServiceMock implements DeviceInformationMan
return null; return null;
} }
@Override
public DeviceInfo getDeviceInfo(Device device) throws DeviceDetailsMgtException {
return null;
}
@Override @Override
public List<DeviceInfo> getDevicesInfo(List<DeviceIdentifier> list) throws DeviceDetailsMgtException { public List<DeviceInfo> getDevicesInfo(List<DeviceIdentifier> list) throws DeviceDetailsMgtException {
return null; return null;

@ -429,13 +429,7 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
} }
@Override @Override
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { public boolean setStatus(Device device, EnrolmentInfo.Status status) throws DeviceManagementException {
return false;
}
@Override
public boolean setStatus(DeviceIdentifier deviceIdentifier, String s, EnrolmentInfo.Status status)
throws DeviceManagementException {
return false; return false;
} }
@ -456,6 +450,11 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
return TestUtils.getActivity(); return TestUtils.getActivity();
} }
@Override
public void addTaskOperation(String s, Operation operation) throws OperationManagementException {
}
@Override @Override
public List<? extends Operation> getOperations(DeviceIdentifier deviceIdentifier) public List<? extends Operation> getOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException { throws OperationManagementException {
@ -468,6 +467,11 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
return null; return null;
} }
@Override
public List<? extends Operation> getOperations(DeviceIdentifier deviceIdentifier, Operation.Status status) throws OperationManagementException {
return null;
}
@Override @Override
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceIdentifier) public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException { throws OperationManagementException {
@ -668,7 +672,7 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
} }
@Override @Override
public boolean updateEnrollment(String s, List<String> list) throws DeviceManagementException, UserNotFoundException, InvalidDeviceException { public boolean updateEnrollment(String s, boolean b, List<String> list) throws DeviceManagementException, UserNotFoundException, InvalidDeviceException {
return false; return false;
} }
@ -741,4 +745,10 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
public int getFunctioningDevicesInSystem() throws DeviceManagementException { public int getFunctioningDevicesInSystem() throws DeviceManagementException {
return 0; return 0;
} }
@Override
public boolean isOperationExist(DeviceIdentifier deviceIdentifier, int i) throws OperationManagementException {
return false;
}
} }

@ -285,11 +285,6 @@ public class AndroidDeviceManager implements DeviceManager {
return true; return true;
} }
@Override
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
return false;
}
@Override @Override
public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser, public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
EnrolmentInfo.Status status) throws DeviceManagementException { EnrolmentInfo.Status status) throws DeviceManagementException {

Loading…
Cancel
Save