Purpose
Exit to control customizing calls by way of the Application Programming Interface, or the Command Line Interface.
Applies To
CLI Methods
Signature
public void ucCliCustom (
HashMap parms,
PrintWriter out,
String delim,
Connection dbconn,
SesameSession session)
Notes
This method is called from the CLI when a statevar of custom is passed. Results are written to the PrintWriter and returned to the CLI as output. These can be plain text, HTML, XML, or other formats.
Example
public void ucCliCustom (HashMap params,
PrintWriter out,
String delim,
Connection dbconn,
SesameSession session)
{
String op = (String) params.get("OPERATION");
if ("credit_card_transaction".equalsIgnoreCase(op) )
{
// doCreditCardTransaction(params, out, dbconn, session);
String issueId = (String) params.get("ID");
String result = (String) params.get("RESULT");
if (issueId == null || result == null) {
out.println("ERROR: Missing one or more required parameters: ID, RESULT!");
return;
}
// verify result values and map to CREDIT_CARD_RESULT field
String creditCardResult = null;
if (result.equals("yes") ) {
creditCardResult = "4515";
// These static vars (holding UDF_LIST_ID values)
// should be setup in the class constructor
// creditCardResult = CREDIT_CARD_RESULT__SUCCESS;
} else if (result.equals("no") ) {
creditCardResult = "4520";
// These static vars (holding UDF_LIST_ID values)
// should be setup in the class constructor
// creditCardResult = CREDIT_CARD_RESULT__FAIL;
} else {
out.println("ERROR: RESULT parameter specifies invalid value: " + result);
}
if (creditCardResult != null)
{
boolean updated = false;
try
{
// verify that id exists
if (! Problem.isProblemPermitted(dbconn, issueId, false) ) {
// false == readOnly flag
out.println("ERROR: Record " + issueId +
" does not exist or is not accessible!");
}
else
{
// update payment record with credit card result
HashMap updateMap = new HashMap();
updateMap.put("CREDIT_CARD_RESULT", creditCardResult);
if (apiEditItem(issueId, updateMap, dbconn, session) == 0) {
out.println("ERROR: Failed to update record " + issueId +
"! See logs for details.");
} else {
updated = true;
}
}
} catch (Exception e) {
ErrorWriter.write(e, ErrorWriter.LOGERR);
out.println("ERROR: General error condition: " + e.getMessage() );
}
// write success response
if (updated == true) { out.println("Record " + issueId + " updated."); }
}
}
super.ucCliCustom(params, out, delim, dbconn, session);
}