Search in sources :

Example 31 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class urn_perun_user_attribute_def_virt_institutionsCountries method resolveEvent.

private List<AuditEvent> resolveEvent(PerunSessionImpl sess, String key) throws WrongAttributeAssignmentException, AttributeNotExistsException {
    List<AuditEvent> resolvingMessages = new ArrayList<>();
    List<String> longerDomains = new ArrayList<>();
    AttributesManagerBl am = sess.getPerunBl().getAttributesManagerBl();
    for (String dnsDomain : am.getEntitylessStringAttributeMapping(sess, DNS_STATE_MAPPING_ATTR.getName()).keySet()) {
        if (dnsDomain.endsWith(key) && dnsDomain.length() > key.length()) {
            longerDomains.add(dnsDomain);
        }
    }
    log.debug("DNS domain '{}' changed, found longer domains: {}", key, longerDomains);
    // find users that are affected by the change - have schacHomeOrganization value ending in key but not ending with longerDomains
    List<User> affectedUsers = sess.getPerunBl().getUsersManagerBl().findUsersWithExtSourceAttributeValueEnding(sess, getSourceAttributeName(), key, longerDomains);
    for (User user : affectedUsers) {
        AttributeDefinition attributeDefinition = am.getAttributeDefinition(sess, getDestinationAttributeName());
        resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), user));
    }
    return resolvingMessages;
}
Also used : AttributeChangedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser) User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) ArrayList(java.util.ArrayList) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeChangedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl)

Example 32 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class urn_perun_group_attribute_def_virt_adDisplayName_o365muTest method setUp.

@Before
public void setUp() throws Exception {
    // prepare mocks
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    AttributesManagerBl am = mock(AttributesManagerBl.class);
    GroupsManagerBl gm = mock(GroupsManagerBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    when(perunBl.getAttributesManagerBl()).thenReturn(am);
    when(perunBl.getGroupsManagerBl()).thenReturn(gm);
    when(sess.getPerunBl().getGroupsManagerBl().getParentGroup(sess, groupB)).thenReturn(groupA);
    when(sess.getPerunBl().getGroupsManagerBl().getParentGroup(sess, groupC)).thenReturn(groupB);
    when(sess.getPerunBl().getGroupsManagerBl().getParentGroup(sess, groupD)).thenReturn(groupC);
    when(sess.getPerunBl().getGroupsManagerBl().getParentGroup(sess, groupE)).thenReturn(groupD);
    when(sess.getPerunBl().getGroupsManagerBl().getParentGroup(sess, groupF)).thenReturn(groupA);
    // group A is the main group with cispr 000000, it has no default display name
    setWhenClauseByParametersForGroup(sess, groupA, null, "000000", groupA.getName(), groupA.getDescription(), typeOfWorkplacesA);
    // group B is special group which should return null on display name
    setWhenClauseByParametersForGroup(sess, groupB, null, "000001", groupB.getName(), groupB.getDescription(), typeOfWorkplacesA);
    // group C is other part of university, it has no default display name
    setWhenClauseByParametersForGroup(sess, groupC, null, "110000", groupC.getName(), groupC.getDescription(), typeOfWorkplacesB);
    // group D is special group with predefined display name
    setWhenClauseByParametersForGroup(sess, groupD, predefinedDisplayName, null, null, null, null);
    // group E is other type of group, it has no default display name
    setWhenClauseByParametersForGroup(sess, groupE, null, "123456", groupE.getName(), groupE.getDescription(), typeOfWorkplacesC);
    // group E is other type of group, it has no default display name, but displayName is missing
    setWhenClauseByParametersForGroup(sess, groupF, null, "654321", groupF.getName(), groupF.getDescription(), typeOfWorkplacesB);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, groupWithoutAttributes, defaultAdDisplayNameAttrDef.getName())).thenThrow(AttributeNotExistsException.class);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, groupWithoutAttributes, inetCisprAttrDef.getName())).thenThrow(AttributeNotExistsException.class);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, groupWithoutAttributes, inetWorkplacesTypeCSAttrDef.getName())).thenThrow(AttributeNotExistsException.class);
}
Also used : GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 33 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class urn_perun_facility_attribute_def_virt_GIDRangesTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_facility_attribute_def_virt_GIDRanges();
    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);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 34 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class urn_perun_facility_attribute_def_def_pbsServerTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_facility_attribute_def_def_pbsServer();
    session = mock(PerunSessionImpl.class);
    facility = new Facility();
    attributeToCheck = new Attribute();
    Attribute name = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    FacilitiesManagerBl facilitiesManagerBl = mock(FacilitiesManagerBl.class);
    when(perunBl.getFacilitiesManagerBl()).thenReturn(facilitiesManagerBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(attributesManagerBl.getAttributeDefinition(session, AttributesManager.NS_FACILITY_ATTR_CORE + ":name")).thenReturn(name);
}
Also used : FacilitiesManagerBl(cz.metacentrum.perun.core.bl.FacilitiesManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 35 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class urn_perun_facility_attribute_def_def_reqAupsTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_facility_attribute_def_def_reqAups();
    session = mock(PerunSessionImpl.class);
    facility = new Facility();
    attributeToCheck = new Attribute();
    reqAttribute = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(session.getPerunBl().getAttributesManagerBl().getEntitylessAttributes(session, AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":orgAups")).thenReturn(Collections.singletonList(reqAttribute));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Aggregations

AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)56 Attribute (cz.metacentrum.perun.core.api.Attribute)48 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)44 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)43 Before (org.junit.Before)42 Facility (cz.metacentrum.perun.core.api.Facility)13 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)11 User (cz.metacentrum.perun.core.api.User)9 ArrayList (java.util.ArrayList)9 ResourcesManagerBl (cz.metacentrum.perun.core.bl.ResourcesManagerBl)8 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)6 UsersManagerBl (cz.metacentrum.perun.core.bl.UsersManagerBl)6 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)5 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)5 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)5 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)4 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)4 Group (cz.metacentrum.perun.core.api.Group)3 FacilitiesManagerBl (cz.metacentrum.perun.core.bl.FacilitiesManagerBl)3 AttributeChangedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser)2