javaapiwebsphere-portal

Websphere Portal Server Virtual Portal IBM Portal API


I'm using the IBM Portal API for developing some pages in the Websphere Portal Server, but I want to work in the context of a virtual portal that is nested in my principal portal. I already read the documentation from IBM, but I don't understand how it work, so I decide to ask you guys. Does anyone of you did that already? This is how I'm trying to get a ContentNode from my virtual portal:

private void createPortalContent(HttpServletRequest request, HttpServletResponse response) throws InterruptedException, ModelException{
    Context ctx = null;
    try {
        ctx = new InitialContext();

        portletModelHome = (PortletModelHome) ctx.lookup(PortletModelHome.JNDI_NAME);
        if(portletModelHome == null){
            Thread.sleep(5000);
            portletModelHome = (PortletModelHome) ctx.lookup(PortletModelHome.JNDI_NAME);
        }

        contentModelHome = (ContentModelHome) ctx.lookup(ContentModelHome.JNDI_NAME);
        if(contentModelHome == null){
            Thread.sleep(5000);
            contentModelHome = (ContentModelHome) ctx.lookup(ContentModelHome.JNDI_NAME);
        }

        contentModelControllerHome = (ContentModelControllerHome) ctx.lookup(ContentModelControllerHome.JNDI_NAME);
        if(contentModelControllerHome == null){
            Thread.sleep(5000);
            contentModelControllerHome = (ContentModelControllerHome) ctx.lookup(ContentModelControllerHome.JNDI_NAME);
        }

        contentMappingInfoHome = (ContentMappingInfoHome) ctx.lookup(ContentMappingInfoHome.JNDI_NAME);
        if(contentMappingInfoHome == null){
            Thread.sleep(5000);
            contentMappingInfoHome = (ContentMappingInfoHome) ctx.lookup(ContentMappingInfoHome.JNDI_NAME);
        }

        virtualPortalList = (VirtualPortalListHome) ctx.lookup(VirtualPortalListHome.VIRTUAL_PORTAL_LIST_JNDI_NAME);
    } catch (NamingException e) {
        e.printStackTrace();
    }

    ContentModelController contentModelController = getController(request, response);
    //LOGGER.info("### CONTENT MODEL CONTROLLER: " + contentModelController.getLocator() + " " + contentModelController.getRoot().toString());
    ContentNode contentNode = (ContentNode) contentModelController.getLocator().findByUniqueName("ro.ram.comunicate");
    //LOGGER.info("### CONTENT NODE: " + contentNode);
   // LOGGER.info("#### VIRTUAL PORTAL LIST: " + virtualPortalList);

    //VirtualPortal virtualPortal = virtualPortalList.getVirtualPortalListProvider().getVirtualPortalList().getLocator().findByUniqueName("");
   // LOGGER.info("### VIRTUAL PORTAL: " + virtualPortal.getTitle(Locale.ENGLISH));
    //Iterator<VirtualPortal> it=virtualPortalList.getVirtualPortalListProvider().getVirtualPortalList().iterator();
   // while(it.hasNext()){
   //     LOGGER.info("### VIRTUAL PORTAL LIST ITERATOR: " + it.next().getDescription(Locale.ENGLISH) + " " + " " + it.next().getTitle(Locale.ENGLISH));
  //      it.next();
    //}
}

Thank you,


Solution

  • For everyone who wants to do something like that, the solution (this was for me) might be:

    1. Using IBM WCM API create a class that implements VirtualPortalScopedAction. In this class you must override the run method. The implementation of this interface makes it necessary.
    2. In the run method you do all the math. Here you must instantiate the objects (ContentModelController, ContentModelHome, ContentModelControllerHome) that are exposed by IBM Portal API and SPI. All of these are necessary for making operations in IBM Websphere Portal.
    3. In the class that implements VirtualPortalScopedAction you must pass the HttpServletRequest and HttpServletResponse, because instantiating all of that objects uses the request and the response. For that it's obvious that you declare two attributes in that class and use setter to set the instances on the request and response.

    thx all of you :) I hope this will help you!