Example usage for com.liferay.portal.kernel.log Log error

List of usage examples for com.liferay.portal.kernel.log Log error

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.log Log error.

Prototype

public void error(Throwable t);

Source Link

Usage

From source file:com.liferay.server.admin.web.internal.portlet.action.EditServerMVCActionCommand.java

License:Open Source License

protected void runScript(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    String language = ParamUtil.getString(actionRequest, "language");
    String script = ParamUtil.getString(actionRequest, "script");

    PortletConfig portletConfig = getPortletConfig(actionRequest);

    PortletContext portletContext = portletConfig.getPortletContext();

    Map<String, Object> portletObjects = ScriptingHelperUtil.getPortletObjects(portletConfig, portletContext,
            actionRequest, actionResponse);

    UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();

    UnsyncPrintWriter unsyncPrintWriter = UnsyncPrintWriterPool.borrow(unsyncByteArrayOutputStream);

    portletObjects.put("out", unsyncPrintWriter);

    try {// w  ww .ja v a2s .  co m
        SessionMessages.add(actionRequest, "language", language);
        SessionMessages.add(actionRequest, "script", script);

        _scripting.exec(null, portletObjects, language, script);

        unsyncPrintWriter.flush();

        SessionMessages.add(actionRequest, "scriptOutput", unsyncByteArrayOutputStream.toString());
    } catch (ScriptingException se) {
        SessionErrors.add(actionRequest, ScriptingException.class.getName(), se);

        Log log = SanitizerLogWrapper.allowCRLF(_log);

        log.error(se.getMessage());
    }
}