use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAllAttributes.
@Override
public void removeAllAttributes(PerunSession sess, Group group) throws WrongAttributeValueException, WrongReferenceAttributeValueException {
List<Attribute> attributes = getAttributes(sess, group);
if (getAttributesManagerImpl().removeAllAttributes(sess, group)) {
getPerunBl().getAuditer().log(sess, new AllAttributesRemovedForGroup(group));
}
log.info("{} removed all attributes from group {}.", sess.getLogId(), group.getId());
for (Attribute attribute : attributes) attribute.setValue(null);
try {
checkAttributesSemantics(sess, group, attributes);
checkAttributesDependencies(sess, group, attributes);
} catch (WrongAttributeAssignmentException ex) {
throw new ConsistencyErrorException(ex);
}
for (Attribute attribute : attributes) {
try {
getAttributesManagerImpl().changedAttributeHook(sess, group, new Attribute(attribute));
} catch (WrongReferenceAttributeValueException ex) {
throw new InternalErrorException(ex);
}
}
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class AttributesManagerBlImpl method getMemberResourceAttributes.
/**
* Returns all relevant MemberResource RichAttributes for given resource.
* That means, returns all MemberResource rich attributes for the given resource and for those members that can
* access the given resource and are allowed.
* Each rich attribute is returned only once.
*
* @param sess session
* @param resource resource
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getMemberResourceAttributes(PerunSession sess, Resource resource, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, MemberResourceMismatchException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
List<Member> members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
for (Member memberElement : members) {
if (getPerunBl().getMembersManagerBl().isMemberAllowed(sess, memberElement)) {
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, memberElement, resource, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(resource, memberElement, attribute));
}
}
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttribute.
@Override
public void removeAttribute(PerunSession sess, User user, AttributeDefinition attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException {
if (removeAttributeWithoutCheck(sess, user, attribute)) {
checkAttributeSemantics(sess, user, new Attribute(attribute));
checkAttributeDependencies(sess, new RichAttribute<>(user, null, new Attribute(attribute)));
}
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class AttributesManagerBlImpl method getMemberGroupAttributes.
/**
* Returns all relevant MemberGroup RichAttributes for given member and group.
* That means, returns all MemberGroup rich attributes for the given member and group.
* If the member is not allowed, an empty list is returned.
* Each rich attribute is returned only once.
*
* @param sess session
* @param member member
* @param group group
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getMemberGroupAttributes(PerunSession sess, Member member, Group group, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException, MemberGroupMismatchException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
if (getPerunBl().getMembersManagerBl().isMemberAllowed(sess, member)) {
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, member, group, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(member, group, attribute));
}
return listOfRichAttributes;
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class AttributesManagerBlImpl method getEntitylessAttributes.
/**
* Returns all entityless rich attributes for the given key.
* Each rich attribute is returned only once.
*
* @param sess session
* @param key key
* @param attrDef type of attribute that will be returned
* @return List of RichAttribute
*/
private List<RichAttribute> getEntitylessAttributes(PerunSession sess, String key, AttributeDefinition attrDef) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<RichAttribute> listOfRichAttributes = new ArrayList<>();
Attribute attribute = getPerunBl().getAttributesManagerBl().getAttribute(sess, key, attrDef.getName());
listOfRichAttributes.add(new RichAttribute<>(key, null, attribute));
listOfRichAttributes = new ArrayList<>(new HashSet<>(listOfRichAttributes));
return listOfRichAttributes;
}
Aggregations