@ -242,7 +242,7 @@ public class OperationManagerImpl implements OperationManager {
//Add the invalid DeviceIds
//Add the invalid DeviceIds
for ( String id : deviceIdValidationResult . getErrorDeviceIdList ( ) ) {
for ( String id : deviceIdValidationResult . getErrorDeviceIdList ( ) ) {
activityStatus = new ActivityStatus ( ) ;
activityStatus = new ActivityStatus ( ) ;
activityStatus . setDeviceIdentifier ( new DeviceIdentifier ( id , deviceType ) ) ;
activityStatus . setDeviceIdentifier ( new DeviceIdentifier ( id , deviceType ) ) ;
activityStatus . setStatus ( ActivityStatus . Status . INVALID ) ;
activityStatus . setStatus ( ActivityStatus . Status . INVALID ) ;
activityStatuses . add ( activityStatus ) ;
activityStatuses . add ( activityStatus ) ;
}
}
@ -351,7 +351,7 @@ public class OperationManagerImpl implements OperationManager {
if ( ! isActionAuthorized ( deviceId ) ) {
if ( ! isActionAuthorized ( deviceId ) ) {
throw new OperationManagementException ( "User '" + getUser ( ) + "' is not authorized to access the '" +
throw new OperationManagementException ( "User '" + getUser ( ) + "' is not authorized to access the '" +
deviceId . getType ( ) + "' device, which carries the identifier '" +
deviceId . getType ( ) + "' device, which carries the identifier '" +
deviceId . getId ( ) + "' of owner '" + owner + "'" ) ;
deviceId . getId ( ) + "' of owner '" + owner + "'" ) ;
}
}
EnrolmentInfo enrolmentInfo = this . getEnrolmentInfo ( deviceId , owner ) ;
EnrolmentInfo enrolmentInfo = this . getEnrolmentInfo ( deviceId , owner ) ;
@ -601,32 +601,33 @@ public class OperationManagerImpl implements OperationManager {
try {
try {
OperationManagementDAOFactory . openConnection ( ) ;
OperationManagementDAOFactory . openConnection ( ) ;
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation d to Operation = operationDAO .
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation d eviceSpecific Operation = operationDAO .
getOperationByDeviceAndId ( enrolmentInfo . getId ( ) ,
getOperationByDeviceAndId ( enrolmentInfo . getId ( ) ,
operationId ) ;
operationId ) ;
if ( dtoOperation . getType ( ) .
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation dtoOperation = deviceSpecificOperation ;
if ( deviceSpecificOperation . getType ( ) .
equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . COMMAND ) ) {
equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . COMMAND ) ) {
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . CommandOperation commandOperation ;
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . CommandOperation commandOperation ;
commandOperation =
commandOperation =
( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . CommandOperation ) commandOperationDAO .
( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . CommandOperation ) commandOperationDAO .
getOperation ( d to Operation. getId ( ) ) ;
getOperation ( d eviceSpecific Operation. getId ( ) ) ;
dtoOperation . setEnabled ( commandOperation . isEnabled ( ) ) ;
dtoOperation . setEnabled ( commandOperation . isEnabled ( ) ) ;
} else if ( d to Operation. getType ( ) .
} else if ( d eviceSpecific Operation. getType ( ) .
equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . CONFIG ) ) {
equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . CONFIG ) ) {
dtoOperation = configOperationDAO . getOperation ( d to Operation. getId ( ) ) ;
dtoOperation = configOperationDAO . getOperation ( d eviceSpecific Operation. getId ( ) ) ;
} else if ( d to Operation. getType ( ) . equals (
} else if ( d eviceSpecific Operation. getType ( ) . equals (
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . PROFILE ) ) {
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . PROFILE ) ) {
dtoOperation = profileOperationDAO . getOperation ( d to Operation. getId ( ) ) ;
dtoOperation = profileOperationDAO . getOperation ( d eviceSpecific Operation. getId ( ) ) ;
} else if ( d to Operation. getType ( ) . equals (
} else if ( d eviceSpecific Operation. getType ( ) . equals (
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . POLICY ) ) {
org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . POLICY ) ) {
dtoOperation = policyOperationDAO . getOperation ( d to Operation. getId ( ) ) ;
dtoOperation = policyOperationDAO . getOperation ( d eviceSpecific Operation. getId ( ) ) ;
}
}
if ( dtoOperation = = null ) {
if ( dtoOperation = = null ) {
throw new OperationManagementException ( "Operation not found for operation Id:" + operationId +
throw new OperationManagementException ( "Operation not found for operation Id:" + operationId +
" device id:" + deviceId . getId ( ) ) ;
" device id:" + deviceId . getId ( ) ) ;
}
}
operation = OperationDAOUtil . convertOperation ( dtoOperation ) ;
dtoOperation . setStatus ( deviceSpecificOperation . getStatus ( ) ) ;
operation = OperationDAOUtil . convertOperation ( deviceSpecificOperation ) ;
} catch ( OperationManagementDAOException e ) {
} catch ( OperationManagementDAOException e ) {
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 ( ) +
@ -904,12 +905,18 @@ public class OperationManagerImpl implements OperationManager {
private OperationDAO lookupOperationDAO ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation operation ) {
private OperationDAO lookupOperationDAO ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation operation ) {
if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . CommandOperation ) {
if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . CommandOperation | |
operation . getType ( ) . equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . COMMAND ) ) {
return commandOperationDAO ;
return commandOperationDAO ;
} else if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . ProfileOperation ) {
} else if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . ProfileOperation | |
operation . getType ( ) . equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . PROFILE ) ) {
return profileOperationDAO ;
return profileOperationDAO ;
} else if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . ConfigOperation ) {
} else if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . ConfigOperation | |
operation . getType ( ) . equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . CONFIG ) ) {
return configOperationDAO ;
return configOperationDAO ;
} else if ( operation instanceof org . wso2 . carbon . device . mgt . core . dto . operation . mgt . PolicyOperation | |
operation . getType ( ) . equals ( org . wso2 . carbon . device . mgt . core . dto . operation . mgt . Operation . Type . POLICY ) ) {
return policyOperationDAO ;
} else {
} else {
return operationDAO ;
return operationDAO ;
}
}
@ -1055,7 +1062,7 @@ public class OperationManagerImpl implements OperationManager {
List < MonitoringOperation > monitoringOperations = deviceManagementProviderService . getMonitoringOperationList ( deviceType ) ; //Get task list from each device type
List < MonitoringOperation > monitoringOperations = deviceManagementProviderService . getMonitoringOperationList ( deviceType ) ; //Get task list from each device type
for ( MonitoringOperation op : monitoringOperations ) {
for ( MonitoringOperation op : monitoringOperations ) {
if ( operation . getCode ( ) . equals ( op . getTaskName ( ) ) ) {
if ( operation . getCode ( ) . equals ( op . getTaskName ( ) ) ) {
return true ;
return true ;
}
}