/** * Gets collections as map of collectionID => Group. * * @return Map of collection IDs to group. */ private Map<String, Group> getCollectionIDsToGroupsMap (PerunSession session, Perun perun, Group collectionsGroup) throws GroupNotExistsException, WrongAttributeAssignmentException, InternalErrorException, AttributeNotExistsException, PrivilegeException { Map<String, Group> collectionIDsToGroupMap = new HashMap<>(); for (Group group : perun.getGroupsManager().getSubGroups(session, collectionsGroup)) { for (Group subgroup : perun.getGroupsManager().getSubGroups(session, group)) { if (REPRESENTATIVES_GROUP_NAME.equals(subgroup.getShortName())) { Attribute collectionID = perun.getAttributesManager().getAttribute(session, subgroup, COLLECTION_ID_ATTR_NAME); collectionIDsToGroupMap.put(collectionID.valueAsString(), subgroup); } } } return collectionIDsToGroupMap; }
/** * Gets collections as map of collectionID => Group. * * @return Map of collection IDs to group. */ private Map<String, Group> getNetworkIDsToGroupsMap (PerunSession session, Perun perun, Group networksGroup) throws GroupNotExistsException, WrongAttributeAssignmentException, InternalErrorException, AttributeNotExistsException, PrivilegeException { Map<String, Group> networkIDsToGroupMap = new HashMap<>(); for (Group group : perun.getGroupsManager().getSubGroups(session, networksGroup)) { for (Group subgroup : perun.getGroupsManager().getSubGroups(session, group)) { if (REPRESENTATIVES_GROUP_NAME.equals(subgroup.getShortName())) { Attribute networkID = perun.getAttributesManager().getAttribute(session, subgroup, NETWORK_ID_ATTR_NAME); networkIDsToGroupMap.put(networkID.valueAsString(), subgroup); } } } return networkIDsToGroupMap; }
@Override public Application approveApplication(PerunSession sess, Application application) throws PerunException { if (application.getType() == Application.AppType.INITIAL) { List<ApplicationFormItemData> applicationData = registrar.getApplicationDataById(sess, application.getId()); String nickName = null; for (ApplicationFormItemData appItem : applicationData) { if (APPLICATION_NICKNAME_ITEM.equals(appItem.getShortname())) { nickName = appItem.getValue(); } } if (nickName != null && !nickName.trim().isEmpty()) { User user = application.getUser(); Attribute loginAttribute; try { loginAttribute = sess.getPerun().getAttributesManager().getAttribute(sess, user, A_U_D_EDUTEAMS_NICKNAME); } catch (AttributeNotExistsException e) { // do not set the login if the attribute does not exist return application; } loginAttribute.setValue(nickName); sess.getPerun().getAttributesManager().setAttribute(sess, user, loginAttribute); } } return application; }
@Override public Application beforeApprove(PerunSession session, Application app) throws PerunException { Group group = app.getGroup(); if (group == null) { throw new CantBeApprovedException("This module can be set only for registration to Group."); } AttributesManager am = session.getPerun().getAttributesManager(); Attribute attestation = am.getAttribute(session, group, A_G_D_groupAttestation); if (attestation == null) { throw new CantBeApprovedException("Application cannot be approved: Group does not have attestation attribute set."); } String newValue = attestation.valueAsString(); if (newValue == null || newValue.isEmpty()) { throw new CantBeApprovedException("Application cannot be approved: Group does not have attestation value set."); } return app; }
.getAttributesManager() .getRequiredAttributesDefinition(perunSession, s); if (!serviceRequiredAttributes.contains(attributeDefinition))
/** * Add new bonaFideStatus to the user attribute. */ @Override public Application approveApplication(PerunSession session, Application app) throws PerunException { User user = app.getUser(); Group group = app.getGroup(); AttributesManager am = session.getPerun().getAttributesManager(); Attribute attestation = am.getAttribute(session, group, A_G_D_groupAttestation); String newValue = attestation.valueAsString(); Attribute bonaFideStatus = am.getAttribute(session, user, A_U_D_userBonaFideStatus); List<String> value = new ArrayList<>(); if (bonaFideStatus.getValue() != null && bonaFideStatus.valueAsList() != null) { value = bonaFideStatus.valueAsList(); } value.add(newValue); bonaFideStatus.setValue(value); am.setAttribute(session, user, bonaFideStatus); return app; }
throw new CantBeSubmittedException("This module can be set only for registration to Group."); AttributesManager am = session.getPerun().getAttributesManager();
Attribute isStatisticGroup = perun.getAttributesManager().getAttribute(session, group, "urn:perun:group:attribute-def:def:statisticGroup"); Attribute isStatisticGroupAutoFill = perun.getAttributesManager().getAttribute(session, group, "urn:perun:group:attribute-def:def:statisticGroupAutoFill");