public void process(final Request request) {
final String title = request.getOptionalProperty(FORM_TITLE);
final String name = request.getOptionalProperty(NAME);
final String cls = request.getOptionalProperty(CLASS, "action");
final String object = request.getOptionalProperty(OBJECT);
final RequestContext context = request.getContext();
String objectId = object != null ? object : (String) context.getVariable(RequestContext.RESULT);
ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);
// REVIEW this is common used code
final String fieldName = request.getOptionalProperty(FIELD);
if (fieldName != null) {
final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
if (field == null) {
throw new ScimpiException("No field " + fieldName + " in "
+ adapter.getSpecification().getFullIdentifier());
}
if (field.isVisible(IsisContext.getAuthenticationSession(), adapter).isVetoed()) {
throw new ForbiddenException(field, ForbiddenException.VISIBLE);
}
IsisContext.getPersistenceSession().resolveField(adapter, field);
adapter = field.get(adapter);
if (adapter != null) {
objectId = context.mapObject(adapter, Scope.INTERACTION);
}
}
if (adapter != null && valid(request, adapter)) {
final String variable = request.getOptionalProperty("param-name", RequestContext.RESULT);
final String variableSegment = variable + "=" + objectId;
String view = request.getOptionalProperty(VIEW);
if (view == null) {
view = defaultView();
}
view = context.fullUriPath(view);
final String classSegment = " class=\"" + cls + "\"";
final String titleSegment = title == null ? "" : (" title=\"" + title + "\"");
String additionalSegment = additionalParameters(request);
additionalSegment = additionalSegment == null ? "" : "&" + additionalSegment;
request.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment
+ context.encodedInteractionParameters() + additionalSegment + "\">");
request.pushNewBuffer();
request.processUtilCloseTag();
final String buffer = request.popBuffer();
if (buffer.trim().length() > 0) {
request.appendHtml(buffer);