Search in sources :

Example 41 with WrongReferenceAttributeValueException

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

the class urn_perun_facility_attribute_def_virt_maxGID method setAttributeValue.

public boolean setAttributeValue(PerunSessionImpl sess, Facility facility, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException {
    Attribute gidNamespaceAttribute = getUnixGIDNamespaceAttribute(sess, facility);
    if (gidNamespaceAttribute.getValue() == null)
        throw new WrongReferenceAttributeValueException(attribute, gidNamespaceAttribute);
    Attribute namespaceMaxGidAttribute = getNamespaceMaxGidAttribute(sess, (String) gidNamespaceAttribute.getValue());
    if (!(attribute.getValue() == null ? namespaceMaxGidAttribute.getValue() == null : attribute.getValue().equals(namespaceMaxGidAttribute.getValue()))) {
        //attribute from param have other vale then physical attribute
        throw new WrongReferenceAttributeValueException(attribute, namespaceMaxGidAttribute);
    }
    return false;
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)

Example 42 with WrongReferenceAttributeValueException

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

the class urn_perun_facility_attribute_def_virt_minUID method getAttributeValue.

public Attribute getAttributeValue(PerunSessionImpl sess, Facility facility, AttributeDefinition attributeDefinition) throws InternalErrorException {
    Attribute attribute = new Attribute(attributeDefinition);
    try {
        Attribute uidNamespaceAttribute = getUidNamespaceAttribute(sess, facility);
        if (uidNamespaceAttribute.getValue() == null)
            return attribute;
        Attribute namespaceMinUidAttribute = getNamespaceMinUidAttribute(sess, (String) uidNamespaceAttribute.getValue());
        attribute = Utils.copyAttributeToVirtualAttributeWithValue(namespaceMinUidAttribute, attribute);
        return attribute;
    } catch (WrongReferenceAttributeValueException ex) {
        return attribute;
    }
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)

Example 43 with WrongReferenceAttributeValueException

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

the class urn_perun_facility_attribute_def_virt_minUID method setAttributeValue.

public boolean setAttributeValue(PerunSessionImpl sess, Facility facility, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException {
    Attribute uidNamespaceAttribute = getUidNamespaceAttribute(sess, facility);
    if (uidNamespaceAttribute.getValue() == null)
        throw new WrongReferenceAttributeValueException(attribute, uidNamespaceAttribute);
    Attribute namespaceMinUidAttribute = getNamespaceMinUidAttribute(sess, (String) uidNamespaceAttribute.getValue());
    if (!(attribute.getValue() == null ? namespaceMinUidAttribute.getValue() == null : attribute.getValue().equals(namespaceMinUidAttribute.getValue()))) {
        //attribute from param have other vale then physical attribute
        throw new WrongReferenceAttributeValueException(attribute, namespaceMinUidAttribute);
    }
    return false;
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)

Example 44 with WrongReferenceAttributeValueException

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

the class urn_perun_facility_attribute_def_virt_minUID method checkAttributeValue.

public void checkAttributeValue(PerunSessionImpl sess, Facility facility, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
    try {
        Attribute uidNamespaceAttribute = getUidNamespaceAttribute(sess, facility);
        if (uidNamespaceAttribute.getValue() == null)
            throw new WrongReferenceAttributeValueException(attribute, uidNamespaceAttribute);
        Attribute namespaceMinUidAttribute = getNamespaceMinUidAttribute(sess, (String) uidNamespaceAttribute.getValue());
        sess.getPerunBl().getAttributesManagerBl().checkAttributeValue(sess, (String) uidNamespaceAttribute.getValue(), namespaceMinUidAttribute);
    } catch (WrongReferenceAttributeValueException ex) {
        throw new WrongReferenceAttributeValueException(attribute, ex.getReferenceAttribute());
    }
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)

Example 45 with WrongReferenceAttributeValueException

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

the class urn_perun_facility_attribute_def_virt_maxUID method setAttributeValue.

public boolean setAttributeValue(PerunSessionImpl sess, Facility facility, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException {
    Attribute uidNamespaceAttribute = getUidNamespaceAttribute(sess, facility);
    if (uidNamespaceAttribute.getValue() == null)
        throw new WrongReferenceAttributeValueException(attribute, uidNamespaceAttribute);
    Attribute namespaceMaxUidAttribute = getNamespaceMaxUidAttribute(sess, (String) uidNamespaceAttribute.getValue());
    if (!(attribute.getValue() == null ? namespaceMaxUidAttribute.getValue() == null : attribute.getValue().equals(namespaceMaxUidAttribute.getValue()))) {
        //attribute from param have other vale then physical attribute
        throw new WrongReferenceAttributeValueException(attribute, namespaceMaxUidAttribute);
    }
    return false;
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)

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