Merge pull request #33 from milanperera/master

Added null check to getLicense
4.x.x
Prabath Abeysekara 9 years ago
commit 3445c49225

@ -603,6 +603,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public License getLicense(String deviceType, String languageCode) throws DeviceManagementException { public License getLicense(String deviceType, String languageCode) throws DeviceManagementException {
DeviceManager deviceManager = this.getDeviceManager(deviceType); DeviceManager deviceManager = this.getDeviceManager(deviceType);
License license;
if (deviceManager == null) { if (deviceManager == null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device Manager associated with the device type '" + deviceType + "' is null. " + log.debug("Device Manager associated with the device type '" + deviceType + "' is null. " +
@ -611,7 +612,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return null; return null;
} }
try { try {
return deviceManager.getLicense(languageCode); license = deviceManager.getLicense(languageCode);
if (license == null) {
if (log.isDebugEnabled()) {
log.debug("Cannot find a license for '" + deviceType + "' device type");
}
}
return license;
} catch (LicenseManagementException e) { } catch (LicenseManagementException e) {
throw new DeviceManagementException("Error occurred while retrieving license configured for " + throw new DeviceManagementException("Error occurred while retrieving license configured for " +
"device type '" + deviceType + "' and language code '" + languageCode + "'", e); "device type '" + deviceType + "' and language code '" + languageCode + "'", e);
@ -851,7 +858,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} }
} }
public List<Device> getDevicesByStatus(EnrolmentInfo.Status status) throws DeviceManagementException { public List<Device> getDevicesByStatus(EnrolmentInfo.Status status) throws DeviceManagementException {
List<Device> devices = new ArrayList<>(); List<Device> devices = new ArrayList<>();
List<Device> allDevices; List<Device> allDevices;

@ -119,43 +119,13 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws
FeatureManagementException { FeatureManagementException {
try { try {
return PolicyManagementDataHolder.getInstance().
List<ProfileFeature> effectiveFeatures = PolicyManagementDataHolder.getInstance() getPolicyEvaluationPoint().getEffectiveFeatures(deviceIdentifier);
.getPolicyEvaluationPoint().
getEffectiveFeatures(deviceIdentifier);
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<DeviceIdentifier>();
deviceIdentifiers.add(deviceIdentifier);
List<ProfileOperation> profileOperationList = new ArrayList<ProfileOperation>();
if (!effectiveFeatures.isEmpty()) {
for (ProfileFeature feature : effectiveFeatures) {
ProfileOperation operation = new ProfileOperation();
operation.setCode(feature.getFeatureCode());
operation.setPayLoad(feature.getContent());
operation.setStatus(Operation.Status.PENDING);
operation.setType(Operation.Type.PROFILE);
operation.setEnabled(true);
profileOperationList.add(operation);
PolicyManagementDataHolder.getInstance().getDeviceManagementService().
addOperation(operation, deviceIdentifiers);
}
} else {
return null;
}
return effectiveFeatures;
} catch (PolicyEvaluationException e) { } catch (PolicyEvaluationException e) {
String msg = "Error occurred while getting the effective features from the PEP service " + String msg = "Error occurred while getting the effective features from the PEP service " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(); deviceIdentifier.getId() + " - " + deviceIdentifier.getType();
log.error(msg, e); log.error(msg, e);
throw new FeatureManagementException(msg, e); throw new FeatureManagementException(msg, e);
} catch (OperationManagementException e) {
String msg = "Error occurred while adding the effective feature to database." +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType();
log.error(msg, e);
throw new FeatureManagementException(msg, e);
} }
} }

Loading…
Cancel
Save