+

Search Tips   |   Advanced Search

Project URL generation

We can redirect request processing to a specific project by generating URLs with the ProjectIdentificationService API, the REST API, or the Enabler API. Request processing operates either completely within the scope of a project or completely outside the scope of a project. We cannot switch projects during request processing.

When a request originates from within a project, the request URL contains a project identifier for that project. The project information is included only in the URL and is not bound to the session. The project identifier can be an object ID (OID), as used by the portal, or a universally unique identifier (UUID), as used by Web Content Manager. To direct request processing to a specific project, generate a URL for the project and then render the URL.


Java API

To generate URLs that target a project using the Java API in the portal, we can use the ProjectIdentificationService API with the StateManagerService API:

This example constructs a portal URL to the current navigational state for a new project:

  // construct a server context for the project   final ServerContext projectCtx = projectService.createServerContext(
    projectID, stateService.getServerContext());

  // access the URL factory to create a URL
  final URLFactory urlFct = stateService.getURLFactory(projectCtx);

  // construct a URL to the current state
  final EngineURL url = urlFct.newURL(Constants.SMART_COPY);
  url.writeDispose(out);

  // done with URL generation
  urlFct.dispose();

This example constructs a portal URL to a URI in a specific project:

  // construct a server context for the project   final PocServerContext projectCtx = projectService.createServerContext(
    projectID, pocService.getServerContext());

  // access the URL factory to create a URL
  final DisposablePocURLFactory urlFct = pocService
    .getURLFactory(projectCtx);

  // construct a URL to the current state
  final PocURL url = urlFct.newURL(PocURLFactory.LATE_BINDING);
  url.setMode(Constants.VALUE_DOWNLOAD);
  url.setURI(new URI("test:abc"));

  // serialize
  url.writeDispose(out);

  // done with URL generation
  urlFct.dispose();


REST API

If the application uses the Representational State Transfer (REST) architecture, we can use the remote APIs provided with the portal to construct project-specific URLs.


Enabler API

If we are using the Enabler API, we can pass the project identifier to the URL generation API as the parameter project in the parameters object. The project identifier can be either a serialized OID or a UUID.

// get the current nav state
var state = com.ibm.mashups.enabler.model.state;
var navState = state.NavigationStateModelFactory.getNavigationStateModel();

// get the URL generator
var urlGen = state.UrlGeneratorFactory.getURLGenerator();
urlGen.getURL(navState, function(url) { alert(url); }, { "project": "UUID-of-Project" } );


Parent: Administer managed pages