protected void assertTrue (boolean condition, String message) throws BLException { if (!condition) throw new BLException (message); } protected void assertFalse (boolean condition, String message)
public String getDetailedMessage () { StringBuffer sb = new StringBuffer (getMessage()); if (detail != null) { sb.append (" ("); sb.append (detail); sb.append (')'); } return sb.toString(); } public void dump (PrintStream p, String indent) {
public int prepare (long id, Serializable o) { Context ctx = (Context) o; try { return doPrepare (id, ctx); } catch (BLException e) { setResultCode (ctx, e.getMessage(), e.getDetail()); } catch (Throwable t) { ctx.log ("prepare exception in " + this.getClass().getName()); ctx.log (t); setResultCode (ctx, t.getMessage()); } finally { checkPoint (ctx); } return ABORTED; }
public void dump (PrintStream p, String indent) { String inner = indent + " "; p.println (indent + "<bl-exception>"); p.println (inner + "<message>" + getMessage() + "</message>"); if (detail != null) p.println (inner + "<detail>" + detail + "</detail>"); if (nested != null) { if (nested instanceof Loggeable) ((Loggeable)nested).dump (p, inner); else { p.println (inner + "<nested-exception>"); p.print (inner); nested.printStackTrace (p); p.println (inner + "</nested-exception>"); } } p.print (inner); printStackTrace (p); p.println (indent + "</bl-exception>"); } public String toString() {
@Override protected boolean saveClick(Button.ClickEvent event, Layout formLayout) { try { entryGrid.validate(); } catch (BLException e) { getApp().displayNotification(e.getDetailedMessage()); return false; } if (newEntryForm.isShouldReverse()) { getApp().addWindow(new ConfirmDialog( getApp().getMessage("confirmTitle"), getApp().getMessage("reverseAndPostConfirmation"), confirm -> { if (confirm && super.saveClick(event, formLayout)) { setReadOnly(true); } })); return true; } else { if(super.saveClick(event, formLayout)) { setReadOnly(true); return true; } return false; } }
public int prepareForAbort (long id, Serializable o) { // TxnSupport does not implement AbortParticipant on purpose, // but participants willing to implement it will benefit from // this method. Context ctx = (Context) o; try { return doPrepareForAbort (id, ctx); } catch (BLException e) { setResultCode (ctx, e.getMessage(), e.getDetail()); } catch (Throwable t) { ctx.log ("prepare exception in " + this.getClass().getName()); ctx.log (t); setResultCode (ctx, t.getMessage()); } finally { checkPoint (ctx); } return ABORTED; }
protected void assertTrue (boolean condition, String message, String detail) throws BLException { if (!condition) throw new BLException (message, detail); } protected void assertFalse
protected void assertNotNull (Object obj, String message, String detail) throws BLException { if (obj == null) throw new BLException (message, detail); } protected void assertNotNull (Object obj, int resultCode)
protected void assertNull (Object obj, String message, String detail) throws BLException { if (obj != null) throw new BLException (message, detail); } protected void checkPoint (Context ctx) {
protected void assertTrue (boolean condition, String error) throws BLException { if (!condition) throw new BLException (error); }
protected void assertFalse (boolean condition, String message) throws BLException { if (condition) throw new BLException (message); } protected void assertTrue
protected void assertNull (Object obj, String message) throws BLException { if (obj != null) throw new BLException (message); } protected void assertNull (Object obj, String message, String detail)
protected void assertFalse (boolean condition, String message, String detail) throws BLException { if (condition) throw new BLException (message, detail); } protected void assertNotNull (Object obj, String message)
protected void assertNotNull (Object obj, String message) throws BLException { if (obj == null) throw new BLException (message); } protected void assertNotNull (Object obj, String message, String detail)
protected void assertNotNull (Object obj, String error) throws BLException { if (obj == null) throw new BLException (error); } protected void assertTrue (boolean condition, String error)
protected void assertNotNull (Object obj, int resultCode) throws BLException { if (obj == null) throw new BLException (Integer.toString (resultCode)); } protected void assertNotNull (Object obj, int resultCode, String detail)
protected void assertNotNull (Object obj, int resultCode, String detail) throws BLException { if (obj == null) throw new BLException (Integer.toString (resultCode), detail); } protected void assertNotNull (Map map, String[] props, String message)
public void validate () throws BLException { if (transaction.getEntries().size() == 0) { setComponentError(new UserError("Transaction has no entries")); throw new BLException("Transaction has no entries"); } }
private void checkMandatoryJson (Context ctx) throws BLException { for (Map.Entry<String,JsonSchema> entry : mandatoryJson.entrySet()) { String value = ctx.getString(entry.getKey()); ProcessingReport report; if (value != null) { try { JsonSchema schema = entry.getValue(); JsonNode node = JsonLoader.fromString(value); report = schema.validate(node); } catch(Exception ex) { throw new BLException(ex.getMessage()); } assertTrue(report.isSuccess(), report.toString()); } } }
private void checkOptionalJson (Context ctx) throws BLException { for (Map.Entry<String,JsonSchema> entry : optionalJson.entrySet()) { String value = ctx.getString(entry.getKey()); ProcessingReport report; if (value != null) { try { JsonSchema schema = entry.getValue(); JsonNode node = JsonLoader.fromString(value); report = schema.validate(node); } catch(Exception ex) { throw new BLException(ex.getMessage()); } assertTrue(report.isSuccess(), report.toString()); } } } }