throws Exception {
// initialize
AsnContext context = this.getAssertionContext();
AsnFactory factory = context.getAssertionFactory();
AsnRequestOptions rOptions = context.getRequestOptions();
AsnResponse opResponse = context.getOperationResponse();
ParseHelper pHelper = new ParseHelper();
String[] parsed;
// parse the HTTP request
if (request != null) {
// set the IP address
rOptions.setIPAddress(request.getRemoteAddr());
// parse an operations request
boolean isOperationsRequest = false;
if (request.getRequestURI() != null) {
isOperationsRequest = request.getRequestURI().toLowerCase().endsWith("/operations");
}
if (isOperationsRequest) {
rOptions.setSubject(AsnConstants.APP_URN_PREFIX);
rOptions.setPredicate(AsnConstants.APP_URN_PREFIX+":assertion:operations");
// parse a non-operations request
} else {
// subject
parsed = pHelper.getParameterValues(request,"s");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"subject");
}
if ((parsed != null) && (parsed.length) > 0) {
rOptions.setSubject(parsed[0]);
}
// predicate
parsed = pHelper.getParameterValues(request,"p");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"predicate");
}
if ((parsed != null) && (parsed.length) > 0) {
rOptions.setPredicate(parsed[0]);
}
// value
parsed = pHelper.getParameterValues(request,"v");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"value");
}
if ((parsed != null) && (parsed.length) > 0) {
rOptions.setValue(parsed[0]);
}
// output format
parsed = pHelper.getParameterValues(request,"f");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"format");
}
if ((parsed != null) && (parsed.length) > 0) {
opResponse.setOutputFormat(parsed[0]);
}
// start and max records start=&max=
parsed = pHelper.getParameterValues(request,"start");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"startRecord");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"startPosition");
}
}
if ((parsed != null) && (parsed.length) > 0) {
rOptions.setStartRecord(Math.max(Val.chkInt(parsed[0],1),1));
}
parsed = pHelper.getParameterValues(request,"max");
if ((parsed == null) || (parsed.length) == 0) {
parsed = pHelper.getParameterValues(request,"maxRecords");
}
if ((parsed != null) && (parsed.length) > 0) {
rOptions.setMaxRecords(Val.chkInt(parsed[0],10));
}
}
}
try {
// determine the handler
AsnOperationHandler handler = factory.makeOperationHandler(context);
// ensure a valid value if required
AsnValue asnValue = context.getOperation().getValue();
if (asnValue != null) {
AsnValueType asnValueType = asnValue.getValueType();
if (asnValueType != null) {
String val = Val.chkStr(rOptions.getValue());
int maxChars = asnValueType.getMaxCharacters();
if (asnValueType.getRequired() && (val.length() == 0) && (request != null)) {
val = Val.chkStr(this.readInputCharacters(request,maxChars));
if (val.length() == 0) val = null;
rOptions.setValue(val);
}
if ((maxChars >= 0) && (val != null) && (val.length() > maxChars)) {
val = Val.chkStr(val.substring(0,maxChars));
}
if ((val != null) && (val.length() > 0)) {