private boolean isPortletContextKnown(PortletContext portletContext) throws PortletInvokerException { final PortletStatus status = super.getStatus(portletContext); if (PortletStatus.OFFERED == status) { return true; } else { Registration registration = RegistrationLocal.getRegistration(); if (registration != null) { if (registration.knows(portletContext)) { return true; } else { String id = portletContext.getId(); throw new NoSuchPortletException( "Registration '" + registration.getRegistrationHandle() + "' does not know the '" + id + "' portlet", id); } } else { return status != null; } } }
public Set<Portlet> getPortlets() throws PortletInvokerException { Set<Portlet> portlets = new HashSet<Portlet>(super.getPortlets()); Registration registration = RegistrationLocal.getRegistration(); if (registration != null) { Set<PortletContext> contexts = registration.getKnownPortletContexts(); for (PortletContext context : contexts) { try { portlets.add(super.getPortlet(context)); } catch (NoSuchPortletException e) { final RegistrationSPI registrationSPI = getRegistrationAsSPI(); try { registrationSPI.removePortletContext(context); log.debug( "Removed '" + context + "' from Registration '" + registration.getRegistrationHandle() + "' because it cannot be resolved anymore."); } catch (RegistrationException e1) { throw new PortletInvokerException(e1); } } } } return portlets; }
public PortletContext exportPortlet(PortletStateType stateType, PortletContext portletContext) throws PortletInvokerException, IllegalArgumentException { if (isPortletContextKnown(portletContext)) { checkOperationIsAllowed(portletContext, RegistrationLocal.getRegistration(), "exportPortlet"); return super.exportPortlet(stateType, portletContext); } else { throw new NoSuchPortletException(portletContext.getId()); } }
private RegistrationSPI getRegistrationAsSPI() throws PortletInvokerException { Registration registration = RegistrationLocal.getRegistration(); if (registration == null) { return null; } if (registration instanceof RegistrationSPI) { return (RegistrationSPI) registration; } else { throw new PortletInvokerException("Cannot deal with non-RegistrationSPI Registrations."); } }
public PropertyMap getProperties(PortletContext portletContext, Set<String> keys) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException { checkOperationIsAllowed(portletContext, RegistrationLocal.getRegistration(), "getProperties"); return super.getProperties(portletContext, keys); }