Ejemplo n.º 1
0
  public void testJCRSourceInitialization() throws Exception {
    ServiceSelector selector =
        (ServiceSelector) getManager().lookup(SourceFactory.ROLE + "Selector");
    Object jcrSourceFactory = selector.select("jcr");

    assertEquals(
        "Wrong class name for jcr protocol", jcrSourceFactory.getClass(), JCRSourceFactory.class);
  }
  /* (non-Javadoc)
   * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
   */
  public void logout() {
    PortalService service = null;
    ServiceSelector adapterSelector = null;
    try {
      adapterSelector = (ServiceSelector) this.manager.lookup(CopletAdapter.ROLE + "Selector");
      service = (PortalService) this.manager.lookup(PortalService.ROLE);
      final String layoutKey = service.getDefaultLayoutKey();

      CopletInstanceDataManager copletInstanceDataManager =
          (CopletInstanceDataManager) service.getAttribute("CopletInstanceData:" + layoutKey);
      if (copletInstanceDataManager != null) {
        Iterator iter = copletInstanceDataManager.getCopletInstanceData().values().iterator();
        while (iter.hasNext()) {
          CopletInstanceData cid = (CopletInstanceData) iter.next();
          CopletAdapter adapter = null;
          try {
            adapter =
                (CopletAdapter)
                    adapterSelector.select(
                        cid.getCopletData().getCopletBaseData().getCopletAdapterName());
            adapter.logout(cid);
          } finally {
            adapterSelector.release(adapter);
          }
        }
      }

      service.removeAttribute("CopletData:" + layoutKey);
      service.removeAttribute("CopletInstanceData:" + layoutKey);
      service.removeAttribute("Layout:" + layoutKey);
    } catch (ServiceException e) {
      throw new CascadingRuntimeException("Unable to lookup portal service.", e);
    } finally {
      this.manager.release(service);
      this.manager.release(adapterSelector);
    }
    super.logout();
  }