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

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

Introduction

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

Prototype

public String[] getParameterNames();

Source Link

Usage

From source file:com.liferay.portlet.admin.action.EditServerAction.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];
            }/*w w w .  ja  v a  2  s.  com*/

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

        convertProcess.setParameterValues(values);
    }

    String path = convertProcess.getPath();

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

        portletURL.setWindowState(WindowState.MAXIMIZED);

        portletURL.setParameter("struts_action", path);

        return portletURL.toString();
    } else {
        MaintenanceUtil.maintain(portletSession.getId(), className);

        MessageBusUtil.sendMessage(DestinationNames.CONVERT_PROCESS, className);

        return null;
    }
}

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];
            }//ww w  .  j a v a  2 s.c o 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;
}