Home Blog Services Resume Contact

The Turn-In Blog

Philip Cheshire's personal blog, rants regarding anything and everything but mainly regarding his findings in day to day programming of java and websphere portal as well as his weekend actities at the autocross course.

What to be notified when a new blog post is published? Sign up here!

Your Name:
What's 12+7?

Your information will be safe. I will not, under any circumstances,
disclose or sell your personal information for any reason at all.
You will have the ability to unsubscribe at any time with a link in the
email you will receive when a new post is entered.

View All Posts

Using WCM API in Virtual Portal with Managed Pages Enabled in Portal V8
posted on Fri Sep 06, 2013 at 01:08 PM

With the addition of the new managed pages functionality in Portal V8, using the WCM API within portlets or themes running in a virtual portal poses a new set of challenges. Using repository.getSystemWorkspace is just not enough anymore to access your libraries. If you're still on v8.0.0.0, you're in trouble as the following was not enabled until v8.0.0.1!

First, let's keep in mind that when your java code executes, it's being executed in the base portal as all portlets and themes are running there. Only pages and WCM assets are running within the scope of the virutal portal. If you need to access a particular library within your custom portlet or theme, you must know your virtual portal context, or at least be able to determine it using the request object. For the following, we're going to assume we know the VP context we're running in.

This is going to be a simple example, but you'll be able to take this concept and apply it to your situation.

My servlet:

 public class MyServlet extends HttpServlet{

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

//First, access the repository like normal

Repository repo = WCM_API.getRepository();

//Create the required VirtualPortalContext using the repository

VirtualPortalContext vctx = repo.generateVPContextFromContextPath("testvp");

//Create VP Scoped Action object

VPScopedActionContentSearch vpA = new VPScopedActionContentSearch();

//execute code in the VP

repo.executeInVP(vctx, vpA);

//get the returned value

Content content = vpA.getReturnedValue();



Create custom class of VPScopedActionContentSearch

 public class VPScopedActionContentSearch implements VirtualPortalScopedAction{

//class level variables

private Content returnedValue = null;

//public constructor

public VPScopedActionContentSearch(){


//method to retrieve found content

public Content getReturnedValue(){

return returnedValue;


//overwritten method


public void run() throws WCMException {

Repository repo = WCM_API.getRepository();

Workspace ws = repo.getSystemWorkspace();


DocumentLibrary docLib = ws.getDocumentLibrary(“My VP Scoped Lib”);


QueryService qs = qs.createQuery(Content.class);


ResultIterator results = qs.execute(query);


returnedValue = (Content)results.next();






There you have an example of how to create your own custom class implementing the VirtualPortalScopedAction interface and use it to execute code scoped to a specific virtual portal.

View Comments      

Blog Posts

I stand with Ferrari against Deadmau5, and here's why.

Themes in WPS v8.5 - What's different?

Using WCM API in Virtual Portal with Managed Pages Enabled in Portal V8

Everything Happens for a Reason

IBM WebSphere Portal v7 Theme Metadata, the NEW Theme Policy

Creating a custom Portal theme based on the Theme

Philip v3.0

You can be surprised as to what you can do with 8 people in 52hrs!

Turns out, putting a Ford V8 in a BMW takes a lot of work!

Creating URLs to Portal Pages and/or Portlets

Gathering User Metrics with Custom Portlet Service

BMW Update

Choosing a Software Vendor

The Art of Successful Software Development

Accessing PUMA Service from a Java Servlet in IBM WebSphere Portal 6.1.x

Retrieving WCM Components Using IBM Web Content Management Java API in WebSphere Portal 6.1.x

Uploading an Image, Resizing, and Saving to Web Content Management using IBM WebSphere Portal 6.1.x

Retrieving URL Parameters in IBM WebSphere Portal 6.1.5

New Website Design Launched!

Gauging Interest: Free AutoX Registration Software

e36 Acquired!

This Week

Starting to come together!