protected Interaction findInteraction() throws WebApplicationException {
   InteractionRegistry registry = getInteractionRegistry();
   if ((null != registry) && (null != registry.getInteraction(interactionId))) {
     return registry.getInteraction(interactionId);
   } else {
     throw new WebApplicationException(Status.NOT_FOUND);
   }
 }
  public void initializePanel(ActivityInstance ai, Map inData) {
    FacesContext facesContext = FacesContext.getCurrentInstance();

    InteractionRegistry registry =
        (InteractionRegistry)
            ManagedBeanUtils.getManagedBean(facesContext, InteractionRegistry.BEAN_ID);
    if (null != registry) {
      // start new interaction
      ModelCache modelCache = ModelCache.findModelCache();
      SessionContext ippSessionContext = SessionContext.findSessionContext();

      Interaction interaction = registry.getInteraction(Interaction.getInteractionId(ai));
      if (null == interaction) {
        interaction =
            new Interaction(ippSessionContext.getUser(), ai, getContextId(ai), modelCache);
        interaction.setInDataValues(inData);
        registry.registerInteraction(interaction);
      }

      Map<String, Object> sessionMap = facesContext.getExternalContext().getSessionMap();
      sessionMap.put(
          IframePanelConstants.KEY_COMMAND, IframePanelConstants.CMD_IFRAME_PANEL_INITIALIZE);
      sessionMap.put(IframePanelConstants.KEY_INTERACTION_ID, interaction.getId());
      if (!isIceFacesPanel(ai)) {
        sessionMap.put(IframePanelConstants.KEY_VIEW_ID, VIEW_ID_NON_IFACE_FACELET_CONTAINER);
      }
    }

    // TODO emit java script to load page into panel?
  }
  public Map getOutDataValues(ActivityInstance ai) {
    FacesContext facesContext = FacesContext.getCurrentInstance();

    Map<String, ? extends Serializable> outData = null;

    InteractionRegistry registry =
        (InteractionRegistry)
            ManagedBeanUtils.getManagedBean(facesContext, InteractionRegistry.BEAN_ID);

    Interaction interaction = registry.getInteraction(Interaction.getInteractionId(ai));
    if (null != interaction) {
      outData = interaction.getOutDataValues();
    }

    return outData;
  }
  public boolean closePanel(ActivityInstance ai, ClosePanelScenario scenario, Object parameters) {
    FacesContext facesContext = FacesContext.getCurrentInstance();

    if (ActivityInteractionControllerUtils.isExternalWebAppInterventionRequired(scenario)) {
      trace.info("Triggering asynchronous close of activity panel ...");

      InteractionRegistry registry =
          (InteractionRegistry)
              ManagedBeanUtils.getManagedBean(facesContext, InteractionRegistry.BEAN_ID);

      Interaction interaction = registry.getInteraction(Interaction.getInteractionId(ai));
      if ((null != interaction) && (Interaction.Status.Complete == interaction.getStatus())) {
        // out data mapping was already performed
        return true;
      }

      Map<String, Object> sessionMap = facesContext.getExternalContext().getSessionMap();

      sessionMap.put(IframePanelConstants.KEY_COMMAND, scenario.getId());
      sessionMap.put(IframePanelConstants.KEY_INTERACTION_ID, Interaction.getInteractionId(ai));
      if (!isIceFacesPanel(ai)) {
        sessionMap.put(IframePanelConstants.KEY_VIEW_ID, VIEW_ID_NON_IFACE_FACELET_CONTAINER);
      }

      PortalApplicationEventScript.getInstance()
          .addEventScript(
              "parent.InfinityBpm.ProcessPortal.sendCloseCommandToExternalWebApp('"
                  + getContentFrameId(ai)
                  + "', '"
                  + scenario.getId()
                  + "');");

      // close panel asynchronously after ICEfaces page responds via JavaScript
      return false;
    } else {
      // destroy interaction
      unregisterInteraction(ai);

      // synchronously close panel as no custom post processing needs to occur
      return true;
    }
  }