public boolean canMaintain(Object dataObject, Person user) { Map<String, String> permissionDetails = new HashMap<String, String>(2); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName( dataObject.getClass())); permissionDetails.put(KRADConstants.MAINTENANCE_ACTN, KRADConstants.MAINTENANCE_EDIT_ACTION); return !permissionExistsByTemplate(KRADConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, permissionDetails) || isAuthorizedByTemplate( dataObject, KRADConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, user.getPrincipalId(), permissionDetails, null); }
@Override public boolean canCreate(Class boClass) { return KRADServiceLocatorWeb.getDocumentDictionaryService().getAllowsNewOrCopy( KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentTypeName(boClass)); }
protected List<PositionAppointmentBo> filterLookupPositionAppointments(List<PositionAppointmentBo> rawResults, Person user) { List<PositionAppointmentBo> returnList = new ArrayList<PositionAppointmentBo>(); for (PositionAppointmentBo positionAppointmentObj : rawResults) { if (((PositionAppointmentAuthorizer)(getDocumentDictionaryService().getDocumentAuthorizer(this.getMaintenanceDocumentTypeName()))).canView((Object) positionAppointmentObj, user)) { returnList.add(positionAppointmentObj); } } return returnList; }
@Override public boolean isAuthorizedForDocument(String principalId, Document document) { try { MissedPunchDocument mpd = (MissedPunchDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(document.getDocumentId()); String groupKey = mpd.getGroupKeyCode(); Long workArea = mpd.getWorkArea(); String department = mpd.getDepartment(); String location = mpd.getGroupKey() != null ? mpd.getGroupKey().getLocationId() : HrServiceLocator.getHrGroupKeyService().getHrGroupKey(mpd.getGroupKeyCode(), mpd.getMissedPunch().getActionLocalDate()).getLocationId(); Map<String, String> roleQualification = new HashMap<String, String>(); roleQualification.put(KimConstants.AttributeConstants.PRINCIPAL_ID, principalId); roleQualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department); roleQualification.put(KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(), workArea.toString()); roleQualification.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), groupKey); roleQualification.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), location); Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentTypeByClass(MissedPunchDocument.class)); return (!KimApiServiceLocator.getPermissionService().isPermissionDefinedByTemplate(KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), new HashMap<String, String>()) || KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(principalId, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails, roleQualification)); } catch (WorkflowException e) { return false; } } }
permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentTypeByClass(MissedPunchDocument.class));
public boolean canCreate(Class boClass, Person user) { Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName( boClass)); permissionDetails.put(KRADConstants.MAINTENANCE_ACTN, KRADConstants.MAINTENANCE_NEW_ACTION); return !permissionExistsByTemplate(KRADConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, permissionDetails) || getPermissionService() .isAuthorizedByTemplate(user.getPrincipalId(), KRADConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, permissionDetails, new HashMap<String, String>()); }
protected List<PositionContract> filterLookupPositions(List<PositionContract> rawResults) { DocumentDictionaryService documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); List<PositionContract> results = new ArrayList<PositionContract>(); for (PositionContract positionObj : rawResults) { if ( ((PositionDocumentAuthorizer)(documentDictionaryService.getDocumentAuthorizer(this.getMaintenanceDocumentTypeName()))).canView(positionObj, GlobalVariables.getUserSession().getPerson()) ) { results.add(positionObj); } } return results; }
public boolean canView(Object dataObject, Person user) { Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName(dataObject.getClass()) ); Map<String, String> q = getRoleQualification(dataObject, user.getPrincipalId()); return isAuthorizedByTemplate(dataObject, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), user.getPrincipalId(), permissionDetails, q); }
protected boolean canEdit(MaintenanceDocument document) { DocumentAuthorizer auth = KRADServiceLocatorWeb.getDocumentDictionaryService().getDocumentAuthorizer(document); boolean valid = true; if (auth != null) { valid = auth.canEdit(document, GlobalVariables.getUserSession().getActualPerson()); } if (!valid) { this.putFieldError("dataObject.primaryDepartment", "error.primaryDepartment.invalid"); } return valid; }
@Override public boolean canMaintain(Object dataObject, Person user) { Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName(dataObject.getClass())); return isAuthorizedByTemplate(dataObject, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.EDIT_KPME_MAINTENANCE_DOCUMENT.getPermissionTemplateName(), user.getPrincipalId(), permissionDetails, getRoleQualification(dataObject, user.getPrincipalId())); }
@Override public void getMaintenanceActionLink(Action actionLink, Object model, String maintenanceMethodToCall) { super.getMaintenanceActionLink(actionLink, model, maintenanceMethodToCall); if (StringUtils.equals(actionLink.getActionLabel(), "copy")) { DocumentDictionaryService documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); Map<String, Object> context = actionLink.getContext(); PositionBo bo = ((PositionBo)context.get((String)"line")); if ( ! (((PositionDocumentAuthorizer)(documentDictionaryService.getDocumentAuthorizer(this.getMaintenanceDocumentTypeName()))).canCopy(bo, GlobalVariables.getUserSession().getPerson())) ) { actionLink.setRender(false); return; } } } }
public boolean canCopy (Object dataObject, Person user) { Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName(dataObject.getClass())); Map<String, String> q = getRoleQualification(dataObject, user.getPrincipalId()); if (isAuthorizedByTemplate(dataObject, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.COPY_KPME_MAINTENANCE_DOCUMENT.getPermissionTemplateName(), user.getPrincipalId(), permissionDetails, q)) { return true; } return false; }
@Override public boolean canCopy(Document document) { Maintainable obj = ((MaintenanceDocumentBase) document).getNewMaintainableObject(); //((MaintenanceDocumentBase) document).getDocumentHeader().ge DocumentDictionaryService documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); boolean canCopy = false; if (document.getAllowsCopy()) { canCopy = true; } if (!(((PositionDocumentAuthorizer)(documentDictionaryService.getDocumentAuthorizer((String)"PositionMaintenanceDocumentType"))).canCopy(obj.getDataObject(), GlobalVariables.getUserSession().getPerson()))) { canCopy = false; } return canCopy; } }
public List<TimeCollectionRule> getTimeCollectionRules(String userPrincipalId, List <TimeCollectionRule> timeCollectionRuleObjs){ List<TimeCollectionRule> results = new ArrayList<TimeCollectionRule>(); if ( timeCollectionRuleObjs != null ){ for (TimeCollectionRule timeCollectionRuleObj : timeCollectionRuleObjs) { String department = timeCollectionRuleObj.getDept(); String grpKeyCode = timeCollectionRuleObj.getGroupKeyCode(); Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department, grpKeyCode, timeCollectionRuleObj.getEffectiveLocalDate()); String location = departmentObj != null ? departmentObj.getGroupKey().getLocationId() : null; Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentTypeName(TimeCollectionRule.class)); Map<String, String> roleQualification = new HashMap<String, String>(); roleQualification.put(KimConstants.AttributeConstants.PRINCIPAL_ID, userPrincipalId); roleQualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department); roleQualification.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), grpKeyCode); roleQualification.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), location); if (!KimApiServiceLocator.getPermissionService().isPermissionDefinedByTemplate(KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails) || KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(userPrincipalId, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails, roleQualification)) { results.add(timeCollectionRuleObj); } } } return results; } }
public boolean canView(Object dataObject, Person user) { Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName(dataObject.getClass())); Map<String, String> roleQualifiers = getRoleQualification(dataObject, user.getPrincipalId()); if (KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(user.getPrincipalId(), KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), permissionDetails, roleQualifiers)) { return true; } if (KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(user.getPrincipalId(), KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.EDIT_KPME_MAINTENANCE_DOCUMENT.getPermissionTemplateName(), permissionDetails, roleQualifiers)) { return true; } return false; }
@Override public boolean canEdit(Document document, Person user) { Object dataObject = ((MaintenanceDocumentBase) document).getDocumentDataObject(); Map<String, String> permissionDetails = new HashMap<String, String>(); permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, getDocumentDictionaryService().getMaintenanceDocumentTypeName(dataObject.getClass())); permissionDetails.put(KimConstants.AttributeConstants.ROUTE_STATUS_CODE, ((MaintenanceDocumentBase)document).getDocumentHeader().getWorkflowDocument().getStatus().getCode() ); boolean canEdit = !permissionExistsByTemplate(KPMENamespace.KPME_WKFLW.getNamespaceCode(), org.kuali.kpme.core.api.permission.KPMEPermissionTemplate.EDIT_KPME_MAINTENANCE_DOCUMENT.getPermissionTemplateName(), permissionDetails) || isAuthorizedByTemplate(dataObject, KPMENamespace.KPME_WKFLW.getNamespaceCode(), org.kuali.kpme.core.api.permission.KPMEPermissionTemplate.EDIT_KPME_MAINTENANCE_DOCUMENT.getPermissionTemplateName(), user.getPrincipalId(), permissionDetails, getRoleQualification(dataObject, user.getPrincipalId())); if (!canEdit) { canEdit = canApprove(document, user); } return canEdit; }