Search in sources :

Example 11 with AttributeNotExistsException

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

the class urn_perun_group_resource_attribute_def_virt_unixGID method fillAttribute.

@Override
public Attribute fillAttribute(PerunSessionImpl sess, Resource resource, Group group, AttributeDefinition attributeDefinition) throws InternalErrorException, WrongAttributeAssignmentException {
    Attribute attribute = new Attribute(attributeDefinition);
    Attribute unixGIDNamespaceAttribute;
    try {
        unixGIDNamespaceAttribute = sess.getPerunBl().getModulesUtilsBl().getUnixGIDNamespaceAttributeWithNotNullValue(sess, resource);
    } catch (WrongReferenceAttributeValueException ex) {
        return attribute;
    }
    Attribute gidAttribute;
    try {
        gidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:" + unixGIDNamespaceAttribute.getValue());
    } catch (AttributeNotExistsException ex) {
        throw new ConsistencyErrorException(ex);
    }
    try {
        sess.getPerunBl().getAttributesManagerBl().forceCheckAttributeValue(sess, group, gidAttribute);
        //check passed, we can use value from this physical attribute
        attribute.setValue(gidAttribute.getValue());
        return attribute;
    } catch (WrongAttributeValueException ex) {
        //Physical attribute have wrong value, let's find a new one
        gidAttribute.setValue(null);
        gidAttribute = sess.getPerunBl().getAttributesManagerBl().fillAttribute(sess, group, gidAttribute);
        attribute.setValue(gidAttribute.getValue());
        return attribute;
    } catch (WrongReferenceAttributeValueException ex) {
        return attribute;
    }
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Example 12 with AttributeNotExistsException

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

the class urn_perun_group_resource_attribute_def_virt_unixGID method setAttributeValue.

@Override
public boolean setAttributeValue(PerunSessionImpl sess, Resource resource, Group group, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException {
    Attribute unixGIDNamespaceAttribute = sess.getPerunBl().getModulesUtilsBl().getUnixGIDNamespaceAttributeWithNotNullValue(sess, resource);
    try {
        Attribute gidAttribute = new Attribute(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:" + unixGIDNamespaceAttribute.getValue()));
        gidAttribute.setValue(attribute.getValue());
        return sess.getPerunBl().getAttributesManagerBl().setAttributeWithoutCheck(sess, group, gidAttribute);
    } catch (WrongAttributeValueException ex) {
        throw new InternalErrorException(ex);
    } catch (AttributeNotExistsException ex) {
        throw new ConsistencyErrorException(ex);
    } catch (WrongAttributeAssignmentException ex) {
        throw new InternalErrorException(ex);
    }
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Example 13 with AttributeNotExistsException

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

the class urn_perun_group_resource_attribute_def_virt_unixGID method checkAttributeValue.

@Override
public void checkAttributeValue(PerunSessionImpl sess, Resource resource, Group group, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException {
    Attribute unixGIDNamespaceAttribute = sess.getPerunBl().getModulesUtilsBl().getUnixGIDNamespaceAttributeWithNotNullValue(sess, resource);
    Attribute gidAttribute;
    try {
        gidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:" + unixGIDNamespaceAttribute.getValue());
    } catch (AttributeNotExistsException ex) {
        throw new ConsistencyErrorException(ex);
    }
    gidAttribute.setValue(attribute.getValue());
    try {
        sess.getPerunBl().getAttributesManagerBl().forceCheckAttributeValue(sess, group, gidAttribute);
    } catch (WrongAttributeValueException ex) {
        throw new WrongAttributeValueException(attribute, ex.getMessage(), ex);
    } catch (WrongReferenceAttributeValueException ex) {
        throw new WrongReferenceAttributeValueException(attribute, ex.getAttribute(), ex);
    }
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Example 14 with AttributeNotExistsException

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

the class urn_perun_group_resource_attribute_def_virt_googleGroupName method checkAttributeValue.

@Override
public void checkAttributeValue(PerunSessionImpl sess, Resource resource, Group group, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException {
    Attribute googleGroupNameNamespaceAttribute = sess.getPerunBl().getModulesUtilsBl().getGoogleGroupNameNamespaceAttributeWithNotNullValue(sess, resource);
    Attribute groupNameAttribute;
    try {
        groupNameAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, AttributesManager.NS_GROUP_ATTR_DEF + ":googleGroupName-namespace:" + googleGroupNameNamespaceAttribute.getValue());
    } catch (AttributeNotExistsException ex) {
        throw new ConsistencyErrorException(ex);
    }
    groupNameAttribute.setValue(attribute.getValue());
    try {
        sess.getPerunBl().getAttributesManagerBl().checkAttributeValue(sess, group, groupNameAttribute);
    } catch (WrongAttributeValueException ex) {
        throw new WrongAttributeValueException(attribute, ex.getMessage(), ex);
    } catch (WrongReferenceAttributeValueException ex) {
        throw new WrongReferenceAttributeValueException(attribute, ex.getAttribute(), ex);
    }
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Example 15 with AttributeNotExistsException

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

the class urn_perun_group_resource_attribute_def_virt_unixGroupName method fillAttribute.

@Override
public Attribute fillAttribute(PerunSessionImpl sess, Resource resource, Group group, AttributeDefinition attributeDefinition) throws InternalErrorException, WrongAttributeAssignmentException {
    Attribute attribute = new Attribute(attributeDefinition);
    Attribute unixGroupNameNamespaceAttribute;
    try {
        unixGroupNameNamespaceAttribute = sess.getPerunBl().getModulesUtilsBl().getUnixGroupNameNamespaceAttributeWithNotNullValue(sess, resource);
    } catch (WrongReferenceAttributeValueException ex) {
        return attribute;
    }
    Attribute groupNameAttribute;
    try {
        groupNameAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:" + unixGroupNameNamespaceAttribute.getValue());
    } catch (AttributeNotExistsException ex) {
        throw new ConsistencyErrorException(ex);
    }
    try {
        sess.getPerunBl().getAttributesManagerBl().checkAttributeValue(sess, group, groupNameAttribute);
        //check passed, we can use value from this physical attribute
        attribute.setValue(groupNameAttribute.getValue());
        return attribute;
    } catch (WrongAttributeValueException ex) {
        //Physical attribute have wrong value, let's find a new one
        groupNameAttribute.setValue(null);
        groupNameAttribute = sess.getPerunBl().getAttributesManagerBl().fillAttribute(sess, group, groupNameAttribute);
        attribute.setValue(groupNameAttribute.getValue());
        return attribute;
    } catch (WrongReferenceAttributeValueException ex) {
        return attribute;
    }
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Aggregations

AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)138 Attribute (cz.metacentrum.perun.core.api.Attribute)120 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)94 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)81 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)75 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)64 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)59 ArrayList (java.util.ArrayList)30 Resource (cz.metacentrum.perun.core.api.Resource)25 Matcher (java.util.regex.Matcher)19 Facility (cz.metacentrum.perun.core.api.Facility)17 User (cz.metacentrum.perun.core.api.User)17 LinkedHashMap (java.util.LinkedHashMap)15 Group (cz.metacentrum.perun.core.api.Group)14 Map (java.util.Map)13 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)12 List (java.util.List)11 HashSet (java.util.HashSet)8 BigDecimal (java.math.BigDecimal)7 Pattern (java.util.regex.Pattern)6