+

Search Tips   |   Advanced Search

Project URL generation

We can redirect request processing to a specific project by generating URLs with the ProjectIdentificationService API, or the REST API. Request processing operates either completely within the scope of a project or completely outside the scope of a project. You 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, we must 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, you can use the remote APIs provided with the portal to construct project-specific URLs.

Parent topic: Administer managed pages