Show TOC

Developing a Custom Handler for Namespace Naming ConventionsLocate this document in the navigation structure

Use

You can develop your own custom handler for determining valid namespaces. The handler is called whenever an administrator creates or changes the ID of a PCD object, and the handler returns an array of strings of valid namespaces.

A handler is deployed in an application that contains the handler class and a service for registering the handler.

Procedure
  1. Create the handler, as follows:

    1. Create a class that implements the INamespacesHandler interface ( com.sap.portal.pcm.namingconventions package).

    2. Implement the getHandlerID() method, which returns the handler ID. This ID identifies the handler, and is used in the service configuration to indicate the handler for the NamingConventionsSrv service.

    3. Implement the getAvailableNamespaces() method. This method returns an array of strings to be displayed to the administrator as valid namespaces.

      The method declaration:

      public String[] getAvailableNamespaces(String configuration, 
           IPrincipal user, String path) throws OperationFailedException {
      }
                           

      Where:

      • configuration : The mode parameter in the service configuration.

      • user : The current user.

      • path : The path of the parent folder that contains the object to be created or changed.

  2. Create a service for registering your handler with the naming conventions service, as follows:

    1. Create a portal service.

    2. In the afterInit() method, register the service by getting the naming conventions service and passing the registerHandler() an instance of your handler.

      INamingConventionsSrv srv = (INamingConventionsSrv) 
        PortalRuntime.getRuntimeResources().getService(
          INamingConventionsSrv.KEY);
      try
      {
        srv.registerHandler(new myHandler());
      }
      catch (RegistrationException e)
      {
        e.printStackTrace();
      }
                           
  3. In the portalapp.xml for your application, set the service to start on deployment, by setting the startup property in the <service-config> element to true .

  4. Enter the handler ID in the handler parameter of the naming conventions service, to use your handler instead of the default handler.