Search in sources :

Example 1 with ScriptError

use of org.gluu.model.custom.script.model.ScriptError in project oxCore by GluuFederation.

the class CustomScriptManager method clearScriptErrorImpl.

protected void clearScriptErrorImpl(CustomScript customScript) {
    // Load entry from DN
    String customScriptDn = customScript.getDn();
    Class<? extends CustomScript> scriptType = customScript.getScriptType().getCustomScriptModel();
    CustomScript loadedCustomScript = customScriptService.getCustomScriptByDn(scriptType, customScriptDn);
    // Check if there is no error
    ScriptError currError = loadedCustomScript.getScriptError();
    if (currError == null) {
        return;
    }
    // Save error into script entry
    loadedCustomScript.setScriptError(null);
    customScriptService.update(loadedCustomScript);
}
Also used : ScriptError(org.gluu.model.custom.script.model.ScriptError) CustomScript(org.gluu.model.custom.script.model.CustomScript)

Example 2 with ScriptError

use of org.gluu.model.custom.script.model.ScriptError in project oxCore by GluuFederation.

the class CustomScriptManager method saveScriptErrorImpl.

protected void saveScriptErrorImpl(CustomScript customScript, Exception exception, boolean overwrite) {
    // Load entry from DN
    String customScriptDn = customScript.getDn();
    Class<? extends CustomScript> scriptType = customScript.getScriptType().getCustomScriptModel();
    CustomScript loadedCustomScript = customScriptService.getCustomScriptByDn(scriptType, customScriptDn);
    // Check if there is error value already
    ScriptError currError = loadedCustomScript.getScriptError();
    if (!overwrite && (currError != null)) {
        return;
    }
    // Save error into script entry
    StringBuilder builder = new StringBuilder();
    builder.append(ExceptionUtils.getStackTrace(exception));
    String message = exception.getMessage();
    if (message != null && !StringUtils.isEmpty(message)) {
        builder.append("\n==================Further details============================\n");
        builder.append(message);
    }
    loadedCustomScript.setScriptError(new ScriptError(new Date(), builder.toString()));
    customScriptService.update(loadedCustomScript);
}
Also used : ScriptError(org.gluu.model.custom.script.model.ScriptError) CustomScript(org.gluu.model.custom.script.model.CustomScript) Date(java.util.Date)

Aggregations

CustomScript (org.gluu.model.custom.script.model.CustomScript)2 ScriptError (org.gluu.model.custom.script.model.ScriptError)2 Date (java.util.Date)1