public String wrapCCP(PortletContext ccpCtx) throws InvalidPortletIdException { if (ccpCtx == null) { throw new IllegalArgumentException(); } return PortletContext.CONSUMER_CLONE_ID_PREFIX + ccpCtx.getId(); }
public PortletStatus getStatus(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException { if (portletContext == null) { throw new IllegalArgumentException("The portlet context cannot be null"); } if (portlets.containsKey(portletContext.getId())) { return PortletStatus.OFFERED; } return null; }
public String wrapPOP(PortletContext popCtx) throws InvalidPortletIdException { if (popCtx == null) { throw new IllegalArgumentException(); } if (popCtx.getId().startsWith(PortletContext.CONSUMER_CLONE_ID_PREFIX)) { throw new IllegalArgumentException("Must not start with " + PortletContext.CONSUMER_CLONE_ID_PREFIX); } return popCtx.getId(); }
private static String encode(org.gatein.pc.api.PortletContext portletContext) { String id = portletContext.getId(); if (id.startsWith(URLTools.SLASH)) { id = id.replace(URLTools.SLASH, SLASH_REPLACEMENT); } return URLTools.encodeXWWWFormURL(id); }
public Portlet getPortlet(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException { if (portletContext == null) { throw new IllegalArgumentException("No null portlet id accepted"); } String portletId = portletContext.getId(); PortletImpl portlet = portlets.get(portletId); if (portlet == null) { throw new NoSuchPortletException(portletId); } return portlet; }
public PortletInstanceContext( UserContext userContext, PortletContext portletContext) { String id = portletContext.getId(); PortletContext target = portletContext; boolean useClone = false; PortletContext clone = (PortletContext)userContext.getAttribute("clone." + id); if (clone != null) { target = clone; useClone = true; } // this.userContext = userContext; this.useClone = useClone; this.target = target; this.id = id; }
public synchronized void removePortletContainer(PortletContainer portletContainer) { Map<String, PortletImpl> portlets = new HashMap<String, PortletImpl>(this.portlets); PortletImpl portlet = new PortletImpl(portletContainer); portlets.remove(portlet.getContext().getId()); // this.portlets = portlets; }
public synchronized void addPortletContainer(PortletContainer portletContainer) { Map<String, PortletImpl> portlets = new HashMap<String, PortletImpl>(this.portlets); PortletImpl portlet = new PortletImpl(portletContainer); portlets.put(portlet.getContext().getId(), portlet); // this.portlets = portlets; }
public PropertyMap getProperties(PortletContext portletContext, Set<String> keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException { PortletImpl portlet = portlets.get(portletContext.getId()); if (portlet == null) { throw new NoSuchPortletException(portletContext.getId()); } ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo(); ContainerPreferencesInfo prefs = info.getPreferences(); PropertyMap result = new SimplePropertyMap(); for (String key : keys) { ContainerPreferenceInfo pref = prefs.getContainerPreference(key); if (pref != null) { result.put(key, pref.getDefaultValue()); } } return result; }
public PropertyMap getProperties(PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException { PortletImpl portlet = portlets.get(portletContext.getId()); if (portlet == null) { throw new NoSuchPortletException(portletContext.getId()); } ContainerPortletInfo info = (ContainerPortletInfo)portlet.getInfo(); ContainerPreferencesInfo prefs = info.getPreferences(); PropertyMap result = new SimplePropertyMap(); for (String key : prefs.getKeys()) { ContainerPreferenceInfo pref = prefs.getContainerPreference(key); if (pref != null) { result.put(key, pref.getDefaultValue()); } } return result; }
/** * @param portletContext * @return Since 2.6 */ public static org.oasis.wsrp.v2.PortletContext convertToWSRPPortletContext(PortletContext portletContext) { ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext"); String id = portletContext.getId(); ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "portlet id", "PortletContext"); org.oasis.wsrp.v2.PortletContext result = WSRPTypeFactory.createPortletContext(id); result.setPortletState(getStateOrNullFor(portletContext)); return result; }
public Iterable<WindowEvent> eventProduced(EventPhaseContext context, WindowEvent producedEvent, WindowEvent sourceEvent) { try { LinkedList<WindowEvent> toConsume = new LinkedList<WindowEvent>(); for (Portlet portlet : invoker.getPortlets()) { PortletInfo portletInfo = portlet.getInfo(); if (portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName())) { WindowEvent distributedEvent = new WindowEvent(producedEvent.getName(), producedEvent.getPayload(), portlet.getContext().getId()); toConsume.addLast(distributedEvent); } } return toConsume; } catch (PortletInvokerException e) { System.out.println("e = " + e); return null; } }
/** * @param registrationContext * @param portletContext * @return * @since 2.6 */ public static V1GetPortletDescription createGetPortletDescription(V1RegistrationContext registrationContext, org.gatein.pc.api.PortletContext portletContext) { ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context"); V1PortletContext wsrpPC = createPortletContext(portletContext.getId()); if (portletContext instanceof StatefulPortletContext) { StatefulPortletContext context = (StatefulPortletContext)portletContext; if (PortletStateType.OPAQUE.equals(context.getType())) { wsrpPC.setPortletState(((StatefulPortletContext<byte[]>)context).getState()); } } V1GetPortletDescription getPortletDescription = new V1GetPortletDescription(); getPortletDescription.setRegistrationContext(registrationContext); getPortletDescription.setPortletContext(wsrpPC); return getPortletDescription; }
/** * @param registrationContext * @param portletContext * @return * @since 2.6 */ public static GetPortletDescription createGetPortletDescription(RegistrationContext registrationContext, org.gatein.pc.api.PortletContext portletContext) { ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context"); PortletContext wsrpPC = createPortletContext(portletContext.getId()); if (portletContext instanceof StatefulPortletContext) { StatefulPortletContext context = (StatefulPortletContext)portletContext; if (PortletStateType.OPAQUE.equals(context.getType())) { wsrpPC.setPortletState(((StatefulPortletContext<byte[]>)context).getState()); } } GetPortletDescription getPortletDescription = new GetPortletDescription(); getPortletDescription.setRegistrationContext(registrationContext); getPortletDescription.setPortletContext(wsrpPC); return getPortletDescription; }
public PortletContext createClone(PortletStateType stateType, PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException { ConsumerContext consumerContext = getConsumerContext(portletContext); // PortletContext clonedContext = super.createClone(stateType, consumerContext.producerPortletContext); if (clonedContext instanceof StatefulPortletContext) { StatefulPortletContext statefulClonedContext = (StatefulPortletContext)clonedContext; ConsumerState consumerState = new ConsumerState<Serializable>(clonedContext.getId(), statefulClonedContext.getType(), statefulClonedContext.getState()); String id = persistenceManager.createState(consumerState); return PortletContext.createPortletContext(PortletContext.CONSUMER_CLONE_ID_PREFIX + id); } else { return clonedContext; } }
public PortletContext importPortlet(PortletStateType stateType, PortletContext portletContext) throws PortletInvokerException, IllegalArgumentException { ConsumerContext consumerContext = getConsumerContext(portletContext); PortletContext importContext = super.importPortlet(stateType, consumerContext.producerPortletContext); if (importContext instanceof StatefulPortletContext) { StatefulPortletContext statefulimportContext = (StatefulPortletContext)importContext; ConsumerState consumerState = new ConsumerState<Serializable>(importContext.getId(), statefulimportContext.getType(), statefulimportContext.getState()); String id = persistenceManager.createState(consumerState); return PortletContext.createPortletContext(PortletContext.CONSUMER_CLONE_ID_PREFIX + id); } else { return importContext; } }
public PortletInvocationResponse invoke(String windowId, List<Cookie> requestCookies, RenderInvocation renderInvocation) throws PortletInvokerException { Portlet portlet = getPortlet(windowId); // renderInvocation.setClientContext(new AbstractClientContext(req, requestCookies)); renderInvocation.setServerContext(new AbstractServerContext(req, resp)); renderInvocation.setInstanceContext(new AbstractInstanceContext(portlet.getContext().getId())); renderInvocation.setUserContext(new AbstractUserContext(req)); renderInvocation.setWindowContext(new AbstractWindowContext(windowId)); renderInvocation.setPortalContext(PORTAL_CONTEXT); renderInvocation.setSecurityContext(new AbstractSecurityContext(req)); renderInvocation.setTarget(portlet.getContext()); // return invoke(renderInvocation); }
public PortletInvocationResponse invoke(String windowId, List<Cookie> requestCookies, EventInvocation eventInvocation) throws PortletInvokerException { Portlet portlet = getPortlet(windowId); // eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies)); eventInvocation.setServerContext(new AbstractServerContext(req, resp)); eventInvocation.setInstanceContext(new AbstractInstanceContext(portlet.getContext().getId())); eventInvocation.setUserContext(new AbstractUserContext(req)); eventInvocation.setWindowContext(new AbstractWindowContext(windowId)); eventInvocation.setPortalContext(PORTAL_CONTEXT); eventInvocation.setSecurityContext(new AbstractSecurityContext(req)); eventInvocation.setTarget(portlet.getContext()); // return invoke(eventInvocation); }
public PortletInvocationResponse invoke(String windowId, ActionInvocation actionInvocation) throws PortletInvokerException { // Portlet portlet = getPortlet(windowId); // actionInvocation.setClientContext(new AbstractClientContext(req)); actionInvocation.setServerContext(new AbstractServerContext(req, resp)); actionInvocation.setInstanceContext(new AbstractInstanceContext(portlet.getContext().getId())); actionInvocation.setUserContext(new AbstractUserContext(req)); actionInvocation.setWindowContext(new AbstractWindowContext(windowId)); actionInvocation.setPortalContext(PORTAL_CONTEXT); actionInvocation.setSecurityContext(new AbstractSecurityContext(req)); actionInvocation.setRequestContext(new AbstractRequestContext(req)); actionInvocation.setTarget(portlet.getContext()); // return invoke(actionInvocation); }
public PortletInvocationResponse invoke(String windowId, ResourceInvocation resourceInvocation) throws PortletInvokerException { Portlet portlet = getPortlet(windowId); // resourceInvocation.setClientContext(new AbstractClientContext(req)); resourceInvocation.setServerContext(new AbstractServerContext(req, resp)); resourceInvocation.setInstanceContext(new AbstractInstanceContext(portlet.getContext().getId())); resourceInvocation.setUserContext(new AbstractUserContext(req)); resourceInvocation.setWindowContext(new AbstractWindowContext(windowId)); resourceInvocation.setPortalContext(PORTAL_CONTEXT); resourceInvocation.setSecurityContext(new AbstractSecurityContext(req)); resourceInvocation.setRequestContext(new AbstractRequestContext(req)); resourceInvocation.setTarget(portlet.getContext()); // return invoke(resourceInvocation); } }