use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntry method checkAttributeValue.
public void checkAttributeValue(PerunSession sess, Resource resource, Attribute attribute) throws PrivilegeException, InternalErrorException, ResourceNotExistsException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException, AttributeNotExistsException {
Utils.checkPerunSession(sess);
getAttributesManagerBl().checkAttributeExists(sess, attribute);
getPerunBl().getResourcesManagerBl().checkResourceExists(sess, resource);
//Choose to which attributes has the principal access
if (!AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, new AttributeDefinition(attribute), resource, null))
throw new PrivilegeException("Principal has no access to check attribute = " + new AttributeDefinition(attribute));
getAttributesManagerBl().checkAttributeValue(sess, resource, attribute);
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class AttributesManagerEntry method checkAttributesValue.
public void checkAttributesValue(PerunSession sess, Facility facility, User user, List<Attribute> attributes) throws PrivilegeException, InternalErrorException, FacilityNotExistsException, UserNotExistsException, WrongAttributeValueException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException, AttributeNotExistsException {
Utils.checkPerunSession(sess);
getAttributesManagerBl().checkAttributesExists(sess, attributes);
getPerunBl().getFacilitiesManagerBl().checkFacilityExists(sess, facility);
getPerunBl().getUsersManagerBl().checkUserExists(sess, user);
//Choose to which attributes has the principal access
for (Attribute attr : attributes) {
if (!AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, new AttributeDefinition(attr), facility, user))
throw new PrivilegeException("Principal has no access to check attribute = " + new AttributeDefinition(attr));
}
getAttributesManagerBl().checkAttributesValue(sess, facility, user, attributes);
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class SearcherImpl method getMembersByExpiration.
@Override
public List<Member> getMembersByExpiration(PerunSession sess, String operator, Calendar date, int days) throws InternalErrorException {
// this would default to now
if (date == null)
date = Calendar.getInstance();
date.add(Calendar.DAY_OF_MONTH, days);
// create sql toDate()
String compareDate = BeansUtils.getDateFormatterWithoutTime().format(date.getTime());
compareDate = "TO_DATE('" + compareDate + "','YYYY-MM-DD')";
if (operator == null || operator.isEmpty())
operator = "=";
if (!operator.equals("<") && !operator.equals("<=") && !operator.equals("=") && !operator.equals(">=") && !operator.equals(">"))
throw new InternalErrorException("Operator '" + operator + "' is not allowed in SQL.");
try {
AttributeDefinition def = ((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, "urn:perun:member:attribute-def:def:membershipExpiration");
String query = "select distinct " + MembersManagerImpl.memberMappingSelectQuery + " from members left join member_attr_values val on " + "val.member_id=members.id and val.attr_id=? where TO_DATE(val.attr_value, 'YYYY-MM-DD')" + operator + compareDate;
return jdbcTemplate.query(query.toString(), MembersManagerImpl.MEMBER_MAPPER, def.getId());
} catch (Exception e) {
throw new InternalErrorException(e);
}
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class urn_perun_entityless_attribute_def_def_namespace_maxGID method getAttributeDefinition.
@Override
public AttributeDefinition getAttributeDefinition() {
AttributeDefinition attr = new AttributeDefinition();
attr.setNamespace(AttributesManager.NS_ENTITYLESS_ATTR_DEF);
attr.setFriendlyName("namespace_maxGID");
attr.setDisplayName("Max GID in namespace");
attr.setType(Integer.class.getName());
attr.setDescription("Maximal value of Group ID.");
return attr;
}
use of cz.metacentrum.perun.core.api.AttributeDefinition in project perun by CESNET.
the class urn_perun_entityless_attribute_def_def_namespace_minGID method getAttributeDefinition.
@Override
public AttributeDefinition getAttributeDefinition() {
AttributeDefinition attr = new AttributeDefinition();
attr.setNamespace(AttributesManager.NS_ENTITYLESS_ATTR_DEF);
attr.setFriendlyName("namespace_minGID");
attr.setDisplayName("Min GID in namespace");
attr.setType(Integer.class.getName());
attr.setDescription("Minimal value of Group ID.");
return attr;
}
Aggregations