Skip Headers

Oracle Internet File System Developer Reference
Release 9.0.1.1.0

Part Number A90093-02
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

17
Customizing Content Type Behavior

This chapter explains how to customize the behavior of content types. The chapter covers the following topics:

Customizing Content Type Behavior : Overview

As discussed in Chapter 5, "Extending Content Types and Attributes", when you create custom content types, they automatically inherit the behaviors of the content types they extend. Without having to do any Java programming, you can leverage all of the content management capabilities built into Oracle 9iFS for custom types of information. Application users will be able to parse, render, and manage the life cycle of instances of the custom content type with any of the clients and protocols servers that come with Oracle 9iFS out of the box.

How Content Type Behavior is Implemented

As discussed in Chapter 3, "Java API Overview", every out-of-the-box content type possesses a set of Java classes that implement its behavior. Behaviors, such as converting a document to HTML or generating a summary of the document, are implemented via methods on these Java classes.

To customize content type behavior, you can extend the bean-side and server-side Java classes. You can create extended bean-side Java classes to allow applications to access custom attributes and behaviors implemented for a content type. You can extend the server-side Java class for a content type to modify how Oracle 9iFS performs certain operations, such as insert, update, and delete.

As illustrated in Table 17-1, the bean-side and server-side Java classes parallel the content type hierarchy. For example, S_PublicObject.class implements the behavior of the PublicObject content type. The S_Document.class implements the behavior of the Document content type. Just as the Document content type extends the PublicObject type to inherit the PublicObject type's attributes, S_Document.class extends S_PublicObject.class to inherit its methods and add new methods that pertain to the Document content type.

Between each content type's bean-side and server-side Java class is a Tie class. Tie classes are placeholders for inserting custom code at any point in the class hierarchy, without modifying the out-of-the-box Java classes.


Table 17-1 Content Type Java Class Hierarchy
Content Type  Bean-side Java Class  Server-side Java Class 

LibraryObject 

java.lang.Object

oracle.ifs.beans.LibraryObject
oracle.ifs.beans.TieLibraryObject 

java.lang.Object

oracle.ifs.beans.S_LibraryObject
oracle.ifs.beans.S_TieLibraryObject 

PublicObject 

oracle.ifs.beans.PublicObject
oracle.ifs.beans.TiePublicObject 

oracle.ifs.beans.S_PublicObject
oracle.ifs.beans.S_TiePublicObject 

Document 

oracle.ifs.beans.Document

oracle.ifs.beans.TieDocument 

oracle.ifs.beans.S_Document

oracle.ifs.beans.S_TieDocument 

Folder 

oracle.ifs.beans.Folder

oracle.ifs.beans.TieFolder 

oracle.ifs.beans.S_Folder

oracle.ifs.beans.S_TieFolder 

When you create a custom content type, you do not have to implement custom Java classes. Your custom content type will automatically be associated with the Java class of the content type that it extends. For example, when you create a custom content type, Image, that extends the Document content type, Oracle 9iFS automatically uses Document.class and S_Document.class to implement the behavior of the Image content type.

Using the Oracle 9iFS Java API to Customize Behavior

You can extend the Oracle 9iFS Java classes to implement custom behavior for content types. You can extend the Java API in three ways:

The following are some recommended practices when implementing custom Java classes:

Before You Begin Extending Behavior

Extending behavior is a complex task. We recommend that you postpone tackling custom Java Beans, server overrides, and Tie classes until you have had considerable experience with Oracle 9iFS and its Java API. Specifically, we suggest that your background should include knowledge and hands-on experience in the following areas:

Creating Custom Bean-side Java Classes

The bean-side Java classes in the Oracle 9iFS Java API provide the primary interface for applications to create and retrieve information, get and set attributes and content, and traverse relationships. When you create a custom content type, applications can use the Oracle 9iFS beans-side Java classes to manipulate instances of the content type. For example, to get and set custom attributes, the application can call the getAttribute() and setAttribute() methods on the LibraryObject class. To create new instances of a custom content type, the application can call the getAttributeByUpperCaseName() and setAttributeByUpperCaseName()methods on LibraryObjectDefinition.

You can extend the bean-side Java classes to provide methods that make it easier for applications to manipulate information. For example, you can implement convenience methods for getting and setting custom attributes, such as getImageWidth() and setImageWidth(). You can implement methods that create and retrieve custom relationships that are used to construct complex content types, such as getBookComponents().

Example of Implementing Bean-side Java Classes

To implement a custom bean-side Java class, follow these steps:

  1. Declare the Bean-side Class.

  2. Create the Constructor.

  3. Creating Custom Methods.

Declare the Bean-side Class

You must first include a class declaration. The bean-side class should extend the bean-side Tie class of the content type that your custom content type extends (e.g., Document). Put your class into a new custom package, such as MyCompany.MyApp.beans. (Do not add this class to the oracle.ifs.beans package.)

Example 17-1 Declaring the Class

public class Image extends TieDocument

Create the Constructor

The bean-side Java class must implement a constructor that calls the constructor for its superclass. Table 17-2 lists the parameters for the constructor.


Table 17-2 Constructor Parameters
Parameters  Datatype  Description 

session 

S_LibrarySession 

Current LibrarySession. 

ID 

java.lang.Long 

The ID of a preexisting instance of the content type. 

classID 

Long 

Class ID for the content type instance that is in the process of being created. 

data 

S_LibraryObjectData 

Data component for a preexisting instance of the content type. 

Example 17-2 Creating the Constructor

public Image(LibrarySession session, 
             Long id, 
             Long classID,
             S_LibraryObjectData data)
throws IfsException
{
  super(session, id, classID, data);
}

Creating Custom Methods

The bean-side Java class provides the primary interface for applications to work with your content type. You should implement methods that make the content type's custom attributes and behavior accessible to a client application. For example, you can implement convenience methods for getting and setting the custom attributes on your content type.

Example 17-3 Creating Convenience Methods

  public void setImageWidth(int newValue)
  throws IfsException
  {
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute("WIDTH", av);
  }

  public void setImageHeight(int newValue)
  throws IfsException
  {
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute("HEIGHT", av);
  }

  public int getImageWidth(LibrarySession session)
  throws IfsException
  {
    AttributeValue av = getAttribute("WIDTH");
    int width = av.getInteger(session);
    return width;
  }

  public int getImageHeight(LibrarySession session)
  throws IfsException
  {
    AttributeValue av = getAttribute("HEIGHT");
    int height = av.getInteger(session);
    return height;
  }

You can also include methods that perform processing tasks. For example, you might provide a method that derives data by performing mathematical functions on an instance's attribute values. Or, you might provide a method that retrieves all documents that are related to another document.

Example 17-4 Creating Processing Methods

public PublicObject[] getBooks(LibrarySession session)
throws IfsException
{
  PublicObject[] relObjs = 
     sel.getLeftwardRelationshipObjects("BOOK_RELATIONSHIP");

  return relObjs;
 }


NOTE:

Example 17-4 uses a Selector to get the Books that include the Image. See Chapter 8, "Building Search Applications" for instructions on how to use Selectors. 


Complete Example

The following example provides the complete sample code for a bean-side Java class for the custom content type Image.

Example 17-5 Creating an Image Bean-side Java Class

package MyCompany.MyApp.beans;

import oracle.ifs.beans.LibrarySession;
import oracle.ifs.beans.TieDocument;
import oracle.ifs.common.AttributeValue;
import oracle.ifs.common.IfsException;
import oracle.ifs.server.S_LibraryObjectData;

public class Image extends TieDocument
{
  public Image(LibrarySession session, 
               Long id, 
               Long classID,
               S_LibraryObjectData data)
  throws IfsException
  {
    super(session, id, classID, data);
  }

    public void setImageWidth(int newValue)
  throws IfsException
  {
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute("WIDTH", av);
  }

  public void setImageHeight(int newValue)
  throws IfsException
  {
    AttributeValue av = AttributeValue.newAttributeValue(newValue);
    setAttribute("HEIGHT", av);
  }

  public int getImageWidth(LibrarySession session)
  throws IfsException
  {
    AttributeValue av = getAttribute("WIDTH");
    int width = av.getInteger(session);
    return width;
  }

  public int getImageHeight(LibrarySession session)
  throws IfsException
  {
    AttributeValue av = getAttribute("HEIGHT");
    int height = av.getInteger(session);
    return height;
  }

public PublicObject[] getBooks(LibrarySession session)
throws IfsException
{
  PublicObject[] relObjs = getLeftwardRelationshipObjects("BOOK_RELATIONSHIP");

  return relObjs;
 }
}

Deploying Your Custom Bean-side Java Classes

To deploy a custom bean-side Java class for a content type, follow these steps:

  1. Compile and place your Java class on the Oracle 9iFS server host machine in a directory structure that corresponds to the class' package (Example 17-6). It is recommended that you create the package directory structure directly under the custom_classes directory in the Oracle 9iFS software home directory (Example 17-7). The custom_classes directory is already included in the CLASSPATH environment variable set by Oracle 9iFS.

  2. Ensure that the CLASSPATH environment variable is configured to make your class accessible to the Java Runtime Engine for Oracle 9iFS. If you have created the package directory structure directly under the custom_classes directory, you should not have to modify the CLASSPATH environment variable (Example 17-8).

  3. Set the BeanClassPath attribute on the ClassObject for your content type to reference the fully qualified classname for your custom class (Example 17-9).

Example 17-6 Compiling the Java Class

javac -deprecation MyCompany.MyApp.beans.Image.java

Example 17-7 Directory for the Bean-side Java Classes

$ORACLE_HOME/9ifs/custom_classes/MyCompany/MyApp/beans/Image.class

Example 17-8 Using XML to set the BeanClassPath for a New ClassObject

<?xml version="1.0" standalone="yes"?>
<CLASSOBJECT>
    <NAME>Image</NAME>   
    <SUPERCLASS RefType = "Name">Document</SUPERCLASS>  
    <BEANCLASSPATH>MyCompany.MyApp.beans.Image</BEANCLASSPATH>
    <ATTRIBUTES>
        <ATTRIBUTE>
            <NAME>Width</NAME>
            <DATATYPE>Integer</DATATYPE>
        </ATTRIBUTE>
        <ATTRIBUTE>
            <NAME>Height</NAME>
            <DATATYPE>Integer</DATATYPE>
        </ATTRIBUTE>
        <ATTRIBUTE>
            <NAME>Artists</NAME>
            <DATATYPE>DirectoryObject</DATATYPE>
            <CLASSDOMAIN RefType = "Name">DirectoryUser...</CLASSDOMAIN>
       </ATTRIBUTE>
    </ATTRIBUTES>
</CLASSOBJECT>

Example 17-9 Using XML to Update a ClassObject's BeanClassPath

<?xml version="1.0" standalone="yes"?>
<CLASSOBJECT>
    <UPDATE RefType = "Name">Image</UPDATE>   
    <BEANCLASSPATH>MyCompany.MyApp.beans.Image</BEANCLASSPATH>
</CLASSOBJECT>


NOTE:

For instructions on creating and updating ClassObjects, see Chapter 5, "Extending Content Types and Attributes"


Testing

To test your custom Java class, follow these steps:

  1. Write a simple Java application that constructs an instance of the class and calls the extended methods (Example 17-10).

  2. Compile the Java class and place it in a directory that is appropriate for its package (Example 17-11 and Example 17-12).

  3. Run the Java class (Example 17-13).

Example 17-10 Writing a Test for a Bean-side Java Class

// Copyright (c) 2001 Oracle Corporation
package MyCompany.MyApp.tests;

import oracle.ifs.beans.LibraryObject;
import oracle.ifs.beans.LibraryService;
import oracle.ifs.beans.LibrarySession;
import oracle.ifs.beans.Relationship;
import oracle.ifs.beans.Selector;

import oracle.ifs.common.AttributeValue;
import oracle.ifs.common.CleartextCredential;
import oracle.ifs.common.IfsException;

import MyCompany.MyApp.beans.Image;

public class TestBeanSideClass extends Object {

  public static void main(String[] args)
  {
     TestBeanSideClass TestBeanSideClass = new TestBeanSideClass(args);
  }

  public TestBeanSideClass(String[] args)
  {
    try
    {
      String userName = args[0];
      String userPassword = args[1];
      String serviceName = args[2];
      String schemaPassword = args[3];
      
      //Connect to Oracle 9iFS.
      LibraryService service = 
             LibraryService.startService(serviceName, schemaPassword);
      CleartextCredential cred = 
             new CleartextCredential(userName, userPassword);
      LibrarySession session = service.connect(cred, null);

      try
      {
        int i, icount, j, jcount;
        Image image;
        PublicObject[] images, books;
        PublicObject book;
        Selector s;

        //Obtain the Image instance
        s = new Selector(session);
        s.setSearchClassname("IMAGE");

        //Execute the query and retrieve each Image.
        images = s.getItems();

        jcount = (images == null) ? 0 : images.length;
        System.out.println("Images : " + jcount);

        for (j = 0; j < jcount; j++)
        {

          image = (Image) images[j];
          System.out.println("  Image : " + image.getName());
          System.out.println("    Width : " + image.getImageWidth(session));
          System.out.println("    Height : " + image.getImageHeight(session));

          System.out.println("   Setting Image Height and Width");

          image.setImageWidth(600);
          image.setImageHeight(800);
          
          System.out.println("    Width : " + image.getImageWidth(session));
          System.out.println("    Height : " + image.getImageHeight(session));

          books = image.getBooks(session);
          
          icount = (books == null) ? 0 : books.length;
          System.out.println("  Books : " + icount);

          for (i = 0; i < icount; i++)
          {
            book = books[i];
            System.out.println("  " + book.getName());
          }
        }
      } 
      catch (IfsException e)
      {
        System.out.println("An error occured.");
        System.out.println("======================");
        System.out.println(e.toString());
        e.printStackTrace();
      }

      //Disconnect.
      session.disconnect();
    } 
    catch (IfsException e)
    {
      System.out.println("Unable to connect to 9iFS.");
      System.out.println("======================");
      System.out.println(e.toString());
      e.printStackTrace();
    }
    catch (Exception e)
    {
      System.out.println("Unable to connect to 9iFS.");
      System.out.println("Ensure that you have supplied the correct");
      System.out.println("connection information in the following arguments: ");
      System.out.println("  args[0] = User Name");
      System.out.println("  args[1] = User Password");
      System.out.println("  args[2] = Service Name");
      System.out.println("  args[3] = Schema Password");
      System.out.println("Example:  ");
      System.out.println("  java " );
      System.out.println("    MyCompany.MyApp.tests.TestBeanSideClass");
      System.out.println("    system manager IfsDefault ifssys");
      System.out.println("======================");
     System.out.println(e.toString());
     e.printStackTrace();
    }
  }
}

Example 17-11 Compiling the Test Java Classes

javac -deprecation TestBeanSideClass.java

Example 17-12 Directory for the Test Java Classes

$ORACLE_HOME/9ifs/custom_classes/MyCompany/MyApp/tests/TestBeanSideClass.class

Example 17-13 Running the Test Java Classes

java MyCompany.MyApp.tests.TestBeanSideClass

Creating Server Overrides

The behavior of content types is implemented in server-side Java classes. The server-side classes possess the code that determines how Oracle 9iFS performs operations, such as insert, update and delete.

You can customize how Oracle 9iFS performs these operations by implementing server overrides. Overrides allow you to interrupt the standard flow of processing in the Oracle 9iFS server at certain predefined points. At these points, you can implement a custom processing task that must occur before or after an operation takes place.

For example, you may want to implement a business rule that ensures that new documents that pertain to a specific project are made accessible to members of that project. You could implement a custom processing task that checks the value of the document's Project attribute, and then automatically grants Discover access in the document's AccessControlList to a DirectoryGroup associated with that project. By implementing the task as a pre-insert override, you can ensure that the processing takes place before a document can be inserted into Oracle 9iFS.

Overrides are performed synchronously with the operation, as opposed to agents, which perform tasks asynchronously. This means that the custom processing task will be performed within the same transaction as the operation. If either fails, any changes made by the custom task and the operation will be rolled back.

How Overrides are Implemented

The Oracle 9iFS Java API provides hooks in the server-side beans that you can use to implement custom overrides. The hooks consist of pre-operation and post-operation methods placed on the S_LibraryObject and S_Relationship class. The methods are called by Oracle 9iFS before and after performing the corresponding operation. On install, the pre-operation and post-operation methods are empty.

To customize how Oracle 9iFS performs these operations, you can create a custom server-side Java class that includes methods that override the pre-operation and post-operation methods.



NOTE:

Since the code that implements Oracle 9iFS functionality is implemented in the server-side beans, methods that must be performed synchronously with Oracle 9iFS operations must also be placed on the server-side beans. 


The override methods can, in turn, call other custom methods in the server-side Java classes. For example, you might extend the server-side Java class to include convenience methods for getting and setting custom attributes. Or, you might include processing methods that manipulate information in the repository.



NOTE:

Extended methods can only be called by pre-operation or post-operation override methods. It is not possible to directly call extended methods on server-side Java classes from a client application. 


Table 17-3 lists all of the operations that have pre-operation and post-operation methods that you can override.


Table 17-3 Operation Override Methods
Operation  Override Method  Usage 

Insert 

extendedPreInsert()
on S_LibraryObject 

Used to perform a task before an object is inserted into Oracle 9iFS.

Example: To validate the value of an attribute based on the value of another attribute before it can be inserted into Oracle 9iFS. 

Insert 

extendedPostInsert()
on S_LibraryObject 

Used to perform a task after an object is inserted into Oracle 9iFS.

Example: To automatically put a document into a project folder that corresponds to the value of a Project attribute on the document. 

Update 

extendedPreUpdate()
on S_LibraryObject 

Used to perform a task before an object is updated in Oracle 9iFS.

Example: To verify that a document's ReviewStatus attribute is set to "Approved" before its PublicationStatus attribute can be set to "Published." 

Update 

extendedPostUpdate()
on S_LibraryObject 

Used to perform a task after an object is update in Oracle 9iFS.

Example: To automatically set the document's ACL attribute with the "Published" SystemAccessControlList when its PublicationStatus attribute is set to "Published." 

Free 

extendedPreFree()
on S_LibraryObject 

Used to perform a task before an object is removed from Oracle 9iFS.

Example: To archive a copy of the document before it is removed from Oracle 9iFS. 

Free 

extendedPostFree()
on S_LibraryObject 

Used to perform a task after an object is removed from Oracle 9iFS.

Example: To cascade delete all documents related to a compound document after it is removed from Oracle 9iFS. 

AddRelationship 

extendedPreAddRelationship()
on S_Relationship 

Used to perform a task before an object is added to a folder.

Example: To verify that the object is being put in the correct folder based on an attribute comparison. 

AddRelationship 

extendedPostAddRelationship()
on S_Relationship 

Used to perform a task after an object is added to a folder.

Example: To apply the folder's ACL to the object. 

RemoveRelationship 

extendedPreRemoveRelationship()
on S_Relationship 

Used to perform a task before an object is removed from a folder.

Example: To verify that the document is located in another folder so that it can still be accessed via a path. 

RemoveRelationship 

extendedPostRemoveRelationship()
on S_Relationship 

Used to perform a task after an object is removed from a folder.

Example: To update an attribute on the object that indicates the number of objects that are related to it as a reference, if the relationship being removed is a custom Reference_Relationships. 

Overriding the pre-operation and post-operation methods (i.e., extendedPreFree()) is easier and safer than overriding the methods (i.e., Free()) that implement the Oracle 9iFS operation. To override the methods that implement Oracle 9iFS operations, you would have to reproduce Oracle 9iFS source code. The code for operations like Insert, Update, and Delete in Oracle 9iFS is both complex and risky to override in this manner. A mistake could result in database corruption. Pre-operation and post-operation methods provide a way for you to implement your custom functionality, while Oracle 9iFS handles the complexities of performing the operation and maintaining data integrity in the database. For these reasons, Oracle 9iFS only supports overriding the pre-operation and post-operation methods.

Example of Using an Override

To write an override, follow these steps:

  1. Declare the Server-side Class.

  2. Create the Constructors.

  3. Implement the Pre-Operation and Post-Operation Override Methods.

Declare the Server-side Class

First, create a server-side Java class, S_Image, to represent your custom class in the server. S_Image extends S_TieDocument. Put this class into a new custom package, such as MyCompany.MyApp.server. (Do not add this class to the oracle.ifs.server package.)

Example 17-14 Declaring the Class

public class S_Image extends S_TieDocument

Create the Constructors

Every server-side Java class must implement two constructors:

Table 17-4 provides a description of the constructors' parameters.


Table 17-4 Constructor Parameters
Parameters  Datatype  Description 

session 

S_LibrarySession 

Current LibrarySession. 

data 

S_LibraryObjectData 

Data component 

classID 

Long 

Class ID for the object that is in the process of being created. 

Example 17-15 Creating the Constructors

public S_Image(S_LibrarySession session, S_LibraryObjectData data)
throws IfsException
{
  super(session, data);
}

public S_Image(S_LibrarySession session, java.lang.Long classID)
throws IfsException
{
  super(session, classID);
}

Implement the Pre-Operation and Post-Operation Override Methods

Create methods that override the pre-operation and post-operation methods.

For example, you might override the extendedPreInsert() method to set a system-set attribute. System-set attributes cannot be set by a client application. Instead, the value of system-set attributes is determined by business rules that are implemented on the server.

In another case, you might overriding the extendedPreInsert() method to automatically set an attribute based on the value of another attribute. Since the attribute's value is based on another attribute value, using a ValueDefault to automatically set the attribute will not suffice. You can implement the business rule that determines the attribute's value on the server as an override.

Table 17-5 provides a description of the method's parameters.


Table 17-5 Constructor Parameters
Parameters  Datatype  Description 

opState 

OperationState 

Used by the system to track the current state of operations. 

def 

S_LibraryObjectDefinition 

Current object definition to be updated with system attributes. 

Example 17-16 Implementing the Override Methods

This is an example of an extendedPreInsert() override that performs custom validation for a system-set attribute. Note that the code example includes placeholders, in bold, that must be replaced with the appropriate code for your application.


// Override Pre Insert Operation
  public void extendedPreInsert(OperationState opState,
                                S_LibraryObjectDefinition def) 
  throws IfsException
  {
    // ALWAYS call super
    super.extendedPreInsert(opState, def);

    // get our session
    S_LibrarySession session = getSession();

    // get the approver attribute so we can check it
    AttributeValue av1 = def.getAttribute("APPROVER");
    S_DirectoryUser approver = (av1 == null) ? null :
       (S_DirectoryUser) av1.getDirectoryObject(session);

    //validate the approver
    boolean verification = verifyApprover(approver);

    if (! verification)
    {
      // this will rollback the operation
      throw new IfsException( <your custom error code>, this );
    }

    // otherwise, set the APPROVED attribute.
    // the APPROVED bit is not settable or updateable
    // by users, but the server can set it thusly
    AttributeValue av2 = AttributeValue.newAttributeValue(true);
    def.setSystemSetAttribute("APPROVED", av2);
  }

  public boolean verifyApprover(S_DirectoryUser approver)
  {
    boolean verification = false;
    <your validation code>
    return verification;
  }
}

The first call after the method begins should be to "super." This call implements any processing that has been implemented in the same method for the superclass (e.g., S_Document). After that, implement any custom processing logic that you require.

The override methods can, in turn, call other extended methods on this or other server-side Java classes. For example, you might implement convenience methods for getting and setting custom attributes on a content type. Or, you might implement processing methods that manipulate or derive data from information in the repository.

Complete Example

The following sample code provides a complete, working example of a server-side override. The example extends Oracle 9iFS to automatically store .gif files as instances of a custom content type, Image. The content type possesses a server-side override that automatically sets the custom attribute, Artists, based on the value of another attribute.

  1. Create a new content type, Image, with the attributes Width, Height, and Artists (Example 17-17).

  2. Register the .gif file extension with the Image content type so that .gif files are automatically stored as Images when imported into (Example 17-18).

  3. Create a server-side Java class for the Image content type that includes an extendedPreInsert() override to automatically set the Artists attribute (Example 17-19).

Example 17-17 Creating the Image Content Type with XML

<?xml version="1.0" standalone="yes"?>
<CLASSOBJECT>
    <NAME>Image</NAME>   
    <SUPERCLASS RefType = "Name">Document</SUPERCLASS>  
    <ATTRIBUTES>
        <ATTRIBUTE>
            <NAME>Width</NAME>
            <DATATYPE>Integer</DATATYPE>
        </ATTRIBUTE>
        <ATTRIBUTE>
            <NAME>Height</NAME>
            <DATATYPE>Integer</DATATYPE>
        </ATTRIBUTE>
        <ATTRIBUTE>
            <NAME>Artists</NAME>
            <DATATYPE>DirectoryObject</DATATYPE>
            <CLASSDOMAIN RefType = "Name">DirectoryUser...</CLASSDOMAIN>
       </ATTRIBUTE>
    </ATTRIBUTES>
</CLASSOBJECT>

Example 17-18 Registering a File Extension for the Image Content Type with XML

<?xml version='1.0' standalone='yes'?>
<OBJECTLIST>
 <PROPERTYBUNDLE>
  <UPDATE RefType='ValueDefault'>ParserLookupByFileExtension</UPDATE>
   <PROPERTIES>
    <PROPERTY Action = 'add'>
     <NAME> gif </NAME>
      <VALUE DataType = 'String'>
         oracle.ifs.beans.parsers.ClassSelectionParser 
      </VALUE>
   </PROPERTY>
  </PROPERTIES>
 </PROPERTYBUNDLE>

 <PROPERTYBUNDLE>
  <UPDATE RefType='ValueDefault'> 
     IFS.PARSER.ObjectTypeLookupByFileExtension
  </UPDATE>
   <PROPERTIES>
    <PROPERTY Action = 'add'>
     <NAME>gif</NAME>
     <VALUE DataType='String'>Image</VALUE>
    </PROPERTY>
   </PROPERTIES>
  </PROPERTYBUNDLE>
</OBJECTLIST>

Example 17-19 Creating a Server-side Java Class for the Image Content Type

package MyCompany.MyApp.server;

import oracle.ifs.common.AttributeValue;
import oracle.ifs.common.IfsException;
import oracle.ifs.server.S_DirectoryUser;
import oracle.ifs.server.S_LibraryObjectData;
import oracle.ifs.server.S_LibraryObjectDefinition;
import oracle.ifs.server.S_LibrarySession;
import oracle.ifs.server.OperationState;
import oracle.ifs.server.S_TieDocument;

public class S_Image extends S_TieDocument
{
  // constructors
  public S_Image(S_LibrarySession session, S_LibraryObjectData data)
  throws IfsException
  {
    super(session, data);
  }

  public S_Image(S_LibrarySession session, Long classId)
  throws IfsException
  {
    super(session, classId);
  }

  // Overrides
  public void extendedPreInsert(OperationState opState, 
                                S_LibraryObjectDefinition def)
  throws IfsException
  {
    // Always call super
    super.extendedPreInsert(opState, def);

    // Get the LibrarySession
    S_LibrarySession session = getSession();

    // Get the related objects
    S_DirectoryObject owner;
    AttributeValue av1, av2;

    av1 = def.getAttribute("OWNER");
    owner = (S_DirectoryObject) av1.getDirectoryObject(session);

    av2 = def.getAttribute("ARTISTS");

    if (av2 == null)
    {
      S_DirectoryObject[] artists = {owner};
      def.setUserSetAttribute("ARTISTS", 
                       AttributeValue.newAttributeValue(artists));
    }
  }
}

Deploying Your Override Classes

To deploy your overrides for a content type, follow these steps:

  1. Compile and place the server-side Java class on the Oracle 9iFS server host machine in a directory structure that corresponds to the class' package (Example 17-20). Create the package directory structure directly under the custom_classes directory in the Oracle 9iFS software home directory (Example 17-21). The custom_classes directory is already included in the CLASSPATH environment variable set by Oracle 9iFS.

  2. Ensure that the CLASSPATH environment variable is configured to make your class accessible to the Java Runtime Engine for Oracle 9iFS. If you have created the package directory structure directly under the custom_classes directory, you should not have to modify the CLASSPATH environment variable (Example 17-22).

  3. Set the ServerClassPath attribute on the ClassObject for your content type to reference the fully qualified classname for your custom class.


NOTE:

For instructions on creating and updating ClassObjects, see Chapter 5, "Extending Content Types and Attributes" 


Example 17-20 Compiling Java Class

javac -deprecation MyCompany.MyApp.server.S_Image.java

Example 17-21 Directory for the Server-side Java Classes

$ORACLE_HOME/9ifs/custom_classes/MyCompany/MyApp/server/S_Image.class

Example 17-22 Using XML to Update a ClassObject's ServerClassPath

<?xml version="1.0" standalone="yes"?>
<CLASSOBJECT>
    <UPDATE RefType = "Name">Image</UPDATE>   
    <SERVERCLASSPATH>MyCompany.MyApp.server.S_Image</SERVERCLASSPATH>
</CLASSOBJECT>

Testing

To test your server-side overrides, write a simple Java application that constructs an instance of the content type and calls the methods that have been overridden. Check the results of your operation to ensure that the pre-operation or post-operation tasks were executed.

Example 17-23 Testing the Sever Override for the Image Content Type

To test the "Complete Example" that implements a server-side override for the Image content type, all you need to do is import a new .gif file into Oracle 9iFS. The .gif file extension has been registered for the Image content type so that Oracle 9iFS will automatically store the image as an instance of Image. On insert, Oracle 9iFS will automatically call the extendedPreInsert() override to implement the business rule for setting the Artists attribute.

Replacing Tie Classes

If you want to implement custom behavior for content types that come with Oracle 9iFS out-of-the-box, and have these behaviors inherited by all descending content types, you can replace the corresponding Tie class. Tie classes are placeholders for inserting custom code at any point in the class hierarchy without directly modifying the bean-side and server-side Java classes for out-of-the-box content types.

For every class in the Oracle 9iFS Java API, there is a corresponding Tie class. Each class that descends from that class extends its Tie class, rather than the class itself. For example, the custom class Image would extend TieDocument rather than Document.

java.lang.Object
  +--oracle.ifs.beans.LibraryObject
    +--oracle.ifs.beans.TieLibraryObject
      +--oracle.ifs.beans.PublicObject
        +--oracle.ifs.beans.TiePublicObject
          +--oracle.ifs.beans.Document
            +--oracle.ifs.beans.TieDocument
          +--oracle.ifs.beans.Folder
            +--oracle.ifs.beans.TieFolder

Tie classes allow you to alter the out-of-the-box behavior of the Oracle 9iFS classes by "tie-ing" into the hierarchy at any level. Tie classes hold a place in the Oracle 9iFS hierarchy so you can customize the behavior of existing Oracle 9iFS classes and make the new behavior part of the inheritance structure. You can replace a Tie class with a custom Tie class that includes extended methods. Since Tie classes are essentially "empty," you can replace them without having to reproduce all of the code that implements the out-of-the-box functionality of the Oracle 9iFS class being extended. Since all of the descending content types extend the Tie class rather than the Oracle 9iFS class itself, they will inherit the custom methods.

For example, you may want to implement custom archiving capabilities for all public information stored in Oracle 9iFS, including documents, folders, users and groups. Since they apply to all public information, the behaviors would best be implemented on the PublicObject content type, rather than implementing the functionality multiple times by extending the Document, Folder, User, and Group content types. You could replace the TiePublicObject class with a custom TiePublicObject class that extends PublicObject and includes the methods archive() and restore(). Since Document, Folder, User, and Group classes all extend TiePublicObject, they will automatically inherit the methods on PublicObject as well as the custom methods you implemented in TiePublicObject.

Replacing a Bean-side Tie Class

To replace a bean-side Tie class, follow these steps:

  1. Declare the Bean-side Tie Class.

  2. Create the Constructor.

  3. Create Custom Methods.

Declare the Bean-side Tie Class

First, include a class declaration. The bean-side Tie class should extend the bean-side class of the Oracle 9iFS content type that should possess the custom behavior (e.g., PublicObject). Include this class in the oracle.ifs.beans package.

Example 17-24 Declare the Class

public class TiePublicObject extends PublicObject

Create the Constructor

The bean-side Tie class must implement a constructor that calls the constructor for its super class. Table 17-6, "Constructor Parameters" lists the parameters for the constructor.


Table 17-6 Constructor Parameters
Parameters  Datatype  Description 

session 

S_LibrarySession 

Current LibrarySession. 

ID 

java.lang.Long 

The ID of a preexisting instance of the content type. 

classID 

Long 

Class ID for the content type instance that is in the process of being created. 

data 

S_LibraryObjectData 

Data component for a preexisting instance of the content type. 

Example 17-25 Constructor

public TiePublicObject(LibrarySession session, 
                       Java.lang.Long id, 
                       Java.lang.Long classID,
                       S_LibraryObjectData data, )
throws IfsException
{
  super(session, id, classID, data);
}

Create Custom Methods

Once you have declared your class and included the constructor, you can add methods to implement custom behavior for all instances of the Oracle 9iFS content type and its descending content types.

Example 17-26 Creating Custom Methods

public LibraryObject[] getAllRelationships(LibrarySession session, 
                                           String relationshipClass)
 throws IfsException
 {
    Long id = getId();
    LibraryObject[] relObjects, rightObjects, leftObjects;
    rightObjects = getRightwardRelationships(relationshipClass);
    leftwardObjects = getLeftwardRelationships(relationshipClass);

    int i;
    int rcount = (rightwardObjects == null) ? 0 : rightwardObjects.length;
    for (i = 0; i < rcount; i++)
    {
        relObjects[i] = rightwardObjects[i];
    }

    int lcount = (leftwardObjects == null) ? 0 : leftwardObjects.length;
    for (i = 0; i < lcount; i++)
    {
        relObjects[rcount + i] = rightwardObjects[i];
    }        
  
    return relObjects;
 }

Replacing a Server-side Tie Class

To replace a server-side Tie class, follow these steps:

  1. Declare the Server-side Tie Class.

  2. Create the Constructors.

  3. Create Override Methods.

Declare the Server-side Tie Class

First, declare the server-side Tie class. The server-side Tie class should extend the server-side class of the content type that should possess the custom methods (e.g., S_Relationship). Put your class into the oracle.ifs.server package.

Example 17-27 Declare the Class

public class S_TieRelationship extends S_Relationship

Create the Constructors

Every server-side Tie class must implement two constructors:

Table 17-7, "Constructor Parameters" provides a description of the constructors' parameters.


Table 17-7 Constructor Parameters
Parameters  Datatype  Description 

session 

S_LibrarySession 

Current LibrarySession. 

data 

S_LibraryObjectData 

Data component for a preexisting instance of the content type. 

classID 

Long 

Class ID for the content type instance that is in the process of being created. 

Example 17-28 Create the Constructors

public S_TieFolderRelationship(S_LibrarySession session, S_LibraryObjectData 
data)
throws IfsException
{
  super(session, data);
}

public S_TieFolderRelationship(S_LibrarySession session, java.lang.Long classID)
throws IfsException
{
  super(session, classID);
}

Create Override Methods

Include overrides to implement the custom behavior you want to perform on the Oracle 9iFS server. For example, you might implement an override that automatically sets an object's ACL attribute to the AccessControlList of its parent folder by overriding the extendedPreAddRelationship() method. All subclasses of the server-side Tie class will inherit these methods.



NOTE:

See "Creating Server Overrides" for instructions on implementing overrides. 


Example 17-29 Implement Override Methods

public void extendedPostAddRelationship(S_LibraryObjectDefinition def, 
                                OperationState opState)
throws IfsException
{
    // Always call super
    super.extendedPostAddRelationship(opState, def);

    // Get the LibrarySession
    S_LibrarySession session = getSession();

    // Get the related objects
    AttributeValue av1, av2;
    S_PublicObject f, po;
    av1 = def.getAttribute("LEFTOBJECT");
    f = (S_PublicObject) av1.getPublicObject(session);
    av2 = def.getAttribute("RIGHTOBJECT");
    po = (S_PublicObject) av2.getPublicObject(session);

    // Apply the Folder's ACL to the item being added to the folder
    S_AccessControlList acl = f.getAcl();
    po.setAttribute("ACL", 
                    AttributeValue.newAttributeValue(acl)); 
}

Complete Example

The following examples provide a complete representation of the bean-side and server-side Tie classes for the PublicObject content type.

Example 17-30 Replacing a Bean-side Tie Java class

package oracle.ifs.beans;

import oracle.ifs.beans.LibraryObject;
import oracle.ifs.beans.LibrarySession;
import oracle.ifs.beans.PublicObject;
import oracle.ifs.beans.Selector;

import oracle.ifs.common.IfsException;

import oracle.ifs.server.S_LibraryObjectData;

public class TiePublicObject 
 extends PublicObject 
{ 
 /** 
  * Constructs a TiePublicObject. 
  * 
  * @param session  the session 
  * @param id       the id 
  * @param classId  the class id 
  * @param data     the data 
  * 
  * @exception IfsException if the operation fails 
  * @pub 
  */ 
 protected TiePublicObject 
 ( 
  LibrarySession session, 
  Long id, 
  Long classId, 
  S_LibraryObjectData data 
 ) throws IfsException 
 { 
  super(session, id, classId, data); 
 } 

 public LibraryObject[] getAllRelationships(LibrarySession session, 
                                           String relationshipClass)
 throws IfsException
 {
    Long id = getId();
    LibraryObject[] relObjects, rightObjects, leftObjects;
    rightObjects = getRightwardRelationships(relationshipClass);
    leftwardObjects = getLeftwardRelationships(relationshipClass);

    int i;
    int rcount = (rightwardObjects == null) ? 0 : rightwardObjects.length;
    for (i = 0; i < rcount; i++)
    {
        relObjects[i] = rightwardObjects[i];
    }

    int lcount = (leftwardObjects == null) ? 0 : leftwardObjects.length;
    for (i = 0; i < lcount; i++)
    {
        relObjects[rcount + i] = rightwardObjects[i];
    }        
  
    return relObjects;
  }
} 

Example 17-31 Replacing a Server-side Tie Java class

package oracle.ifs.server;

import oracle.ifs.common.IfsException;
import oracle.ifs.common.AttributeValue;

import oracle.ifs.server.S_AccessControlList;
import oracle.ifs.server.S_PublicObject;
import oracle.ifs.server.OperationState;
import oracle.ifs.server.S_FolderRelationship;
import oracle.ifs.server.S_LibraryObjectDefinition;

public class S_TieFolderRelationship
extends S_FolderRelationship
{
  /** 
  * Constructs a TiePublicObject. 
  * 
  * @param session  the session 
  * @param id       the id 
  * @param classId  the class id 
  * @param data     the data 
  * 
  * @exception IfsException if the operation fails 
  * @pub 
  */ 

  // Constructors

  public S_TieFolderRelationship(S_LibrarySession session, 
                                 S_LibraryObjectData data)
  throws IfsException
  {
    super(session, data);
  }

  public S_TieFolderRelationship(S_LibrarySession session,  
                                 java.lang.Long classID)
  throws IfsException
  {
    super(session, classID);
  } 

  // Overrides
  public void extendedPostAddRelationship(OperationState opState, 
                                S_LibraryObjectDefinition def)
  throws IfsException
  {
    // Always call super
    super.extendedPostInsert(opState, def);

    // Get the LibrarySession
    S_LibrarySession session = getSession();

    // Get the related objects
    AttributeValue av1, av2;
    S_PublicObject f, po;
    av1 = def.getAttribute("LEFTOBJECT");
    f = (S_PublicObject) av1.getPublicObject(session);
    av2 = def.getAttribute("RIGHTOBJECT");
    po = (S_PublicObject) av2.getPublicObject(session);

    // Apply the Folder's ACL to the item being added to the folder
    S_AccessControlList acl = f.getAcl();
    po.setAttribute("ACL", 
                    AttributeValue.newAttributeValue(acl)); 
  }
}

Deploying Custom Tie Classes

To deploy a custom Tie class, follow these steps:

  1. Compile the custom Tie classes (Example 17-32).

  2. Create a directory to hold your custom Tie classes (e.g., tie_classes). It is recommended that the directory be located in the custom_classes directory located in the Oracle 9iFS software home directory (Example 17-33). In the custom Tie classes directory, create subdirectories that correspond to the Tie classes' package (e.g., oracle/ifs/beans and oracle/ifs/server). Move the custom classes to the appropriate directory.

  3. Modify the CLASSPATH environment variable on the Oracle 9iFS host machine to include the custom Tie class directory. Ensure that the path to these directories precedes the path to the repos.jar file in the CLASSPATH. This will enable the Java Virtual Machine to load your custom Tie classes instead of loading the Oracle 9iFS Tie classes in the repos.jar.

  4. Stop and start Oracle 9iFS to refresh the CLASSPATH for the JRE (Example 17-34).

Example 17-32 Compiling Java Classes

javac -deprecation TiePublicObject.java
javac -deprecation S_TieFolderRelationship.java

Example 17-33 Creating Directories for the Tie Classes on Solaris

$ORACLE_HOME/9ifs/custom_classes/tie_classes/oracle/ifs/beans
$ORACLE_HOME/9ifs/custom_classes/tie_classes/oracle/ifs/server

Example 17-34 Stopping and Starting Oracle 9iFS on Solaris

$ORACLE_HOME/9ifs/bin/ifsstopdomain
$ORACLE_HOME/9ifs/bin/ifsstartdomain


NOTE:

See the Oracle 9iFS Setup and Administration Guide for instructions on stopping and starting Oracle 9iFS. 


Testing

To test your custom Tie classes, follow these steps:

  1. Write a simple Java application that constructs an instance of the content type and calls the extended methods on that instance (Example 17-35).

  2. Compile the Java class (Example 17-36) and place it in a directory that is appropriate for its package (Example 17-37).

  3. Run the Java class (Example 17-38).

Example 17-35 Writing a Test for a Bean-side Tie Class

package MyCompany.MyApp.tests;

import oracle.ifs.beans.Folder;
import oracle.ifs.beans.LibraryObject;
import oracle.ifs.beans.LibraryService;
import oracle.ifs.beans.LibrarySession;
import oracle.ifs.beans.Relationship;
import oracle.ifs.beans.TiePublicObject;

import oracle.ifs.common.CleartextCredential;
import oracle.ifs.common.IfsException;

public class TestTiePublicObject extends Object {


  public static void main(String[] args)
  {
     TestTiePublicObject TestTiePublicObject = new TestTiePublicObject(args);
  }

  public TestTiePublicObject(String[] args)
  {
    try
    {
      String userName = args[0];
      String userPassword = args[1];
      String serviceName = args[2];
      String schemaPassword = args[3];
      
      //Connect to Oracle 9iFS.
      LibraryService service = 
             LibraryService.startService(serviceName, schemaPassword);
      CleartextCredential cred = 
             new CleartextCredential(userName, userPassword);
      LibrarySession session = service.connect(cred, null);

      try
      {
          session.setAdministrationMode(true);

          Folder f = session.getPrimaryUserProfile().getHomeFolder();
          System.out.println("Mome Folder : " + f.getName());

          LibraryObject[] rels = f.getAllRelationships(session, "RELATIONSHIP");

          int i, icount;
          Relationship rel;

          icount = (rels == null) ? 0 : rels.length;
          System.out.println(" Relationships : " + icount);

          for (i = 0; i < icount; i++)
          {
             rel = (Relationship) rels[i];
             System.out.println("   " + rel.getLeftObject().getName() + 
                                " : " + rel.getRightObject().getName());
          }
      } 
      catch (IfsException e)
      {
        System.out.println("An error occured.");
        System.out.println("======================");
        System.out.println(e.toString());
        e.printStackTrace();
      }

      //Disconnect.
      session.disconnect();
    } 
    catch (IfsException e)
    {
      System.out.println("Unable to connect to 9iFS.");
      System.out.println("======================");
      System.out.println(e.toString());
      e.printStackTrace();
    }
    catch (Exception e)
    {
      System.out.println("Unable to connect to 9iFS.");
      System.out.println("Ensure that you have supplied the correct");
      System.out.println("connection information in the following arguments: ");
      System.out.println("  args[0] = User Name");
      System.out.println("  args[1] = User Password");
      System.out.println("  args[2] = Service Name");
      System.out.println("  args[3] = Schema Password");
      System.out.println("Example:  ");
      System.out.println("  java " );
      System.out.println("    MyCompany.MyApp.tests.TestTiePublicObject");
      System.out.println("    system manager IfsDefault ifssys");
      System.out.println("======================");
     System.out.println(e.toString());
     e.printStackTrace();
    }
  }
}

Example 17-36 Writing a Test for a Server-side Tie Class

package MyCompany.MyApp.tests;

import oracle.ifs.beans.AccessControlList;
import oracle.ifs.beans.Folder;
import oracle.ifs.beans.FolderDefinition;
import oracle.ifs.beans.LibraryService;
import oracle.ifs.beans.LibrarySession;

import oracle.ifs.common.AttributeValue;
import oracle.ifs.common.CleartextCredential;
import oracle.ifs.common.Collection;
import oracle.ifs.common.IfsException;

public class TestServerTieClass extends Object {

  public static void main(String[] args)
  {
      TestServerTieClass TestServerTieClass = new TestServerTieClass(args);
  }

  public TestServerTieClass(String[] args)
  {
    try
    {
      String userName = args[0];
      String userPassword = args[1];
      String serviceName = args[2];
      String schemaPassword = args[3];
      
      //Connect to Oracle 9iFS.
      LibraryService service = 
             LibraryService.startService(serviceName, schemaPassword);
      CleartextCredential cred = 
             new CleartextCredential(userName, userPassword);
      LibrarySession session = service.connect(cred, null);

      try
      {
         AccessControlList defACL, propagatedACL, privateACL, publicACL;
         Folder propagatedF, privateF, publicF;
         String propagatedFName, privateFName, publicFName;

         // Get the session's ID to generate unique folder names.
         Long sessionId = session.getId();

         // Create a FolderDefinition which will be used
         // to create three folders to test the Tie class.
         FolderDefinition fd = new FolderDefinition();
         
         // Create a new folder which will be orphaned and 
         // therefore acquire the user's default ACL.
         fd.setAttributeByUpperCaseName("NAME", 
            AttributeValue.newAttributeValue("PropACLFolder" + sessionId));
         propagatedF = (Folder) session.createPublicObject(fd);
         propagatedFName = propagatedF.getName();

         System.out.println(propagatedFName + " created.");

         defACL = propagatedF.getAcl();
         System.out.println("  The folder is currently orphaned");
         System.out.println("  so it has the default ACL : " 
             + defACL.getName());
         
         // Get the Private and Public ACLs to be set explicitly
         // on two new folders.
         Collection systemACLs = session.getSystemAccessControlListCollection();
         privateACL = (AccessControlList) systemACLs.getItems("Private");
         publicACL = (AccessControlList) systemACLs.getItems("Public");

         // Create another folder which has the Private ACL.
         fd.setAttributeByUpperCaseName("NAME", 
            AttributeValue.newAttributeValue("PrivFolder" + sessionId));
         fd.setAttributeByUpperCaseName("ACL", 
            AttributeValue.newAttributeValue(privateACL));
         privateF = (Folder) session.createPublicObject(fd);
         privateFName = privateF.getName();

         System.out.println(privateFName + " created.");
         System.out.println(privateFName + "'s ACL is : " 
                + privateF.getAcl().getName());

         // Add the original folder to the Private folder to automatically
         // apply the Private ACL with the server override on the Tie class.
         privateF.addItem(propagatedF);
         System.out.println("  Added " + propagatedFName + " to " 
            + privateFName);

         propagatedACL = propagatedF.getAcl();
         System.out.println("  " + propagatedFName + "'s ACL is now : " 
           + propagatedACL.getName());

         // Create another folder which has the Public ACL.
         fd.setAttributeByUpperCaseName("NAME", 
            AttributeValue.newAttributeValue("PubFolder" + sessionId));
         fd.setAttributeByUpperCaseName("ACL", 
            AttributeValue.newAttributeValue(publicACL));
         publicF = (Folder) session.createPublicObject(fd);
         publicFName = publicF.getName();

         System.out.println(publicFName + " created");
         System.out.println(publicFName + "'s ACL is : " 
              + publicF.getAcl().getName());

         // Add the original folder to the Public folder to automatically
         // apply the Public ACL with the server override on the Tie class.
         publicF.addItem(propagatedF);
         System.out.println("  Added " + propagatedFName + " to " 
            + publicFName);

         propagatedACL = propagatedF.getAcl();
         System.out.println("  " + propagatedFName + "'s ACL is now : " 
           + propagatedACL.getName());
      } 
      catch (IfsException e)
      {
        System.out.println("An error occured.");
        System.out.println("======================");
        System.out.println(e.toString());
        e.printStackTrace();
      }

      //Disconnect.
      session.disconnect();
    } 
    catch (IfsException e)
    {
      System.out.println("Unable to connect to 9iFS.");
      System.out.println("======================");
      System.out.println(e.toString());
      e.printStackTrace();
    }
    catch (Exception e)
    {
      System.out.println("Unable to connect to 9iFS.");
      System.out.println("Ensure that you have supplied the correct");
      System.out.println("connection information in the following arguments: ");
      System.out.println("  args[0] = User Name");
      System.out.println("  args[1] = User Password");
      System.out.println("  args[2] = Service Name");
      System.out.println("  args[3] = Schema Password");
      System.out.println("Example:  ");
      System.out.println("  java " );
      System.out.println("    MyCompany.MyApp.tests.TestServerTieClass");
      System.out.println("    system manager IfsDefault ifssys");
      System.out.println("======================");
      System.out.println(e.toString());
      e.printStackTrace();
    }
  }
}

Example 17-37 Compiling the Test Java Classes

javac -deprecation TestTiePublicObject.java
javac -deprecation TestServerTieClass.java

Example 17-38 Directory for the Test Java Classes

$ORACLE_HOME/9ifs/custom_classes/MyCompany/MyApp/tests/

Example 17-39 Running the Test Java Classes

java MyCompany.MyApp.tests.TestTiePublicObject
java MyCompany.MyApp.tests.TestServerTieClass

Sample Code

Oracle 9iFS is installed with runnable sample code files for the examples in this chapter. The sample code files are located in the <ORACLE_HOME>/9ifs/samplecode/oracle/ifs/examples/devdoc/customizingbehavior directory. Table 17-8 lists the sample code files and their corresponding examples.


Table 17-8 Example Sample Code Files
Example  Sample Code File 

Example 17-5, "Creating an Image Bean-side Java Class" 

Image.java 

Example 17-8, "Using XML to set the BeanClassPath for a New ClassObject" 

DeployBeanSideClassforNewCT.xml 

Example 17-9, "Using XML to Update a ClassObject's BeanClassPath" 

DeployBeanSideClassforExistingCT.xml 

Example 17-10, "Writing a Test for a Bean-side Java Class" 

TestBeanSideClass.java 

Example 17-17, "Creating the Image Content Type with XML" 

CreateContentType.xml 

Example 17-18, "Registering a File Extension for the Image Content Type with XML" 

RegisterContentTypeExtensions.xml 

Example 17-19, "Creating a Server-side Java Class for the Image Content Type" 

S_Image.java 

Example 17-22, "Using XML to Update a ClassObject's ServerClassPath" 

DeployServerSideClass.xml 

Example 17-30, "Replacing a Bean-side Tie Java class" 

TiePublicObject.java 

Example 17-31, "Replacing a Server-side Tie Java class" 

S_TieFolderRelationship.java 

Example 17-35, "Writing a Test for a Bean-side Tie Class" 

TestTiePublicObject.java 

Example 17-36, "Writing a Test for a Server-side Tie Class" 

TestServerTieClass.java 

In addition to the example sample code files, Oracle 9iFS is installed with more advanced sample code that helps you get started working with the Java API. The API sample code is located in the <ORACLE_HOME>/9ifs/samplecode/api directory.

The following API sample code is relevant to this chapter.


Table 17-9 API Sample Code
Class  Usage 

OverrideSample.java 

Demonstrates server-side overrides, extendedPreAddItem (ReportFolder) and extendedPreFree (Report). Uses a JDBC connection to update a table in a different schema 


Go to previous page Go to next page
Oracle
Copyright © 2001 Oracle Corporation.

All Rights Reserved.
Go To Table Of Contents
Contents
Go To Index
Index