Show TOC

Background documentationDeveloping a Custom Handler Locate this document in the navigation structure

 

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 INamespacesHandler (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 naming conventions service.

      The following is the method's signature:

      Syntax Syntax

      1. public String getHandlerID() {
      2. }
      End of the code.
    3. Implement the getAvailableNamespaces() method. This method returns an array of strings to be displayed to the administrator as valid namespaces.

      The following is the method's signature:

      Syntax Syntax

      1. public String[] getAvailableNamespaces(String configuration, 
             IPrincipal user, String path) throws OperationFailedException {
      2. }
      End of the code.

      The method is passed the following:

      • configuration: The mode parameter in the service configuration. For more information, see Configuring the Service.

      • 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.

      Syntax Syntax

      1. INamingConventionsSrv srv = (INamingConventionsSrv) 
      2.   PortalRuntime.getRuntimeResources().getService(
      3.     INamingConventionsSrv.KEY);
      4. try
      5. {
      6.   srv.registerHandler(new myHandler());
      7. }
      8. catch (RegistrationException e)
      9. {
      10.   e.printStackTrace();
      11. }
      End of the code.
  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.

To use your handler instead of the default handler, enter the handler ID in the handler parameter of the naming conventions service. For more information, see Configuring the Service.