Dina Bogdan
Dina Bogdan

Reputation: 4688

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,

Upvotes: 1

Views: 661

Answers (2)

Dina Bogdan
Dina Bogdan

Reputation: 4688

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!

Upvotes: 1

Crosstalk22
Crosstalk22

Reputation: 377

So looking for unique names is a bad idea, you must look for the objectid of the page when working outside the scope of portal. This comment from the infocenter " The concept of virtual portals scopes some models to the virtual portal in which a user operates. At the moment, this scoping concept applies to the content model, the navigation model, and the navigation selection model. These models scope their resources to the virtual portal in which a user operates." I think you would be best off, moving this code into the resource request of a portlet and then doing the update through that so it is scoped. If you want to continue down this path, make it so the code does not look for uniquename but instead for the actual object id after using the Identification package to convert a string representation of an objectid into an actual object, then use the locator on that

Upvotes: 1

Related Questions