Show TOC Start of Content Area

Procedure documentation Implementing an IResource Handle Locate the document in its SAP Library structure

Use

The IResourceHandle object maps the third-party backend system to the repository framework. It handles the mapping of data from the objects of the backend system to the unified aspects of the Repository Manager implementation.

Procedure

A Repository Manager has to implement its own representation of IResourceHandle either by implementing the IResourceHandle interface or by extending the abstract class AbstractHandle.

The figure illustrates the role of the IResourceHandle object in the repository framework.

This graphic is explained in the accompanying text

Implement the interface as described in the following: 

public class SimpleHandle implements IResourceHandle

The IResourceHandle interface exposes only one interface method that you need to implement:

public IRid getRid();

The getRid() method must return a hierarchically structured identifier (RID) which addresses and identifies the backend object within the repository framework.

The handle object itself should contain context information from the repository framework, which can be used by the third-party backend system. The context information, for example, user and language, can be passed through the handle’s constructor and stored in member variables.

 

  SimpleHandle(Node node,
               IUser user,
               Locale locale) {
    this.m_node = node;
    this.m_user = user;
    this.m_locale = locale;
  }

 

As IResourceHandle objects are used as keys in Maps (see implementation property unified aspects), we recommend that you override the hashCode() and equals()methods of the implementation:

 
  public boolean equals(Object obj) {
    if(   ( obj != null )
       && ( obj instanceof SimpleHandle )
      ) {
      SimpleHandle o = (SimpleHandle)obj;
      if(   ( o.getRid().equals(this.getRid()) )
         && ( o.m_locale.equals(this.m_locale) )
         && ( o.m_user.equals(this.m_user) )
        ) {
        return true;
      }
    }
    return false;
  }
 
  public int hashCode() {
    return this.getRid().hashCode()
           + this.m_locale.hashCode()
           + this.m_user.hashCode();
  }
 

 

In the sample implementation, the backend objects are represented as Node and FolderNode objects. They contain a wrapper for file system objects such as files and folders. The IResourceHandle implementation (SimpleHandle) in the sample holds a reference to a corresponding Node or FolderNode object in the backend. To allow direct handling of these objects, the handle also exposes an implementation-dependent method getNode():

 

  public Node getNode() {
    return this.m_node;
  }

 

Methods that you implement for an IResourceHandle implementation are:

getRID()

Returns a hierarchical resource identifier (RID)  to identify a referenced backend object

equals()

Indicates whether any other object is equal to this one

hashCode()

Returns a hash code value for the object

 

End of Content Area