@Override
public void checkExecutionPossibility(Admin admin, ApprovalData adl) throws AdminAlreadyApprovedRequestException{
// Check that the approvers username doesn't exists among the existing
// usernames.
ApprovalDataVO data = getApprovalDataVO(adl);
String username = admin.getUsername();
if (data.getReqadmincertissuerdn() != null) {
// Check that the approver isn't the same as requested the action.
boolean sameAsRequester = false;
String requsername = getRequestAdminUsername(adl);
if(username != null) {
if(username.equals(requsername)) {
sameAsRequester=true;
}
} else {
if(admin.getAdminData().equals(getApprovalRequest(adl).getRequestAdmin().getAdminData())) {
sameAsRequester=true;
}
}
if (sameAsRequester) {
logSession.log(admin, adl.getCaid(), LogConstants.MODULE_APPROVAL, new Date(), null, null, LogConstants.EVENT_ERROR_APPROVALREJECTED,
"Error administrator have already approved, rejected or requested current request, approveId ");
throw new AdminAlreadyApprovedRequestException("Error administrator have already approved, rejected or requested current request, approveId : "
+ /*approvalId*/ adl.getApprovalid());
}
}
//Check that his admin has not approved this this request before
Iterator<Approval> iter = data.getApprovals().iterator();
while (iter.hasNext()) {
Approval next = iter.next();
if ((next.getAdmin().getUsername()!=null && username!=null && next.getAdmin().getUsername().equals(username)) || ((next.getAdmin().getUsername()==null || username==null) && admin.getAdminData().equals(next.getAdmin().getAdminData()))) {
logSession.log(admin, adl.getCaid(), LogConstants.MODULE_APPROVAL, new Date(), null, null, LogConstants.EVENT_ERROR_APPROVALREJECTED,
"Error administrator have already approved or rejected current request, approveId ");