if (numOfApprovalsRequired > 0 && !ApprovalExecutorUtil.isCalledByClassNameOrExtRA("ChangeStatusEndEntityApprovalRequest")){
if (numOfApprovalsRequired > 0 && !ApprovalExecutorUtil.isCalledByClassNameOrExtRA("ChangeStatusEndEntityApprovalRequest",NONAPPROVABLECLASSNAMES_SETUSERSTATUS)){
    public void setUserStatus(Admin admin, String username, int status, boolean approvalflag) throws AuthorizationDeniedException, FinderException, ApprovalException, WaitingForApprovalException {        debug(">setUserStatus(" + username + ", " + status + ")");        // Check if administrator is authorized to edit user.        int caid = LogConstants.INTERNALCAID;        try {            UserDataPK pk = new UserDataPK(username);            UserDataLocal data1 = home.findByPrimaryKey(pk);            caid = data1.getCaId();            if (!authorizedToCA(admin, caid)) {                logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_ERROR_CHANGEDENDENTITY, "Administrator not authorized to change status of user with current CA.");                throw new AuthorizationDeniedException("Administrator not authorized to set status to user with given CA.");            }            if (getGlobalConfiguration(admin).getEnableEndEntityProfileLimitations()) {                if (!authorizedToEndEntityProfile(admin, data1.getEndEntityProfileId(), AvailableAccessRules.EDIT_RIGHTS)) {                    logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_ERROR_CHANGEDENDENTITY, "Administrator not authorized to change status");                    throw new AuthorizationDeniedException("Administrator not authorized to edit user.");                }            }                        if(approvalflag){            	// Check if approvals is required.            	int numOfApprovalsRequired = getNumOfApprovalRequired(admin, CAInfo.REQ_APPROVAL_ADDEDITENDENTITY, caid);            	if (numOfApprovalsRequired > 0 && !ApprovalExecutorUtil.isCalledByClassNameOrExtRA("ChangeStatusEndEntityApprovalRequest")){       		    		            		ChangeStatusEndEntityApprovalRequest ar = new ChangeStatusEndEntityApprovalRequest(username, data1.getStatus(), status ,  admin,null,numOfApprovalsRequired,data1.getCaId(),data1.getEndEntityProfileId());            		approvalsession.addApprovalRequest(admin, ar);            		throw new WaitingForApprovalException("Edit Endity Action have been added for approval by authorized adminstrators");            	}              }                                    if(data1.getStatus() == UserDataConstants.STATUS_KEYRECOVERY && !(status == UserDataConstants.STATUS_KEYRECOVERY || status == UserDataConstants.STATUS_INPROCESS || status == UserDataConstants.STATUS_INITIALIZED)){                keyrecoverysession.unmarkUser(admin,username);	            }                        data1.setStatus(status);            data1.setTimeModified((new java.util.Date()).getTime());            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_INFO_CHANGEDENDENTITY, ("New status : " + status));        } catch (FinderException e) {            logsession.log(admin, caid, LogEntry.MODULE_RA, new java.util.Date(), username, null, LogEntry.EVENT_ERROR_CHANGEDENDENTITY, "Couldn't find username in database.");            throw e;        }        debug("<setUserStatus(" + username + ", " + status + ")");    } // setUserStatus