use of cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllAttributes.
public void removeAllAttributes(PerunSession sess, Group group) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException {
List<Attribute> attributes = getAttributes(sess, group);
getAttributesManagerImpl().removeAllAttributes(sess, group);
getPerunBl().getAuditer().log(sess, "All attributes removed for {}", group);
for (Attribute attribute : attributes) attribute.setValue(null);
try {
checkAttributesValue(sess, group, attributes);
this.checkAttributesDependencies(sess, group, null, attributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
for (Attribute attribute : attributes) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, group, 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.WrongAttributeAssignmentException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttributeWithoutCheck.
public boolean removeAttributeWithoutCheck(PerunSession sess, UserExtSource ues, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException {
getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_UES_ATTR);
if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
throw new WrongAttributeAssignmentException(attribute);
boolean changed = getAttributesManagerImpl().removeAttribute(sess, ues, attribute);
if (changed) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, ues, 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, ues);
}
return changed;
}
use of cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttributeWithoutCheck.
public boolean removeAttributeWithoutCheck(PerunSession sess, Group group, AttributeDefinition attribute) throws InternalErrorException, WrongAttributeAssignmentException {
getAttributesManagerImpl().checkNamespace(sess, attribute, NS_GROUP_ATTR);
if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
throw new WrongAttributeAssignmentException(attribute);
boolean changed = getAttributesManagerImpl().removeAttribute(sess, group, attribute);
if (changed) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, group, 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, group);
}
return changed;
}
use of cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllAttributes.
public void removeAllAttributes(PerunSession sess, Host host) throws InternalErrorException, WrongAttributeValueException {
List<Attribute> attributes = getAttributes(sess, host);
getAttributesManagerImpl().removeAllAttributes(sess, host);
getPerunBl().getAuditer().log(sess, "All attributes removed for {}", host);
for (Attribute attribute : attributes) attribute.setValue(null);
try {
checkAttributesValue(sess, host, attributes);
this.checkAttributesDependencies(sess, host, null, attributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
} catch (WrongReferenceAttributeValueException ex) {
throw new WrongAttributeValueException(ex);
}
//TODO HOOK FOR HOSTS
/*
for(Attribute attribute: attributes) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, host, 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.WrongAttributeAssignmentException in project perun by CESNET.
the class AttributesManagerBlImpl method checkMemberIsFromTheSameVoLikeResource.
/**
* Check if member is assigned on resource. If not, throw WrongAttributeAssignment Exception
*
* @param sess
* @param member
* @param resource
* @throws WrongAttributeAssignmentException
* @throws InternalErrorException
* @throws MemberNotExistsException
* @throws ResourceNotExistsException
*/
private void checkMemberIsFromTheSameVoLikeResource(PerunSession sess, Member member, Resource resource) throws WrongAttributeAssignmentException, InternalErrorException {
Utils.notNull(sess, "sess");
Utils.notNull(member, "member");
Utils.notNull(resource, "resource");
if (member.getVoId() != resource.getVoId())
throw new WrongAttributeAssignmentException("Member is not from the same vo like Resource: " + member + " " + resource);
}
Aggregations