use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class AttributesManagerBlImpl method setAttributeWithoutCheck.
public boolean setAttributeWithoutCheck(PerunSession sess, Member member, Attribute attribute) throws InternalErrorException, WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_MEMBER_ATTR);
boolean changed = true;
if (isVirtAttribute(sess, attribute)) {
//TODO better exception here
try {
return getAttributesManagerImpl().setVirtualAttribute(sess, member, attribute);
} catch (WrongReferenceAttributeValueException ex) {
throw new InternalErrorException(ex);
}
//FIXME update "changed" variable
} else if (isCoreAttribute(sess, attribute)) {
//TODO better exception
try {
setCoreAttributeWithoutCheck(sess, member, attribute);
} catch (WrongReferenceAttributeValueException ex) {
throw new InternalErrorException(ex);
} catch (WrongAttributeValueException ex) {
throw new InternalErrorException(ex);
}
//FIXME check if attribute is acctualy changed
changed = true;
} else {
changed = getAttributesManagerImpl().setAttribute(sess, member, attribute);
}
if (changed) {
getPerunBl().getAuditer().log(sess, "{} set for {}.", attribute, member);
getAttributesManagerImpl().changedAttributeHook(sess, member, attribute);
}
return changed;
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttributeWithoutCheck.
public boolean removeAttributeWithoutCheck(PerunSession sess, Facility facility, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException {
getAttributesManagerImpl().checkNamespace(sess, attribute, NS_FACILITY_ATTR);
if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
throw new WrongAttributeAssignmentException(attribute);
boolean changed = getAttributesManagerImpl().removeAttribute(sess, facility, attribute);
if (changed) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, facility, new Attribute(attribute));
} catch (WrongAttributeValueException ex) {
//TODO better exception here
throw new InternalErrorException(ex);
} catch (WrongReferenceAttributeValueException ex) {
//TODO better exception here
throw new InternalErrorException(ex);
}
getPerunBl().getAuditer().log(sess, "{} removed for {}", attribute, facility);
}
return changed;
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllUserFacilityAttributes.
public void removeAllUserFacilityAttributes(PerunSession sess, User user) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException {
List<RichAttribute<User, Facility>> userFacilitiesAttributes = getAttributesManagerImpl().getAllUserFacilityRichAttributes(sess, user);
//remove all non-virtual attributes
getAttributesManagerImpl().removeAllUserFacilityAttributes(sess, user);
getPerunBl().getAuditer().log(sess, "All non-virtual user-facility attributes removed for all facilities and {}", user);
for (RichAttribute<User, Facility> richAttribute : userFacilitiesAttributes) {
try {
checkAttributeValue(sess, richAttribute.getSecondaryHolder(), richAttribute.getPrimaryHolder(), new Attribute(richAttribute.getAttribute()));
this.checkAttributeDependencies(sess, richAttribute);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
}
for (RichAttribute<User, Facility> attribute : userFacilitiesAttributes) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, attribute.getSecondaryHolder(), attribute.getPrimaryHolder(), new Attribute(attribute.getAttribute()));
} catch (WrongAttributeValueException ex) {
//TODO better exception here
throw new InternalErrorException(ex);
} catch (WrongReferenceAttributeValueException ex) {
//TODO better exception here
throw new InternalErrorException(ex);
}
}
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllAttributes.
public void removeAllAttributes(PerunSession sess, Facility facility, boolean removeAlsoUserFacilityAttributes) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException {
removeAllAttributes(sess, facility);
if (removeAlsoUserFacilityAttributes) {
List<Attribute> userFacilityAttributes = getUserFacilityAttributesForAnyUser(sess, facility);
getAttributesManagerImpl().removeAllUserFacilityAttributesForAnyUser(sess, facility);
getPerunBl().getAuditer().log(sess, "All user-facility attributes removed for {} for any user.", facility);
for (Attribute attribute : userFacilityAttributes) attribute.setValue(null);
List<User> facilityUsers = perunBl.getFacilitiesManagerBl().getAllowedUsers(sess, facility);
for (User user : facilityUsers) {
try {
checkAttributesValue(sess, facility, user, userFacilityAttributes);
this.checkAttributesDependencies(sess, facility, user, userFacilityAttributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
for (Attribute attribute : userFacilityAttributes) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, facility, user, new Attribute(attribute));
} catch (WrongAttributeValueException ex) {
//TODO better exception here
throw new InternalErrorException(ex);
} catch (WrongReferenceAttributeValueException ex) {
//TODO better exception here
throw new InternalErrorException(ex);
}
}
}
}
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_maxGID method checkAttributeValue.
public void checkAttributeValue(PerunSessionImpl sess, Facility facility, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
try {
Attribute gidNamespaceAttribute = getUnixGIDNamespaceAttribute(sess, facility);
if (gidNamespaceAttribute.getValue() == null)
throw new WrongReferenceAttributeValueException(attribute, gidNamespaceAttribute);
Attribute namespaceMaxGidAttribute = getNamespaceMaxGidAttribute(sess, (String) gidNamespaceAttribute.getValue());
sess.getPerunBl().getAttributesManagerBl().checkAttributeValue(sess, (String) gidNamespaceAttribute.getValue(), namespaceMaxGidAttribute);
} catch (WrongReferenceAttributeValueException ex) {
throw new WrongReferenceAttributeValueException(attribute, ex.getReferenceAttribute());
}
}
Aggregations