/** * Returns the windows that can consume the wanted event name. * * @param wanted the wanted event name * @return the collection of windows that can consume the wanted event */ Collection<Window> getConsumers(QName wanted) { List<Window> consumers = null; for (Window window : windows.values()) { if (window.portlet != null) { for (QName name : window.portlet.getInfo().getEventing().getConsumedEvents().keySet()) { if (wanted.equals(name)) { if (consumers == null) { consumers = new ArrayList<Window>(); } consumers.add(window); } } } } return consumers == null ? Collections.<Window>emptyList() : consumers; } }
public PagePortletControllerContext( HttpServletRequest req, HttpServletResponse resp, PortletInvoker invoker, ServletContext servletContext, PortalPrepareResponse prepareResponse) throws IllegalRequestException, IOException, ServletException, PortletInvokerException { super(req, resp); // Map<Key, Portlet> portlets = new HashMap<Key, Portlet>(); for (Portlet portlet : invoker.getPortlets()) { PortletInfo portletInfo = portlet.getInfo(); String portletName = portletInfo.getName(); String applicationName = portletInfo.getApplicationName(); Key key = new Key(applicationName, portletName); portlets.put(key, portlet); } // this.invoker = invoker; this.portlets = portlets; this.prepareResponse = prepareResponse; this.stateControllerContext = new StateControllerContextImpl(this); this.eventControllerContext = new PageEventControllerContext(this, prepareResponse); this.serialization = new PortletPageNavigationalStateSerialization(stateControllerContext); }
public String getDisplayName(String portletName, Locale locale) { String portletDisplayName = portletName; if (portletDisplayNames.get(portletName) != null) { portletDisplayName = portletDisplayNames.get(portletName).getValue(locale, true).getString(); } else if (!isPortletDisplayNamesImported) { PortletInvoker portletInvoker = (PortletInvoker) PortalContainer.getComponent(PortletInvoker.class); try { Set<org.gatein.pc.api.Portlet> portlets = portletInvoker.getPortlets(); for (org.gatein.pc.api.Portlet portlet : portlets) { portletDisplayNames.put(portlet.getInfo().getName(), portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME)); } isPortletDisplayNamesImported = true; } catch (PortletInvokerException exception) { LOG.error("Error occurred when trying to import portlets", exception); } if (portletDisplayNames.get(portletName) != null) { portletDisplayName = portletDisplayNames.get(portletName).getValue(locale, true).getString(); } } return portletDisplayName; }
private void printRoute(EventRoute route, PrintWriter writer,PagePortletControllerContext context, int id, String cid) { writer.print("<div onmouseover=\"showDetails(this,'details-" + id + cid + "')\" onmouseout=\"hideDetails(this,'details-" + id + cid + "')\" onclick=\"new Effect.Highlight('" + context.getPortletInfo(route.getSource()).getName() + "', {startcolor:'#990000', endcolor:'ffffdd',queue: {position:'start', scope: 'highlight', limit:2}});new Effect.Highlight('" + context.getPortletInfo(route.getDestination()).getName() + "', {startcolor:'#990000', endcolor:'ffffdd',queue: {position:'end', scope: 'highlight', limit:2}});\" >" + "<div class=\"event-header\">\n" + " <h4>" + context.getPortletInfo(route.getSource()).getName() + "</h4>\n" + " <div>Event: " + route.getName().getLocalPart() + "</div>\n" + " </div>\n"); writer.print("<div class=\"event-body\">" + "<p><label>Source: </label>" + context.getPortletInfo(route.getSource()).getName() + "<img src=\"/simple-portal/images/debug/arrow.gif\" alt=\"\"/>"); writer.print("<label>Destination: </label>" + context.getPortletInfo(route.getDestination()).getName() + "</p>\n" + " <div class=\"details\" id=\"details-" + id + cid + "\">\n" + " <div class=\"details-frame\">\n" + " " + formatAck(route.getAcknowledgement()) + "\n" + " <div class=\"dotted-white\"></div>\n" + " <label>Payload: " + route.getPayload() + "</label>\n" + " </div>\n" + " </div></div>" + ""); writer.print("</div>"); for (EventRoute child : route.getChildren()) { id = rand(1,1000); writer.println("<div class=\"children\">"); printRoute(child, writer, context, id, "a"); writer.println("</div>"); } }
try MetaInfo metaInfo = container.getInfo().getMeta(); description = metaInfo.getMetaValue("description");
public CacheControl getCacheControl() { if (cacheControl == null) { PortletInfo info = preq.container.getInfo(); CacheInfo cacheInfo = info.getCache(); cacheControl = new CacheControlImpl(cacheInfo.getExpirationSecs(), CacheScope.PRIVATE); } return cacheControl; } }
CapabilitiesInfo capabilities = info.getCapabilities(); Set<ModeInfo> compatibleModes = capabilities.getModes(mediaType); for (ModeInfo modeInfo : compatibleModes)
if (portlet.getInfo().getName().equals(segment.value))
CacheInfo cacheInfo = info.getCache(); cc = new org.gatein.pc.api.cache.CacheControl(cacheInfo.getExpirationSecs(), CacheScope.PRIVATE, null);
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; } }
if (portlet.getInfo().getApplicationName().equals(portletAppName) && portlet.getInfo().getName().equals(portletName))
if (!consumerPortletInfo.getEventing().getConsumedEvents().containsKey(toConsumeEvent.getName()))
if (portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
EventingInfo eventingInfo = info.getEventing(); Map<QName, ? extends EventInfo> consumedEventInfos = eventingInfo.getConsumedEvents(); EventInfo eventInfo = consumedEventInfos.get(eventName);
EventingInfo eventingInfo = info.getEventing(); Map<QName, ? extends EventInfo> consumedEventInfos = eventingInfo.getConsumedEvents(); EventInfo eventInfo = consumedEventInfos.get(eventName);
if (!producerPortletInfo.getEventing().getProducedEvents().containsKey(producedEvent.getName()))