Search in sources :

Example 1 with Vo

use of cz.metacentrum.perun.core.api.Vo in project perun by CESNET.

the class VosManagerEntry method getVoByShortName.

public Vo getVoByShortName(PerunSession sess, String shortName) throws VoNotExistsException, InternalErrorException, PrivilegeException {
    Utils.notNull(shortName, "shortName");
    Utils.notNull(sess, "sess");
    Vo vo = vosManagerBl.getVoByShortName(sess, shortName);
    // Authorization
    if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, vo) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.TOPGROUPCREATOR, vo) && !AuthzResolver.isAuthorized(sess, Role.ENGINE)) {
        throw new PrivilegeException(sess, "getVoByShortName");
    }
    return vo;
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) Vo(cz.metacentrum.perun.core.api.Vo)

Example 2 with Vo

use of cz.metacentrum.perun.core.api.Vo in project perun by CESNET.

the class VosManagerEntry method getVoById.

public Vo getVoById(PerunSession sess, int id) throws VoNotExistsException, InternalErrorException, PrivilegeException {
    Utils.notNull(sess, "sess");
    Vo vo = vosManagerBl.getVoById(sess, id);
    // Authorization
    if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, vo) && !AuthzResolver.isAuthorized(sess, Role.ENGINE) && !AuthzResolver.isAuthorized(sess, Role.RPC) && !AuthzResolver.isAuthorized(sess, Role.SELF)) {
        throw new PrivilegeException(sess, "getVoById");
    }
    return vo;
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) Vo(cz.metacentrum.perun.core.api.Vo)

Example 3 with Vo

use of cz.metacentrum.perun.core.api.Vo in project perun by CESNET.

the class urn_perun_resource_attribute_def_virt_voShortName method getAttributeValue.

public Attribute getAttributeValue(PerunSessionImpl sess, Resource resource, AttributeDefinition attributeDefinition) throws InternalErrorException {
    Attribute attribute = new Attribute(attributeDefinition);
    Vo vo = sess.getPerunBl().getResourcesManagerBl().getVo(sess, resource);
    attribute.setValue(vo.getShortName());
    return attribute;
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) Vo(cz.metacentrum.perun.core.api.Vo)

Example 4 with Vo

use of cz.metacentrum.perun.core.api.Vo in project perun by CESNET.

the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResource.

@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResource() throws Exception {
    System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromResource");
    //Prepare attribute, create it and set it with testing value
    Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
    perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
    //Prepare richAttribute with holders (attribute is not needed but holders are needed)
    RichAttribute richAttr = new RichAttribute();
    richAttr.setPrimaryHolder(resource2InVo2);
    List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
    assertTrue("return only 1 vo", listOfRichAttributes.size() == 1);
    assertTrue("primary holder is type of vo", listOfRichAttributes.get(0).getPrimaryHolder() instanceof Vo);
    assertTrue("secondary holder is null", listOfRichAttributes.get(0).getSecondaryHolder() == null);
    assertTrue("the Vo is vo2", vo2.equals(listOfRichAttributes.get(0).getPrimaryHolder()));
    assertTrue("attribute in richAttribute is equals to our attribute", (listOfRichAttributes.get(0).getAttribute()).equals(attribute));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Vo(cz.metacentrum.perun.core.api.Vo) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 5 with Vo

use of cz.metacentrum.perun.core.api.Vo in project perun by CESNET.

the class AttributesManagerEntryIntegrationTest method getRichAttributesWithHoldersForAttributeDefinitionGetVosFromHost.

@Test
public void getRichAttributesWithHoldersForAttributeDefinitionGetVosFromHost() throws Exception {
    System.out.println(CLASS_NAME + "getRichAttributesWithHoldersForAttributeDefinitionGetVosFromHost");
    //Prepare attribute, create it and set it with testing value
    Attribute attribute = setAttributeInNamespace(AttributesManager.NS_VO_ATTR);
    perun.getAttributesManagerBl().setAttribute(sess, vo2, attribute);
    perun.getAttributesManagerBl().setAttribute(sess, vo1, attribute);
    //Prepare richAttribute with holders (attribute is not needed but holders are needed)
    RichAttribute richAttr = new RichAttribute();
    richAttr.setPrimaryHolder(host1OnFacility2);
    List<RichAttribute> listOfRichAttributes = perun.getAttributesManagerBl().getRichAttributesWithHoldersForAttributeDefinition(sess, new AttributeDefinition(attribute), richAttr);
    //Return facilities Administrator too if exists
    assertTrue("return at least 2 vos", listOfRichAttributes.size() >= 2);
    assertTrue("return maximum of 3 vos", listOfRichAttributes.size() <= 3);
    assertTrue("primary holder is type of vo", listOfRichAttributes.get(0).getPrimaryHolder() instanceof Vo);
    assertTrue("secondary holder is null", listOfRichAttributes.get(0).getSecondaryHolder() == null);
    List<Vo> returnedVos = new ArrayList<Vo>();
    for (RichAttribute ra : listOfRichAttributes) {
        returnedVos.add((Vo) ra.getPrimaryHolder());
    }
    assertTrue("returned vos contains vo1", returnedVos.contains(vo1));
    assertTrue("returned vos contains vo2", returnedVos.contains(vo2));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) RichAttribute(cz.metacentrum.perun.core.api.RichAttribute) ArrayList(java.util.ArrayList) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Vo(cz.metacentrum.perun.core.api.Vo) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Aggregations

Vo (cz.metacentrum.perun.core.api.Vo)137 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)93 Test (org.junit.Test)93 Group (cz.metacentrum.perun.core.api.Group)48 Member (cz.metacentrum.perun.core.api.Member)40 User (cz.metacentrum.perun.core.api.User)32 Resource (cz.metacentrum.perun.core.api.Resource)31 Attribute (cz.metacentrum.perun.core.api.Attribute)21 ArrayList (java.util.ArrayList)19 RichResource (cz.metacentrum.perun.core.api.RichResource)18 RichUser (cz.metacentrum.perun.core.api.RichUser)17 ContactGroup (cz.metacentrum.perun.core.api.ContactGroup)16 ExtSource (cz.metacentrum.perun.core.api.ExtSource)16 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)15 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)13 Facility (cz.metacentrum.perun.core.api.Facility)13 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)13 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)12 Date (java.util.Date)12 RichGroup (cz.metacentrum.perun.core.api.RichGroup)11