Example usage for com.liferay.portal.convert ConvertProcess validate

List of usage examples for com.liferay.portal.convert ConvertProcess validate

Introduction

In this page you can find the example usage for com.liferay.portal.convert ConvertProcess validate.

Prototype

public void validate() throws ConvertException;

Source Link

Usage

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

License:Open Source License

protected String convertProcess(ActionRequest actionRequest, ActionResponse actionResponse, String cmd)
        throws Exception {

    ActionResponseImpl actionResponseImpl = (ActionResponseImpl) actionResponse;

    PortletSession portletSession = actionRequest.getPortletSession();

    String className = StringUtil.replaceFirst(cmd, "convertProcess.", StringPool.BLANK);

    ConvertProcess convertProcess = (ConvertProcess) InstancePool.get(className);

    String[] parameters = convertProcess.getParameterNames();

    if (parameters != null) {
        String[] values = new String[parameters.length];

        for (int i = 0; i < parameters.length; i++) {
            String parameter = className + StringPool.PERIOD + parameters[i];

            if (parameters[i].contains(StringPool.EQUAL)) {
                String[] parameterPair = StringUtil.split(parameters[i], CharPool.EQUAL);

                parameter = className + StringPool.PERIOD + parameterPair[0];
            }//from ww w  .  j  a  v  a  2  s. co m

            values[i] = ParamUtil.getString(actionRequest, parameter);
        }

        convertProcess.setParameterValues(values);
    }

    try {
        convertProcess.validate();
    } catch (ConvertException ce) {
        SessionErrors.add(actionRequest, ce.getClass(), ce);

        return null;
    }

    String path = convertProcess.getPath();

    if (path != null) {
        PortletURL portletURL = actionResponseImpl.createRenderURL();

        portletURL.setParameter("mvcRenderCommandName", path);
        portletURL.setWindowState(WindowState.MAXIMIZED);

        return portletURL.toString();
    }

    MaintenanceUtil.maintain(portletSession.getId(), className);

    MessageBusUtil.sendMessage(DestinationNames.CONVERT_PROCESS, className);

    return null;
}