use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class urn_perun_member_attribute_def_def_workplace method changedAttributeHook.
@Override
public void changedAttributeHook(PerunSessionImpl session, Member member, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException {
User user = session.getPerunBl().getUsersManagerBl().getUserByMember(session, member);
if (attribute.getValue() != null) {
Attribute userWorkplace = null;
try {
userWorkplace = session.getPerunBl().getAttributesManagerBl().getAttribute(session, user, A_U_workplace);
if (userWorkplace.getValue() == null) {
userWorkplace.setValue(attribute.getValue());
session.getPerunBl().getAttributesManagerBl().setAttribute(session, user, userWorkplace);
}
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException(ex);
} catch (AttributeNotExistsException ex) {
throw new ConsistencyErrorException(ex);
} catch (WrongAttributeValueException ex) {
throw new WrongReferenceAttributeValueException(attribute, userWorkplace, "Mismatch in checking of member workplace and user workplace (different checking rules)", 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, Resource resource, Member member) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
this.checkMemberIsFromTheSameVoLikeResource(sess, member, resource);
List<Attribute> attributes = getAttributes(sess, resource, member);
getAttributesManagerImpl().removeAllAttributes(sess, resource, member);
getPerunBl().getAuditer().log(sess, "All attributes removed for {} and {}", resource, member);
for (Attribute attribute : attributes) attribute.setValue(null);
try {
checkAttributesValue(sess, resource, member, attributes);
checkAttributesValue(sess, resource, member, attributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
for (Attribute attribute : attributes) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, resource, member, 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 AttributesManagerBlImpl method removeAttributeWithoutCheck.
public boolean removeAttributeWithoutCheck(PerunSession sess, String key, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException {
getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_ENTITYLESS_ATTR);
boolean changed = getAttributesManagerImpl().removeAttribute(sess, key, attribute);
if (changed) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, key, 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, key);
}
return changed;
}
use of cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException in project perun by CESNET.
the class AttributesManagerBlImpl method setAttributeWithoutCheck.
public boolean setAttributeWithoutCheck(PerunSession sess, Facility facility, User user, Attribute attribute) throws InternalErrorException, WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_USER_FACILITY_ATTR);
if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
throw new WrongAttributeAssignmentException(attribute);
boolean changed = true;
if (getAttributesManagerImpl().isVirtAttribute(sess, attribute)) {
//TODO better exception here
try {
changed = getAttributesManagerImpl().setVirtualAttribute(sess, facility, user, attribute);
} catch (WrongReferenceAttributeValueException ex) {
throw new InternalErrorException(ex);
}
//FIXME update changed variable
} else {
changed = getAttributesManagerImpl().setAttribute(sess, facility, user, attribute);
}
if (changed) {
getPerunBl().getAuditer().log(sess, "{} set for {} and {}.", attribute, facility, user);
getAttributesManagerImpl().changedAttributeHook(sess, facility, user, 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, Vo vo, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException {
getAttributesManagerImpl().checkNamespace(sess, attribute, NS_VO_ATTR);
if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
throw new WrongAttributeAssignmentException(attribute);
boolean changed = getAttributesManagerImpl().removeAttribute(sess, vo, attribute);
if (changed) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, vo, 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, vo);
}
return changed;
}
Aggregations