📄 eventproviderimpl.java.svn-base
字号:
if (isEventSupported(processingEvents, eventName, portletAppDD.getDefaultNamespace())) { if (portletDD.getPortletName().equals(portlet.getPortletName())) { resultSet.add(portlet.getId()); } } else { if (processingEvents != null) { for (EventDefinitionReference ref : processingEvents) { QName name = ref.getQualifiedName(portletAppDD.getDefaultNamespace()); if (name == null) { continue; } // add also grouped portlets, that ends with "." if (name.toString().endsWith(".") && eventName.toString().startsWith(name.toString()) && portletDD.getPortletName().equals(portlet.getPortletName())) { resultSet.add(portlet.getId()); } // also look for alias names: if (aliases != null) { for (QName alias : aliases) { if (alias.toString().equals(name.toString()) && portletDD.getPortletName().equals(portlet.getPortletName())) { resultSet.add(portlet.getId()); } } } // also look for default namespaced events if (name.getNamespaceURI() == null || name.getNamespaceURI().equals("")) { String defaultNamespace = portletAppDD.getDefaultNamespace(); QName qname = new QName(defaultNamespace, name.getLocalPart()); if (eventName.toString().equals(qname.toString()) && portletDD.getPortletName().equals(portlet.getPortletName())) { resultSet.add(portlet.getId()); } } } } } } } catch (PortletContainerException e) { LOG.warn(e); } } // make list for (String name : resultSet) { resultList.add(name); } return resultList; } private boolean isEventSupported(List<? extends EventDefinitionReference> supportedEvents, QName eventName, String defaultNamespace) { if (supportedEvents != null) { for (EventDefinitionReference ref : supportedEvents) { QName refQName = ref.getQualifiedName(defaultNamespace); if (refQName != null && refQName.equals(eventName)) { return true; } } } return false; } private List<QName> getAllAliases(QName eventName, PortletApplicationDefinition portletAppDD) { if (portletAppDD.getEventDefinitions() != null) { for (EventDefinition def : portletAppDD.getEventDefinitions()){ QName defQName = def.getQualifiedName(portletAppDD.getDefaultNamespace()); if (defQName != null && defQName.equals(eventName)){ return def.getAliases(); } } } return null; } /** * gets the right PortletWindowThread or makes a new one, if theres none * * @param eventContainer * @param config * @param window * @return */ private PortletWindowThread getPortletWindowThread( EventContainer eventContainer, PortletWindowConfig config, PortletWindow window, ServletContext containerServletContext) { if (portletContextService == null) { portletContextService = container.getOptionalContainerServices().getPortletContextService(); } if (portletContextService != null){ String windowID = window.getId().getStringId(); PortletWindowThread portletWindowThread = portletWindowThreads .get(windowID); if (portletWindowThread == null) { portletWindowThread = new PortletWindowThread(threadGroup, config .getId(), this, window, eventContainer,portletContextService); portletWindowThreads.put(windowID, portletWindowThread); } else { // a thread could be started twice, so we make a new one, // after the old thread stopped // try { try { portletWindowThread.join(); } catch (InterruptedException e) { LOG.warn(e); } portletWindowThreads.remove(portletWindowThread); portletWindowThread = new PortletWindowThread(threadGroup, config .getId(), this, window, eventContainer,portletContextService); portletWindowThreads.put(windowID, portletWindowThread); } return portletWindowThread; } else return null; } /** * Wait for event execution. */ private void waitForEventExecution() { long counter = 0; while (threadGroup.activeCount() > 0) { try { counter = +WAITING_CYCLE; if (counter > 500) { threadGroup.stop(); } Thread.sleep(WAITING_CYCLE); } catch (InterruptedException e) { LOG.warn(e); } } } /** * gets an arbitrary event, which is not processed yet. * * @return the arbitrary event */ private Event getArbitraryEvent() { Event eActual = null; for (Event event : this.savedEvents.getEvents()) { if (this.savedEvents.isNotProcessed(event)) { eActual = event; } } return eActual; } /** * */ private Collection<PortletWindowConfig> getAllPortlets( DriverConfiguration driverConfig) { Collection<PortletWindowConfig> portlets = new ArrayList<PortletWindowConfig>(); ServletContext servletContext = PortalRequestContext .getContext(request).getServletContext();// if (portletRegistry == null) {// portletRegistry = ((PortletContainer) servletContext// .getAttribute(AttributeKeys.PORTLET_CONTAINER))// .getOptionalContainerServices().getPortletRegistryService();// }// if (portletRegistry != null){ Collection pages = driverConfig.getPages(); if (pages != null){ Iterator iPages = pages.iterator(); while(iPages.hasNext()){ PageConfig pageConfig = (PageConfig) iPages.next(); Collection portletIDs = pageConfig.getPortletIds(); if (portletIDs != null){ Iterator iPortletIDs = portletIDs.iterator(); while(iPortletIDs.hasNext()){ portlets.add(PortletWindowConfig.fromId(iPortletIDs.next().toString())); } } } } // PortletWindowConfig.fromId(((PageConfig)driverConfig.getPages().iterator().next()).getPortletIds().iterator().next().toString());// Iterator i = portletRegistry.getRegisteredPortletApplications();// while(i.hasNext()){// portlets.addAll(((PortletAppDD)portletRegistry.getRegisteredPortletApplications().next()).getPortlets());// }// } // Collection<PortletApplicationConfig> apps = // driverConfig.getPortletApplications(); // for (PortletApplicationConfig app : apps) { // portlets.addAll(app.getPortlets()); // } return portlets; } /** * @return the request */ public HttpServletRequest getRequest() { return request; } /** * @return the response */ public HttpServletResponse getResponse() { return response; } /** * Gets the saved events. * * @return the saved events */ public EventList getSavedEvents() { return savedEvents; } private boolean isDeclaredAsPublishingEvent(QName qname) { ServletContext servletContext = PortalRequestContext .getContext(request).getServletContext(); String applicationId = PortletWindowConfig .parseContextPath(portletWindow.getId().getStringId()); String applicationName = applicationId; if (applicationId.length() >0 ) { applicationName = applicationId.substring(1); } String portletName = PortletWindowConfig .parsePortletName(portletWindow.getId().getStringId()); if (portletRegistry == null) { portletRegistry = ((PortletContainer) servletContext .getAttribute(AttributeKeys.PORTLET_CONTAINER)) .getOptionalContainerServices().getPortletRegistryService(); } List<? extends EventDefinitionReference> events = null; try { events = portletRegistry.getPortlet(applicationName, portletName).getSupportedPublishingEvents(); } catch (PortletContainerException e1) { e1.printStackTrace(); } if (events != null) { String defaultNamespace = portletWindow.getPortletEntity().getPortletDefinition().getApplication().getDefaultNamespace(); for (EventDefinitionReference ref : events) { QName name = ref.getQualifiedName(defaultNamespace); if (name == null) { continue; } if (qname.equals(name)) { return true; } } } return false; } private boolean isValueInstanceOfDefinedClass(QName qname, Serializable value) { PortletApplicationDefinition app = portletWindow.getPortletEntity().getPortletDefinition().getApplication(); List<? extends EventDefinition> events = app.getEventDefinitions(); if (events != null) { for (EventDefinition def : events){ if (def.getQName() != null){ if (def.getQName().equals(qname)) return value.getClass().getName().equals( def.getValueType()); } else{ QName tmp = new QName(app.getDefaultNamespace(),def.getName()); if (tmp.equals(qname)) return value.getClass().getName().equals( def.getValueType()); } } } // event not declared return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -