001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.core.model.instance.command.action;
023:
024: import org.jboss.portal.Mode;
025: import org.jboss.portal.WindowState;
026: import org.jboss.portal.core.controller.ControllerException;
027: import org.jboss.portal.core.controller.ControllerResponse;
028: import org.jboss.portal.core.controller.command.info.CommandInfo;
029: import org.jboss.portal.core.controller.portlet.ControllerResponseFactory;
030: import org.jboss.portal.core.controller.portlet.InvokePortletCommandFactory;
031: import org.jboss.portal.core.controller.portlet.PortletContextFactory;
032: import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
033: import org.jboss.portal.core.model.instance.InvokePortletInstanceCommandFactory;
034: import org.jboss.portal.core.model.instance.command.PortletInstanceCommand;
035: import org.jboss.portal.portlet.PortletInvokerException;
036: import org.jboss.portal.portlet.PortletParameters;
037: import org.jboss.portal.portlet.StateString;
038: import org.jboss.portal.portlet.invocation.ActionInvocation;
039: import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
040:
041: /**
042: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
043: * @version $Revision: 8786 $
044: */
045: public class InvokePortletInstanceActionCommand extends
046: PortletInstanceCommand {
047:
048: /** The interaction state. */
049: private StateString interactionState;
050:
051: /** The nform. */
052: private PortletParameters form;
053:
054: public InvokePortletInstanceActionCommand(String instanceId,
055: StateString navigationalState,
056: StateString interactionState, PortletParameters form) {
057: super (instanceId, navigationalState);
058:
059: //
060: this .interactionState = interactionState;
061: this .form = form;
062: }
063:
064: public StateString getInteractionState() {
065: return interactionState;
066: }
067:
068: public PortletParameters getForm() {
069: return form;
070: }
071:
072: public CommandInfo getInfo() {
073: return null;
074: }
075:
076: public ControllerResponse execute() throws ControllerException {
077: try {
078: PortletContextFactory pcf1 = new PortletContextFactory(
079: context);
080: InvokePortletCommandFactory pcf2 = new InvokePortletInstanceCommandFactory(
081: instanceId);
082:
083: //
084: ActionInvocation action = PortletInvocationFactory
085: .createAction(context, Mode.VIEW,
086: WindowState.MAXIMIZED, navigationalState,
087: interactionState, form, pcf1, pcf2);
088:
089: //
090: PortletInvocationResponse response = instance
091: .invoke(action);
092:
093: //
094: return ControllerResponseFactory.createActionResponse(
095: instanceId, response);
096: } catch (PortletInvokerException e) {
097: return ControllerResponseFactory.createResponse(e);
098: }
099: }
100: }
|