Search in sources :

Example 11 with WrongReferenceAttributeValueException

use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException 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 WrongReferenceAttributeValueException

use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException 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 13 with WrongReferenceAttributeValueException

use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException 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 14 with WrongReferenceAttributeValueException

use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException 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)

Example 15 with WrongReferenceAttributeValueException

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

the class urn_perun_group_resource_attribute_def_virt_unixGroupName method getAttributeValue.

@Override
public Attribute getAttributeValue(PerunSessionImpl sess, Resource resource, Group group, AttributeDefinition attributeDefinition) throws InternalErrorException {
    Attribute attribute = new Attribute(attributeDefinition);
    Attribute unixGroupNameNamespaceAttribute;
    try {
        unixGroupNameNamespaceAttribute = sess.getPerunBl().getModulesUtilsBl().getUnixGroupNameNamespaceAttributeWithNotNullValue(sess, resource);
    } catch (WrongReferenceAttributeValueException ex) {
        return attribute;
    }
    try {
        Attribute groupNameAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:" + unixGroupNameNamespaceAttribute.getValue());
        attribute = Utils.copyAttributeToVirtualAttributeWithValue(groupNameAttribute, attribute);
        return attribute;
    } catch (WrongAttributeAssignmentException ex) {
        throw new InternalErrorException(ex);
    } catch (AttributeNotExistsException ex) {
        throw new ConsistencyErrorException(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) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Aggregations

WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)109 Attribute (cz.metacentrum.perun.core.api.Attribute)101 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)83 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)70 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)64 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)62 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)51 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)27 Resource (cz.metacentrum.perun.core.api.Resource)13 ArrayList (java.util.ArrayList)13 Facility (cz.metacentrum.perun.core.api.Facility)12 Matcher (java.util.regex.Matcher)12 User (cz.metacentrum.perun.core.api.User)11 Group (cz.metacentrum.perun.core.api.Group)9 BigDecimal (java.math.BigDecimal)6 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)5 List (java.util.List)5 Pattern (java.util.regex.Pattern)5 Pair (cz.metacentrum.perun.core.api.Pair)3 LinkedHashMap (java.util.LinkedHashMap)3