use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class ElixirBonaFideStatus method canBeSubmitted.
/**
* Validate if the user meets criteria for applying to group.
*/
@Override
public void canBeSubmitted(PerunSession session, Application.AppType appType, Map<String, String> params) throws PerunException {
User user = session.getPerunPrincipal().getUser();
if (user == null) {
throw new CantBeSubmittedException("This module can be set only for registration to Group.");
}
AttributesManagerBl am = ((PerunBl) session.getPerun()).getAttributesManagerBl();
Attribute affiliations = am.getAttribute(session, user, A_U_D_userEduPersonScopedAffiliations);
if (affiliations.getValue() != null) {
List<String> val = affiliations.valueAsList();
for (String affiliation : val) {
if (affiliation.startsWith("faculty@")) {
return;
}
}
}
Attribute rems = am.getAttribute(session, user, A_U_D_userBonaFideStatusRems);
if (rems.getValue() != null) {
return;
}
throw new CantBeSubmittedException("User does not meet the criteria for applying for Bona Fide Status");
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class ElixirBonaFideStatus method beforeApprove.
@Override
public Application beforeApprove(PerunSession session, Application app) throws CantBeApprovedException {
Group group = app.getGroup();
if (group == null) {
throw new CantBeApprovedException("This module can be set only for registration to Group.");
}
AttributesManagerBl am = ((PerunBl) session.getPerun()).getAttributesManagerBl();
Attribute attestation;
try {
attestation = am.getAttribute(session, group, A_G_D_groupAttestation);
} catch (Exception e) {
throw new InternalErrorException(e.getMessage(), e);
}
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;
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_entityless_attribute_def_def_namespace_minUIDTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_entityless_attribute_def_def_namespace_minUID();
session = mock(PerunSessionImpl.class);
attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
reqAttribute = new Attribute(classInstance.getAttributeDefinition());
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, key, AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-maxUID")).thenReturn(reqAttribute);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_facility_attribute_def_def_unixGID_namespaceTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_facility_attribute_def_def_unixGID_namespace();
session = mock(PerunSessionImpl.class);
facility = new Facility();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("friendly_name");
reqAttribute = new Attribute();
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_maxUIDTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_facility_attribute_def_virt_maxUID();
session = mock(PerunSessionImpl.class);
facility = new Facility();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("friendly_name");
reqAttribute = new Attribute();
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
}
Aggregations