|
|
@ -209,14 +209,27 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new UnauthorizedDeviceAccessException("User '" + getUser() + "' is not authorized to " +
|
|
|
|
throw new UnauthorizedDeviceAccessException("User '" + getUser() + "' is not authorized to " +
|
|
|
|
"fetch operations on device '" + deviceId.getId() + "'");
|
|
|
|
"fetch operations on device '" + deviceId.getId() + "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user : " +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
|
|
|
|
|
|
deviceId.getType() + "' device carrying the identifier '" +
|
|
|
|
|
|
|
|
deviceId.getId() + "'");
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -233,20 +246,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
|
|
|
|
|
|
deviceId.getType() + "' device carrying the identifier '" +
|
|
|
|
|
|
|
|
deviceId.getId() + "'");
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException(
|
|
|
|
throw new OperationManagementException(
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user : " +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operations;
|
|
|
|
return operations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -259,16 +264,31 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
if (isUserAuthorized) {
|
|
|
|
if (!isUserAuthorized) {
|
|
|
|
try {
|
|
|
|
log.error("User : " + getUser() + " is not authorized to fetch operations on device : " +
|
|
|
|
|
|
|
|
deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user : " +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
|
|
|
|
|
|
deviceId.getType() + "' device carrying the identifier '" +
|
|
|
|
|
|
|
|
deviceId.getId() + "'");
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
@ -290,23 +310,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
|
|
|
|
|
|
deviceId.getType() + "' device carrying the identifier '" +
|
|
|
|
|
|
|
|
deviceId.getId() + "'");
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException(
|
|
|
|
throw new OperationManagementException(
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("User : " + getUser() + " is not authorized to fetch operations on device : " + deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user : " +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return paginationResult;
|
|
|
|
return paginationResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -323,15 +332,31 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
if (isUserAuthorized) {
|
|
|
|
if (!isUserAuthorized) {
|
|
|
|
try {
|
|
|
|
log.error("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId() + "'", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
throw new OperationManagementException("Device not found for the given device Identifier:" +
|
|
|
|
throw new OperationManagementException("Device not found for the given device Identifier:" +
|
|
|
@ -356,24 +381,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
"pending operations assigned for '" + deviceId.getType() +
|
|
|
|
"pending operations assigned for '" + deviceId.getType() +
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException(
|
|
|
|
throw new OperationManagementException(
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operations;
|
|
|
|
return operations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -387,15 +400,31 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
if (isUserAuthorized) {
|
|
|
|
if (!isUserAuthorized) {
|
|
|
|
try {
|
|
|
|
log.error("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user : " +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId(), e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
@ -426,24 +455,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving next pending operation", e);
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving next pending operation", e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId(), e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException(
|
|
|
|
throw new OperationManagementException(
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user : " +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -457,8 +474,15 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
if (isUserAuthorized) {
|
|
|
|
if (!isUserAuthorized) {
|
|
|
|
try {
|
|
|
|
log.error("User : " + getUser() + " is not authorized to update operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -466,9 +490,16 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the" +
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the" +
|
|
|
|
" data source", e);
|
|
|
|
" data source", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while fetching the device for device identifier: " + deviceId.getId() +
|
|
|
|
|
|
|
|
"type:" + deviceId.getType(), e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
boolean isUpdated = false;
|
|
|
|
boolean isUpdated = false;
|
|
|
|
if (operation.getStatus() != null) {
|
|
|
|
if (operation.getStatus() != null) {
|
|
|
@ -485,24 +516,11 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException(
|
|
|
|
throw new OperationManagementException(
|
|
|
|
"Error occurred while updating the operation: " + operationId + " status:" +
|
|
|
|
"Error occurred while updating the operation: " + operationId + " status:" +
|
|
|
|
operation.getStatus(), e);
|
|
|
|
operation.getStatus(), e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while fetching the device for device identifier: " + deviceId.getId() +
|
|
|
|
|
|
|
|
"type:" + deviceId.getType(), e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while initiating a transaction", e);
|
|
|
|
throw new OperationManagementException("Error occurred while initiating a transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("User : " + getUser() + " is not authorized to update operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -538,16 +556,31 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
if (isUserAuthorized) {
|
|
|
|
if (!isUserAuthorized) {
|
|
|
|
try {
|
|
|
|
log.error("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening connection to the data source",
|
|
|
|
|
|
|
|
e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
throw new OperationManagementException("Device not found for given device identifier: " +
|
|
|
|
throw new OperationManagementException("Device not found for given device identifier: " +
|
|
|
@ -582,24 +615,13 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the list of " +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
"' device '" + deviceId.getId() + "'", e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while opening connection to the data source",
|
|
|
|
throw new OperationManagementException("Error occurred while opening connection to the data source",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -612,15 +634,31 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
isUserAuthorized(deviceId, DeviceGroupConstants.Permissions.DEFAULT_OPERATOR_PERMISSIONS);
|
|
|
|
if (isUserAuthorized) {
|
|
|
|
if (!isUserAuthorized) {
|
|
|
|
try {
|
|
|
|
log.info("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId(), e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException(
|
|
|
|
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
if (enrolmentId < 0) {
|
|
|
|
if (enrolmentId < 0) {
|
|
|
@ -651,24 +689,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"operations assigned for '" + deviceId.getType() +
|
|
|
|
"' device '" +
|
|
|
|
"' device '" +
|
|
|
|
deviceId.getId() + "' and status:" + status.toString(), e);
|
|
|
|
deviceId.getId() + "' and status:" + status.toString(), e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceId.getType() +
|
|
|
|
|
|
|
|
"' and device Id '" + deviceId.getId(), e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new OperationManagementException(
|
|
|
|
throw new OperationManagementException(
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
"Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("User : " + getUser() + " is not authorized to fetch operations on device : "
|
|
|
|
|
|
|
|
+ deviceId.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (DeviceAccessAuthorizationException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
|
|
|
|
|
|
|
this.getUser(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operations;
|
|
|
|
return operations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -809,7 +835,8 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<Activity> getActivitiesUpdatedAfter(long timestamp, int limit, int offset) throws OperationManagementException {
|
|
|
|
public List<Activity> getActivitiesUpdatedAfter(long timestamp, int limit,
|
|
|
|
|
|
|
|
int offset) throws OperationManagementException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
return operationDAO.getActivitiesUpdatedAfter(timestamp, limit, offset);
|
|
|
|
return operationDAO.getActivitiesUpdatedAfter(timestamp, limit, offset);
|
|
|
|