use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_maxUID 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 namespaceMaxUidAttribute = getNamespaceMaxUidAttribute(sess, (String) uidNamespaceAttribute.getValue());
sess.getPerunBl().getAttributesManagerBl().checkAttributeValue(sess, (String) uidNamespaceAttribute.getValue(), namespaceMaxUidAttribute);
} catch (WrongReferenceAttributeValueException ex) {
throw new WrongReferenceAttributeValueException(attribute, ex.getReferenceAttribute());
}
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_maxUID 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 namespaceMaxUidAttribute = getNamespaceMaxUidAttribute(sess, (String) uidNamespaceAttribute.getValue());
attribute = Utils.copyAttributeToVirtualAttributeWithValue(namespaceMaxUidAttribute, attribute);
return attribute;
} catch (WrongReferenceAttributeValueException ex) {
return attribute;
}
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_minGID method getAttributeValue.
public Attribute getAttributeValue(PerunSessionImpl sess, Facility facility, AttributeDefinition attributeDefinition) throws InternalErrorException {
Attribute attribute = new Attribute(attributeDefinition);
try {
Attribute gidNamespaceAttribute = getUnixGIDNamespaceAttribute(sess, facility);
if (gidNamespaceAttribute.getValue() == null)
return attribute;
Attribute namespaceMinGidAttribute = getNamespaceMinGidAttribute(sess, (String) gidNamespaceAttribute.getValue());
attribute = Utils.copyAttributeToVirtualAttributeWithValue(namespaceMinGidAttribute, attribute);
return attribute;
} catch (WrongReferenceAttributeValueException ex) {
return attribute;
}
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_minGID 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 namespaceMinGidAttribute = getNamespaceMinGidAttribute(sess, (String) gidNamespaceAttribute.getValue());
if (!(attribute.getValue() == null ? namespaceMinGidAttribute.getValue() == null : attribute.getValue().equals(namespaceMinGidAttribute.getValue()))) {
//attribute from param have other vale then physical attribute
throw new WrongReferenceAttributeValueException(attribute, namespaceMinGidAttribute);
}
return false;
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_member_resource_attribute_def_def_filesQuota method checkAttributeValue.
@Override
public void checkAttributeValue(PerunSessionImpl perunSession, Resource resource, Member member, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
Attribute attrFilesLimit = null;
Integer filesQuota = null;
Integer filesLimit = null;
//Get FilesLimit attribute
try {
attrFilesLimit = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, resource, member, A_MR_filesLimit);
} catch (AttributeNotExistsException ex) {
throw new ConsistencyErrorException(attribute + " from member " + member.getId() + " and resource " + resource.getId() + " could not obtained.", ex);
}
//Get FilesQuota value
if (attribute.getValue() != null) {
filesQuota = (Integer) attribute.getValue();
} else {
try {
attribute = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, resource, A_R_defaultFilesQuota);
} catch (AttributeNotExistsException ex) {
throw new ConsistencyErrorException("Attribute with defaultFilesQuota from resource " + resource.getId() + " could not obtained.", ex);
}
if (attribute != null && attribute.getValue() != null) {
filesQuota = (Integer) attribute.getValue();
}
}
if (filesQuota != null && filesQuota < 0)
throw new WrongAttributeValueException(attribute, resource, member, attribute + " cannot be less than 0.");
//Get FilesLimit value
if (attrFilesLimit != null && attrFilesLimit.getValue() != null) {
filesLimit = (Integer) attrFilesLimit.getValue();
} else if (attrFilesLimit == null || attrFilesLimit.getValue() == null) {
try {
attrFilesLimit = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, resource, A_R_defaultFilesLimit);
} catch (AttributeNotExistsException ex) {
throw new ConsistencyErrorException("Attribute with defaultFilesLimit from resource " + resource.getId() + " could not obtained.", ex);
}
if (attrFilesLimit != null || attrFilesLimit.getValue() != null) {
filesLimit = (Integer) attrFilesLimit.getValue();
}
}
if (filesLimit != null && filesLimit < 0)
throw new ConsistencyErrorException(attrFilesLimit + " cannot be less than 0.");
//Compare filesQuota with filesLimit
if (filesQuota == null || filesQuota == 0) {
if (filesLimit != null && filesLimit != 0)
throw new WrongReferenceAttributeValueException(attribute, attrFilesLimit, resource, member, resource, null, "Try to set unlimited quota, but limit is still " + filesLimit);
} else if (filesLimit != null && filesLimit != 0) {
if (filesLimit < filesQuota)
throw new WrongReferenceAttributeValueException(attribute, attrFilesLimit, resource, member, resource, null, attribute + " must be less than or equal to " + attrFilesLimit);
}
}
Aggregations