3.9 Extending the Object Management Tasks

The iManager Base Content module provides a role called eDirectory Administration. If you are assigned to the role, you have access to tasks that allow you to create, delete, move, and rename eDirectory objects. These tasks are generic: they work on almost any type of object and they operate on each object in the same way. However, you can extend these tasks to customize the management action for certain types of objects. For example, you could create a task that deletes groups only, keeps a log of deletions, and sends a notice when the task is used to delete a group. You can also disallow deletion of certain types of objects.

The object management tasks that you can extend are:

3.9.1 Registering an Object Type for the Create Object Task

The Create Object task only creates objects of types that are registered with iManager for the creator task. This is different from the behavior of the Delete, Move, and Rename tasks, which operate on all objects unless you specify otherwise (see Section 3.9.2, Extending the Delete, Move, and Rename Tasks).

iManager provides a generic creator task, com.novell.emframe.fw.GenericCreator. The generic creator task shows the user the default fields for the mandatory attributes of the object type that the user has chosen to create. If you need to enable the create object task for a class that is not registered, and all you need to do is collect information for the mandatory attributes, you can enable your class by simply adding an <object-creator> section to the SDK_HOME/tomcat/webapps/nps/portal/fw/plugins/creator.xml file using com.novell.emframe.fw.GenericCreator as the value of the <class-name> element, as shown in the following example:

 <object-creator>
   <id>dbm.CreateServer</id>
   <version>1.0</version>
   <required-version>2.7</required-version>
   <class-name>com.novell.emframe.fw.GenericCreator</class-name>
   <object-type-name>Database Server</object-type-name>
 </object-creator>
 

If the generic creator doesn't work for you, create a task that creates objects the way you need it to work then specify the class as the value of the <class-name> element in SDK_HOME/tomcat/webapps/nps/portal/fw/plugins/creator.xml. This causes the creator to launch your task instead of the generic creator. For example:

 <object-creator>
   <id>dbm.CreateServer</id>
   <version>1.0</version>
   <required-version>2.7.0</required-version>
   <class-name>com.company.imanager.CreateServer</class-name>
   <object-type-name>Database Server</object-type-name>
 </object-creator>
 

3.9.2 Extending the Delete, Move, and Rename Tasks

  1. Create a Java class that extends the class of the task you want to use.

    For example, if you want to use the Delete Object task, your class must extend com.novell.emframe.dev.Deletor.

  2. In your class, implement the doDelete(ObjectEntry, TaskContext), the doRename( ObjectEntry, String, TaskContext ), or the doMove( ObjectEntry, ObjectEntry, TaskContext ) method to perform the desired action. In the appropriate method, either complete the operation and return or throw a PluginException constructed with the header and body of the message to display to the user.

    NOTE:The doXXX() method names may be overloaded, so make sure that you pass in the correct set of arguments in order to get the result you are expecting.

  3. Register your plug-in with iManager by adding an <object-deletor>, <object-move>, or <object-rename> section to the XML file in SDK_HOME/tomcat/webapps/nps/portal/modules/fw/plugins that corresponds to the task to which you are plugging in. Use the <object‑type‑name> element to designate object types that your task works with, and use the <class‑name> element to specify the class name of your Java class. For example, the following <object-deletor> section registers a deletor plug-in when added to deletor.xml:

     <object-deletor>
       <id>dbm.DeleteServer</id>
       <version>1.0</version>
       <required-version>2.7.0</required-version>
       <object-type-name>Database Server</object-type-name>
       <class-name>com.company.imanager.DeleteServer</class-name>
     </object-deletor>
     

    The following XML registers a move plug-in when added to move.xml:

     <object-move>
       <id>dbm.MoveServer</id>
       <version>1.0</version>
       <required-version>2.7.0</required-version>
       <object-type-name>Move Server</object-type-name>
       <class-name>com.company.imanager.MoveServer</class-name>
     </object-move>
     
  4. Create a registration file for the plug-in. Specify the base task class (for example, DeleteObjectTask) and the object type you are working with.

  5. To veto performance of the action on an object type, throw an exception in the doXXX() method with the message to be displayed to the user when the user tries to act on that object type.

3.9.3 Disallowing Operation of an Object Management Task on an Object Type

You can extend the Create, Delete, Move, or Rename tasks to disallow, or “veto,” the operation of an object management task on objects of a particular type. However, iManager provides classes that perform a basic veto on the Create, Delete, Move, and Rename tasks. You can register an object type using one of these veto classes to disallow operation of the task on that object type. For example, the following section in deletor.xml disallow deletion of the Database Server type:

 <object-deletor>
   <id>dbm.DeleteServer</id>
   <version>1.0</version>
   <required-version>2.7.0</required-version>
   <object-type-name>Database Server</object-type-name>
   <class-name>com.novell.emframe.dev.VetoDeletor</class-name>
 </object-deletor>
 

The veto classes are as follows:

  • com.novell.emframe.dev.VetoCreatorTask

  • com.novell.emframe.dev.VetoDeletor

  • com.novell.emframe.dev.VetoMove

  • com.novell.emframe.dev.VetoRename

If the veto plug-ins provided with iManager do not suit your needs, you can create your own. For example, you might want to create a plug-in that sends a notice to an administrator when a user attempts to delete objects of a certain type.

To veto the creator task, create a custom task that extends Task and register it as explained in Section 3.9.1, Registering an Object Type for the Create Object Task. The task should implement the execute method and return false after displaying an error message.

To veto the deletor, move, or rename tasks, extend the task for the action you want to veto (Delete, Move, or Rename) and register the task, as explained in Section 3.9.2, Extending the Delete, Move, and Rename Tasks. In the doXXX() method, throw a PluginException with the message to be displayed to the user when the user tries to act on the object type for which your class is registered.