use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_defaultDataQuota method getAttributeDefinition.
@Override
public AttributeDefinition getAttributeDefinition() {
AttributeDefinition attr = new AttributeDefinition();
attr.setNamespace(AttributesManager.NS_RESOURCE_ATTR_DEF);
attr.setFriendlyName("defaultDataQuota");
attr.setDisplayName("Default data quota");
attr.setType(String.class.getName());
attr.setDescription("Soft quota including units (M, G, T, ...), G is default.");
return attr;
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerBlImpl method getEntitylessAttributesWithKeys.
@Override
public Map<String, Attribute> getEntitylessAttributesWithKeys(PerunSession sess, String attrName) throws AttributeNotExistsException, WrongAttributeAssignmentException {
AttributeDefinition definition = getAttributeDefinition(sess, attrName);
List<String> keys = getEntitylessKeys(sess, definition);
return getEntitylessAttributesWithKeys(sess, attrName, keys);
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttributes.
private void removeAttributes(PerunSession sess, Resource resource, Member member, List<? extends AttributeDefinition> attributes, boolean workWithUserAttributes) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, MemberResourceMismatchException {
if (!(workWithUserAttributes)) {
removeAttributes(sess, member, resource, attributes);
} else {
List<AttributeDefinition> attributesToCheck = new ArrayList<>();
for (AttributeDefinition attribute : attributes) {
if (!getAttributesManagerImpl().isCoreAttribute(sess, attribute)) {
Facility facility = getPerunBl().getResourcesManagerBl().getFacility(sess, resource);
User user = getPerunBl().getUsersManagerBl().getUserByMember(sess, member);
if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_MEMBER_RESOURCE_ATTR)) {
if (removeAttributeWithoutCheck(sess, member, resource, attribute))
attributesToCheck.add(attribute);
} else if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_USER_FACILITY_ATTR)) {
if (removeAttributeWithoutCheck(sess, facility, user, attribute))
attributesToCheck.add(attribute);
} else if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_USER_ATTR)) {
if (removeAttributeWithoutCheck(sess, user, attribute))
attributesToCheck.add(attribute);
} else if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_MEMBER_ATTR)) {
if (removeAttributeWithoutCheck(sess, member, attribute))
attributesToCheck.add(attribute);
} else {
throw new WrongAttributeAssignmentException(attribute);
}
}
}
checkAttributesSemantics(sess, member, resource, attributesFromDefinitions(attributesToCheck), true);
checkAttributesDependencies(sess, member, resource, attributesFromDefinitions(attributesToCheck), true);
}
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttributeWithoutCheck.
private boolean removeAttributeWithoutCheck(PerunSession sess, UserExtSource ues, AttributeDefinition attribute) throws 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) {
getAttributesManagerImpl().changedAttributeHook(sess, ues, new Attribute(attribute));
log.info("{} removed attribute {} from user external source {}.", sess.getLogId(), attribute.getName(), ues.getId());
getPerunBl().getAuditer().log(sess, new AttributeRemovedForUes(new AttributeDefinition(attribute), ues));
}
return changed;
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerBlImpl method removeAttributes.
@Override
public void removeAttributes(PerunSession sess, Resource resource, Group group, List<? extends AttributeDefinition> attributes, boolean workWithGroupAttributes) throws WrongAttributeAssignmentException, WrongAttributeValueException, WrongReferenceAttributeValueException, GroupResourceMismatchException {
if (!workWithGroupAttributes) {
removeAttributes(sess, resource, group, attributes);
} else {
List<AttributeDefinition> attributesToCheck = new ArrayList<>();
for (AttributeDefinition attribute : attributes) {
// skip core attributes
if (!getAttributesManagerImpl().isCoreAttribute(sess, attribute)) {
if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_GROUP_RESOURCE_ATTR)) {
if (removeAttributeWithoutCheck(sess, resource, group, attribute))
attributesToCheck.add(attribute);
} else if (getAttributesManagerImpl().isFromNamespace(attribute, AttributesManager.NS_GROUP_ATTR)) {
if (removeAttributeWithoutCheck(sess, group, attribute))
attributesToCheck.add(attribute);
} else {
throw new WrongAttributeAssignmentException(attribute);
}
}
}
checkAttributesSemantics(sess, resource, group, attributesFromDefinitions(attributesToCheck), true);
checkAttributesDependencies(sess, group, resource, attributesFromDefinitions(attributesToCheck), true);
}
}
Aggregations