fixing app-install issue

revert-70aa11f8
hasuniea 8 years ago
parent 282f53bf09
commit 6db619317c

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.mgt.common;
public class InvalidDeviceException extends Exception {
private static final long serialVersionUID = -3151279311929070297L;
public InvalidDeviceException(String msg, Exception nestedEx) {
super(msg, nestedEx);
}
public InvalidDeviceException(String message, Throwable cause) {
super(message, cause);
}
public InvalidDeviceException(String msg) {
super(msg);
}
public InvalidDeviceException() {
super();
}
public InvalidDeviceException(Throwable cause) {
super(cause);
}
}

@ -32,10 +32,11 @@ public interface OperationManager {
* *
* @param operation Operation to be added * @param operation Operation to be added
* @param devices List of DeviceIdentifiers to execute the operation * @param devices List of DeviceIdentifiers to execute the operation
* @throws OperationManagementException If some unusual behaviour is observed while adding the * @throws OperationManagementException If some unusual behaviour is observed while adding the operation
* operation * InvalidDeviceException If addOperation request contains Invalid DeviceIdentifiers.
*/ */
Activity addOperation(Operation operation, List<DeviceIdentifier> devices) throws OperationManagementException; Activity addOperation(Operation operation, List<DeviceIdentifier> devices) throws OperationManagementException,
InvalidDeviceException;
/** /**
* Method to retrieve the list of all operations to a device. * Method to retrieve the list of all operations to a device.

@ -106,6 +106,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
throw new ApplicationManagementException("Error in add operation at app installation", e); throw new ApplicationManagementException("Error in add operation at app installation", e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new ApplicationManagementException("Error in notify operation at app installation", e); throw new ApplicationManagementException("Error in notify operation at app installation", e);
} catch (InvalidDeviceException e) {
throw new ApplicationManagementException("Invalid DeviceIdentifiers found.", e);
} }
} }
@ -140,6 +142,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
.addOperation(type, operation, deviceIdentifierList); .addOperation(type, operation, deviceIdentifierList);
} catch (InvalidDeviceException e) {
throw new ApplicationManagementException("Invalid DeviceIdentifiers found.", e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new ApplicationManagementException("Error in get devices for user: " + userName + throw new ApplicationManagementException("Error in get devices for user: " + userName +
" in app installation", e); " in app installation", e);
@ -179,6 +183,8 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
} }
return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(type, operation, return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(type, operation,
deviceIdentifierList); deviceIdentifierList);
} catch (InvalidDeviceException e) {
throw new ApplicationManagementException("Invalid DeviceIdentifiers found.", e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new ApplicationManagementException("Error in get devices for user role " + userRole + throw new ApplicationManagementException("Error in get devices for user role " + userRole +
" in app installation", e); " in app installation", e);

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -43,9 +43,11 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOE
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
import org.wso2.carbon.device.mgt.core.operation.mgt.util.DeviceIDHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.util.OperationCreateTimeComparator; import org.wso2.carbon.device.mgt.core.operation.mgt.util.OperationCreateTimeComparator;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager;
import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerImpl; import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerImpl;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -88,7 +90,7 @@ public class OperationManagerImpl implements OperationManager {
@Override @Override
public Activity addOperation(Operation operation, public Activity addOperation(Operation operation,
List<DeviceIdentifier> deviceIds) throws OperationManagementException { List<DeviceIdentifier> deviceIds) throws OperationManagementException, InvalidDeviceException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("operation:[" + operation.toString() + "]"); log.debug("operation:[" + operation.toString() + "]");
for (DeviceIdentifier deviceIdentifier : deviceIds) { for (DeviceIdentifier deviceIdentifier : deviceIds) {
@ -96,14 +98,16 @@ public class OperationManagerImpl implements OperationManager {
deviceIdentifier.getType() + "]"); deviceIdentifier.getType() + "]");
} }
} }
try {
DeviceIDHolder deviceIDHolder = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds);
List<DeviceIdentifier> validDeviceIds = deviceIDHolder.getValidDeviceIDList();
if (validDeviceIds.size() > 0) {
List<DeviceIdentifier> authorizedDeviceList = this.getAuthorizedDevices(operation, deviceIds); List<DeviceIdentifier> authorizedDeviceList = this.getAuthorizedDevices(operation, deviceIds);
if (authorizedDeviceList.size() <= 0) { if (authorizedDeviceList.size() <= 0) {
log.info("User : " + getUser() + " is not authorized to perform operations on given device-list."); log.info("User : " + getUser() + " is not authorized to perform operations on given device-list.");
return null; return null;
} }
try {
OperationManagementDAOFactory.beginTransaction(); OperationManagementDAOFactory.beginTransaction();
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
OperationDAOUtil.convertOperation(operation); OperationDAOUtil.convertOperation(operation);
@ -146,6 +150,7 @@ public class OperationManagerImpl implements OperationManager {
} }
} }
} }
OperationManagementDAOFactory.commitTransaction(); OperationManagementDAOFactory.commitTransaction();
Activity activity = new Activity(); Activity activity = new Activity();
activity.setActivityId(DeviceManagementConstants.OperationAttributes.ACTIVITY + operationId); activity.setActivityId(DeviceManagementConstants.OperationAttributes.ACTIVITY + operationId);
@ -153,6 +158,10 @@ public class OperationManagerImpl implements OperationManager {
activity.setCreatedTimeStamp(new Date().toString()); activity.setCreatedTimeStamp(new Date().toString());
activity.setType(Activity.Type.valueOf(operationDto.getType().toString())); activity.setType(Activity.Type.valueOf(operationDto.getType().toString()));
return activity; return activity;
} else {
throw new InvalidDeviceException("Invalid device Identifiers found.");
}
} catch (OperationManagementDAOException e) { } catch (OperationManagementDAOException e) {
OperationManagementDAOFactory.rollbackTransaction(); OperationManagementDAOFactory.rollbackTransaction();
throw new OperationManagementException("Error occurred while adding operation", e); throw new OperationManagementException("Error occurred while adding operation", e);

@ -0,0 +1,32 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.operation.mgt;
public class OperationMgtConstants {
public final class DeviceConstants {
private DeviceConstants() {
throw new AssertionError();
}
public static final String DEVICE_ID_NOT_FOUND = "Device not found for device id: %s";
public static final String DEVICE_ID_SERVICE_NOT_FOUND =
"Issue in retrieving device management service instance for device found at %s";
}
}

@ -0,0 +1,48 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.operation.mgt.util;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import java.util.List;
/**
* Holder class for storing valid & invalid device-ids.
*/
public class DeviceIDHolder {
private List<String> errorDeviceIdList;
private List<DeviceIdentifier> validDeviceIDList;
public List<String> getErrorDeviceIdList() {
return errorDeviceIdList;
}
public void setErrorDeviceIdList(List<String> errorDeviceIdList) {
this.errorDeviceIdList = errorDeviceIdList;
}
public List<DeviceIdentifier> getValidDeviceIDList() {
return validDeviceIDList;
}
public void setValidDeviceIDList(List<DeviceIdentifier> validDeviceIDList) {
this.validDeviceIDList = validDeviceIDList;
}
}

@ -42,7 +42,7 @@ public class PushNotificationBasedOperationManager implements OperationManager {
@Override @Override
public Activity addOperation(Operation operation, public Activity addOperation(Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException { List<DeviceIdentifier> devices) throws OperationManagementException, InvalidDeviceException {
Activity activity = this.operationManager.addOperation(operation, devices); Activity activity = this.operationManager.addOperation(operation, devices);
for (DeviceIdentifier deviceId : devices) { for (DeviceIdentifier deviceId : devices) {
try { try {

@ -222,7 +222,7 @@ public interface DeviceManagementProviderService {
List<DeviceIdentifier> deviceIds) throws DeviceManagementException; List<DeviceIdentifier> deviceIds) throws DeviceManagementException;
Activity addOperation(String type, Operation operation, Activity addOperation(String type, Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException; List<DeviceIdentifier> devices) throws OperationManagementException, InvalidDeviceException;
List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException; List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException;

@ -1021,7 +1021,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
@Override @Override
public Activity addOperation(String type, Operation operation, public Activity addOperation(String type, Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException { List<DeviceIdentifier> devices) throws OperationManagementException, InvalidDeviceException {
return pluginRepository.getOperationManager(type, this.getTenantId()).addOperation(operation, devices); return pluginRepository.getOperationManager(type, this.getTenantId()).addOperation(operation, devices);
} }

@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
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.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
@ -108,6 +109,8 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
log.debug("No devices are available to perform the operations."); log.debug("No devices are available to perform the operations.");
} }
} }
} catch (InvalidDeviceException e) {
throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
throw new DeviceMgtTaskException("Error occurred while retrieving the device list.", e); throw new DeviceMgtTaskException("Error occurred while retrieving the device list.", e);
} catch (OperationManagementException e) { } catch (OperationManagementException e) {

@ -34,6 +34,8 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants;
import org.wso2.carbon.device.mgt.core.operation.mgt.util.DeviceIDHolder;
import org.wso2.carbon.user.api.TenantManager; import org.wso2.carbon.user.api.TenantManager;
import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.CarbonUtils;
@ -317,4 +319,53 @@ public final class DeviceManagerUtil {
} }
return limit; return limit;
} }
public static DeviceIDHolder validateDeviceIdentifiers(List<DeviceIdentifier> deviceIDs) {
List<String> errorDeviceIdList = new ArrayList<String>();
List<DeviceIdentifier> validDeviceIDList = new ArrayList<DeviceIdentifier>();
int deviceIDCounter = 0;
for (DeviceIdentifier deviceIdentifier : deviceIDs) {
deviceIDCounter++;
String deviceID = deviceIdentifier.getId();
if (deviceID == null || deviceID.isEmpty()) {
errorDeviceIdList.add(String.format(OperationMgtConstants.DeviceConstants.DEVICE_ID_NOT_FOUND,
deviceIDCounter));
continue;
}
try {
if (isValidDeviceIdentifier(deviceIdentifier)) {
validDeviceIDList.add(deviceIdentifier);
} else {
errorDeviceIdList.add(String.format(OperationMgtConstants.DeviceConstants.
DEVICE_ID_NOT_FOUND, deviceID));
}
} catch (DeviceManagementException e) {
errorDeviceIdList.add(String.format(OperationMgtConstants.DeviceConstants.DEVICE_ID_SERVICE_NOT_FOUND,
deviceIDCounter));
}
}
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
deviceIDHolder.setValidDeviceIDList(validDeviceIDList);
deviceIDHolder.setErrorDeviceIdList(errorDeviceIdList);
return deviceIDHolder;
}
public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
Device device = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceIdentifier);
if (device == null || device.getDeviceIdentifier() == null ||
device.getDeviceIdentifier().isEmpty() || device.getEnrolmentInfo() == null) {
return false;
} else if (EnrolmentInfo.Status.REMOVED.equals(device.getEnrolmentInfo().getStatus())) {
return false;
}
return true;
}
} }

@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.common.*;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
@ -105,6 +106,10 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
PolicyManagementDataHolder.getInstance().getDeviceManagementService().addOperation(type, PolicyManagementDataHolder.getInstance().getDeviceManagementService().addOperation(type,
PolicyManagerUtil.transformPolicy(policy), deviceIdentifiers); PolicyManagerUtil.transformPolicy(policy), deviceIdentifiers);
return policy; return policy;
} catch (InvalidDeviceException e) {
String msg = "Error occurred while getting the effective policies for invalid DeviceIdentifiers";
log.error(msg, e);
throw new PolicyManagementException(msg, e);
} catch (PolicyEvaluationException e) { } catch (PolicyEvaluationException e) {
String msg = "Error occurred while getting the effective policies from the PEP service for device " + String msg = "Error occurred while getting the effective policies from the PEP service for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType(); deviceIdentifier.getId() + " - " + deviceIdentifier.getType();

@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
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;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
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.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
@ -100,6 +101,10 @@ public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegato
//ToDo Need to fix this to fetch OSGi service //ToDo Need to fix this to fetch OSGi service
OperationManager operationManager = new OperationManagerImpl(); OperationManager operationManager = new OperationManagerImpl();
operationManager.addOperation(PolicyManagerUtil.transformPolicy(policy), deviceIdentifiers); operationManager.addOperation(PolicyManagerUtil.transformPolicy(policy), deviceIdentifiers);
} catch (InvalidDeviceException e) {
String msg = "Invalid DeviceIdentifiers found.";
log.error(msg, e);
throw new PolicyDelegationException(msg, e);
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String msg = "Error occurred while adding the operation to device."; String msg = "Error occurred while adding the operation to device.";
log.error(msg, e); log.error(msg, e);

@ -21,10 +21,7 @@ package org.wso2.carbon.policy.mgt.core.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
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.core.operation.mgt.PolicyOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
@ -170,7 +167,8 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
addOperation(type, policyOperation, deviceIdentifiers); addOperation(type, policyOperation, deviceIdentifiers);
} }
} catch (InvalidDeviceException e) {
throw new PolicyComplianceException("Invalid Device identifiers found.", e);
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
throw new PolicyComplianceException("Error occurred while re-enforcing the policy to device " + deviceIdentifier.getId() + " - " + throw new PolicyComplianceException("Error occurred while re-enforcing the policy to device " + deviceIdentifier.getId() + " - " +
deviceIdentifier.getType(), e); deviceIdentifier.getType(), e);

@ -25,6 +25,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
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;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
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.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
@ -354,6 +355,8 @@ public class MonitoringManagerImpl implements MonitoringManager {
if (!deviceIdsToAddOperation.isEmpty()) { if (!deviceIdsToAddOperation.isEmpty()) {
try { try {
this.addMonitoringOperationsToDatabase(new ArrayList<>(deviceIdsToAddOperation.values())); this.addMonitoringOperationsToDatabase(new ArrayList<>(deviceIdsToAddOperation.values()));
} catch (InvalidDeviceException e) {
throw new PolicyComplianceException("Invalid Device Identifiers found.", e);
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
throw new PolicyComplianceException("Error occurred while adding monitoring operation to devices", e); throw new PolicyComplianceException("Error occurred while adding monitoring operation to devices", e);
} }
@ -387,7 +390,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
} }
private void addMonitoringOperationsToDatabase(List<Device> devices) private void addMonitoringOperationsToDatabase(List<Device> devices)
throws PolicyComplianceException, OperationManagementException { throws PolicyComplianceException, OperationManagementException, InvalidDeviceException {
List<DeviceIdentifier> deviceIdentifiers = this.getDeviceIdentifiersFromDevices(devices); List<DeviceIdentifier> deviceIdentifiers = this.getDeviceIdentifiersFromDevices(devices);
CommandOperation monitoringOperation = new CommandOperation(); CommandOperation monitoringOperation = new CommandOperation();

Loading…
Cancel
Save