Search in sources :

Example 26 with PerunBl

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

the class urn_perun_facility_attribute_def_virt_minUIDTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_facility_attribute_def_virt_minUID();
    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 27 with PerunBl

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

the class GroupAndGroupStructureSynchronizationIntegrationTest method setUpBaseGroup.

private void setUpBaseGroup(Vo vo) throws Exception {
    extSource = extSourceManagerBl.createExtSource(sess, extSource, null);
    Group returnedGroup = groupsManagerBl.createGroup(sess, vo, baseGroup);
    extSourceManagerBl.addExtSource(sess, vo, extSource);
    Attribute attr = attributesManagerBl.getAttribute(sess, baseGroup, GroupsManager.GROUPEXTSOURCE_ATTRNAME);
    attr.setValue(extSource.getName());
    attributesManagerBl.setAttribute(sess, baseGroup, attr);
    extSourceManagerBl.addExtSource(sess, baseGroup, extSource);
    Attribute membersQuery = new Attribute(((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, GroupsManager.GROUPMEMBERSQUERY_ATTRNAME));
    membersQuery.setValue("SELECT * from members where groupName='?';");
    attributesManagerBl.setAttribute(sess, baseGroup, membersQuery);
    Attribute interval = new Attribute(((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, GroupsManager.GROUPSYNCHROINTERVAL_ATTRNAME));
    interval.setValue("1");
    attributesManagerBl.setAttribute(sess, baseGroup, interval);
    AttributeDefinition loginAttrDef = setGroupAttribute("groupLogin");
    Attribute structureLoginName = new Attribute(((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, GroupsManager.GROUPS_STRUCTURE_LOGIN_ATTRNAME));
    structureLoginName.setValue(loginAttrDef.getName());
    attributesManagerBl.setAttribute(sess, baseGroup, structureLoginName);
    // create test Group in database
    assertNotNull("unable to create testing Group", returnedGroup);
}
Also used : Group(cz.metacentrum.perun.core.api.Group) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition)

Example 28 with PerunBl

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

the class Utils method parseAdditionalUserExtSource.

/**
 * Returns additional user ext source either found in Perun or creates new. Parameter userExtSourceRaw is array of
 * Strings containing name, type and extLogin. If any of the required parts is empty, ParserException is thrown.
 * Used in extractAdditionalUserExtSources to get ues.
 *
 * @param sess perun session
 * @param userExtSourceRaw array of strings containing all parts of ues
 * @return UserExtSource additional ues
 */
private static UserExtSource parseAdditionalUserExtSource(PerunSession sess, String[] userExtSourceRaw) {
    // Get extLogin from 3rd part of userExtSourceRaw as well as ues attributes, so it needs to be parsed from it
    String extLogin = userExtSourceRaw[2].split(";")[0];
    // Check whether any of the required parts of ues are not empty
    if (userExtSourceRaw[0].isEmpty() || userExtSourceRaw[1].isEmpty() || extLogin.isEmpty()) {
        throw new ParserException("Some of the required parts of userExtSource are empty.");
    }
    ExtSource additionalExtSource;
    try {
        // Try to get extSource, with full extSource object (containg ID)
        additionalExtSource = ((PerunBl) sess.getPerun()).getExtSourcesManagerBl().getExtSourceByName(sess, userExtSourceRaw[0]);
    } catch (ExtSourceNotExistsException e) {
        try {
            // Create new one if not exists
            additionalExtSource = new ExtSource(userExtSourceRaw[0], userExtSourceRaw[1]);
            additionalExtSource = ((PerunBl) sess.getPerun()).getExtSourcesManagerBl().createExtSource(sess, additionalExtSource, null);
        } catch (ExtSourceExistsException e1) {
            throw new ConsistencyErrorException("Creating existing extSource: " + userExtSourceRaw[0]);
        }
    }
    // Get optional LoA (0 if not stated)
    int loa = parseAdditionalUESLoa(userExtSourceRaw);
    return new UserExtSource(additionalExtSource, loa, extLogin);
}
Also used : ParserException(cz.metacentrum.perun.core.api.exceptions.ParserException) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) RichUserExtSource(cz.metacentrum.perun.core.api.RichUserExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSourceExistsException(cz.metacentrum.perun.core.api.exceptions.ExtSourceExistsException) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) RichUserExtSource(cz.metacentrum.perun.core.api.RichUserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException)

Example 29 with PerunBl

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

the class urn_perun_user_attribute_def_virt_loaTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_virt_loa();
    session = mock(PerunSessionImpl.class);
    user = new User(0, "John", "Doe", "", "", "");
    attributeToCheck = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
}
Also used : User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Example 30 with PerunBl

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

the class urn_perun_resource_attribute_def_def_replicaDestinationTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_resource_attribute_def_def_replicaDestination();
    attributeToCheck = new Attribute();
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
}
Also used : ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Aggregations

PerunBl (cz.metacentrum.perun.core.bl.PerunBl)130 Attribute (cz.metacentrum.perun.core.api.Attribute)93 Before (org.junit.Before)65 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)64 AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)48 User (cz.metacentrum.perun.core.api.User)41 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)37 ArrayList (java.util.ArrayList)22 Vo (cz.metacentrum.perun.core.api.Vo)21 Facility (cz.metacentrum.perun.core.api.Facility)19 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)19 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)19 ExtSource (cz.metacentrum.perun.core.api.ExtSource)16 Member (cz.metacentrum.perun.core.api.Member)16 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)16 UserExtSourceExistsException (cz.metacentrum.perun.core.api.exceptions.UserExtSourceExistsException)16 UsersManagerBl (cz.metacentrum.perun.core.bl.UsersManagerBl)15 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)14 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)13 Group (cz.metacentrum.perun.core.api.Group)12