if (propertyName.equals("set")) {
result = request.isPropertySet("set");
} else {
final Test test = tests.get(propertyName);
if (test == null) {
throw new ScimpiException("No such test: " + propertyName);
}
final String attributeValue = request.getOptionalProperty(propertyName, false);
result = test.test(request, attributeValue, id);
if (test.negateResult) {
result = !result;
}
}
checkMade = true;
allConditionsMet &= result;
}
/*
*
* // Check variables if
* (request.isPropertySpecified("variable-exists")) { boolean
* valuePresent = request.isPropertySet("variable-exists"); checkMade =
* true; allConditionsMet &= valuePresent; }
*
* String variable = request.getOptionalProperty("variable-true"); if
* (variable != null) { String value = (String)
* request.getContext().getVariable(variable); checkMade = true;
* allConditionsMet &= Attributes.isTrue(value); }
*
* variable = request.getOptionalProperty("variable-equals"); if
* (variable != null) { String value = (String)
* request.getContext().getVariable(variable); checkMade = true;
* allConditionsMet &= variable.equals(value); }
*/
// Check Object
/*
* // Check Collection String collection =
* request.getOptionalProperty("collection-" + TYPE); if (collection !=
* null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), collection); Class<?>
* cls = forClass(request); TypeOfFacet facet =
* object.getSpecification().getFacet(TypeOfFacet.class); boolean
* hasType = object != null && (cls == null ||
* cls.isAssignableFrom(facet.value())); checkMade = true;
* allConditionsMet &= hasType;; }
*
* collection = request.getOptionalProperty("collection-" + "empty"); if
* (collection != null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); CollectionFacet
* facet = object.getSpecification().getFacet(CollectionFacet.class);
* boolean isEmpty = facet != null && facet.size(object) == 0;
* processTags(isEmpty, request); allConditionsMet &= isEmpty; }
*/
// Check Methods
/*
* String method = request.getOptionalProperty(METHOD + "-exists"); if
* (method != null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); List<? extends
* ObjectAction> objectActions =
* object.getSpecification().getObjectActions(ActionType.USER); boolean
* methodExists = false; for (ObjectAction objectAssociation :
* objectActions) { if (objectAssociation.getId().equals(method)) {
* methodExists = true; break; } } checkMade = true; allConditionsMet &=
* methodExists; }
*
* method = request.getOptionalProperty(METHOD + "-visible"); if (method
* != null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); // TODO needs to
* work irrespective of parameters ObjectAction objectAction =
* object.getSpecification().getObjectAction(ActionType.USER, method,
* ObjectSpecification.EMPTY_LIST); Consent visible =
* objectAction.isVisible(IsisContext.getAuthenticationSession(),
* object); checkMade = true; allConditionsMet &= visible.isAllowed(); }
*
* method = request.getOptionalProperty(METHOD + "-usable"); if (method
* != null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); // TODO needs to
* work irrespective of parameters ObjectAction objectAction =
* object.getSpecification().getObjectAction(ActionType.USER, method,
* ObjectSpecification.EMPTY_LIST); Consent usable =
* objectAction.isUsable(IsisContext.getAuthenticationSession(),
* object); checkMade = true; allConditionsMet &= usable.isAllowed(); }
*
*
* // Check Fields String field = request.getOptionalProperty(FIELD +
* "-exists"); if (field != null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); List<? extends
* ObjectAssociation> objectFields =
* object.getSpecification().getAssociations(); boolean fieldExists =
* false; for (ObjectAssociation objectAssociation : objectFields) { if
* (objectAssociation.getId().equals(field)) { fieldExists = true;
* break; } } checkMade = true; allConditionsMet &= fieldExists; }
*
* field = request.getOptionalProperty(FIELD + "-visible"); if (field !=
* null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
* objectField = object.getSpecification().getAssociation(field);
* Consent visible =
* objectField.isVisible(IsisContext.getAuthenticationSession(),
* object); checkMade = true; allConditionsMet &= visible.isAllowed(); }
*
* field = request.getOptionalProperty(FIELD + "-editable"); if (field
* != null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
* objectField = object.getSpecification().getAssociation(field);
* Consent usable =
* objectField.isUsable(IsisContext.getAuthenticationSession(), object);
* checkMade = true; allConditionsMet &= usable.isAllowed(); }
*
* field = request.getOptionalProperty(FIELD + "-empty"); if (field !=
* null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
* objectField = object.getSpecification().getAssociation(field);
* IsisContext.getPersistenceSession().resolveField(object,
* objectField); ObjectAdapter fld = objectField.get(object); if (fld ==
* null) { checkMade = true; allConditionsMet &= true; } else {
* CollectionFacet facet =
* fld.getSpecification().getFacet(CollectionFacet.class); boolean
* isEmpty = facet != null && facet.size(fld) == 0; processTags(isEmpty,
* request); allConditionsMet &= isEmpty; } }
*
* field = request.getOptionalProperty(FIELD + "-set"); if (field !=
* null) { ObjectAdapter object =
* MethodsUtils.findObject(request.getContext(), id); ObjectAssociation
* objectField = object.getSpecification().getAssociation(field);
* IsisContext.getPersistenceSession().resolveField(object,
* objectField); ObjectAdapter fld = objectField.get(object); if (fld ==
* null) { throw new ScimpiException("No object for field-set " +
* field); } Object fieldValue = fld.getObject(); if (fieldValue
* instanceof Boolean) { checkMade = true; allConditionsMet &=
* ((Boolean) fieldValue).booleanValue(); } else { checkMade = true;
* allConditionsMet &= true; } }
*/
// Check User
/*
* String hasRole = request.getOptionalProperty("has-role"); if (hasRole
* != null) { AuthenticationSession session =
* IsisContext.getSession().getAuthenticationSession(); List<String>
* roles = session.getRoles(); boolean hasMatchingRole = false; for
* (String role : roles) { if (role.equals(hasRole.trim())) {
* hasMatchingRole = true; break; } } checkMade = true; allConditionsMet
* &= hasMatchingRole; }
*/
final String persistent = request.getOptionalProperty("persistent");
if (persistent != null) {
final ObjectAdapter object = request.getContext().getMappedObjectOrResult(persistent);
checkMade = true;
allConditionsMet &= object.isPersistent();
}
/*
* String type = request.getOptionalProperty(TYPE); if (type != null) {
* ObjectAdapter object = MethodsUtils.findObject(request.getContext(),
* id); Class<?> cls = forClass(request); boolean hasType = object !=
* null && (cls == null ||
* cls.isAssignableFrom(object.getObject().getClass())); checkMade =
* true; allConditionsMet &= hasType;; }
*/
if (request.isPropertySpecified("empty")) {
if (request.isPropertySet("empty")) {
final String collection = request.getOptionalProperty("empty");
if (collection != null) {
final ObjectAdapter object = request.getContext().getMappedObjectOrResult(collection);
final CollectionFacet facet = object.getSpecification().getFacet(CollectionFacet.class);
checkMade = true;
allConditionsMet &= facet.size(object) == 0;
}
} else {
checkMade = true;
allConditionsMet &= true;
}
}
if (request.isPropertySpecified("set")) {
final boolean valuePresent = request.isPropertySet("set");
checkMade = true;
allConditionsMet &= valuePresent;
}
if (checkMade) {
processTags(allConditionsMet, request);
} else {
throw new ScimpiException("No condition in " + getName());
}
}