Tuesday, May 19, 2009

Intralink Scripting: Commonspace Folder Info - Part 2

In Part 1, I discussed how to use ILFolderTreeModel to recursively descend through your Commonspace folders to generate a folder list. Coupled with other classes, you can generate even more data about your folders.

In a previous article, I discussed the ObjectInfo subclasses and how to use them to get object metadata. In this article, I'll discuss how to use the ObjectInfo subclass pertaining to Commonspace folders called CSFolderObjectInfo.

The CSFolderObjectInfo class contains many methods to interact with Commonspace folders. The ObjectInfo class are extremely powerful as they let you bypass the user interface and talk directly with the data model of the Intralink client. Despite its name, the CSFolderObjectInfo class contains many methods to perform actions upon Commonspace folders, not just to get information about them.

Examples of methods specific to the CSFolderObjectInfo are: getParent(), getFullPath(), setDescription(), createFolder(), deleteFolder(), moveFolder(), getFilespace(), getReleaseLevel(), getReleaseScheme(), setRelScheme(), etc. Not all of these are guaranteed to work as you may hope. Caution must be exercised before experimenting on your production system. Do so at your own risk.

Before you can apply these methods, you need a CSFolderObjectInfo object. One way to instantiate a CSFolderObjectInfo object is with the static method createByKey() in the ObjectInfo class, although sometimes there are other ways. Here is an example, using the static field tFolder to specify the ObjectInfo object type and a String value for the folder name:

    CSFolderObjectInfo fol_oi = null;
fol_oi = (CSFolderObjectInfo)ObjectInfo.createByKey( ObjectInfo.tFolder, "Root Folder/ProjectX" );
 

This is a very generic technique that can be applied to most other ObjectInfo data types, even though there are specific createByKey() methods for specific object types.


Example: Release Scheme, File Space, and Release Levels

This example expands upon the code in Part 1, by adding the output of the Release Scheme name, the File Space used, and the Release Levels associated with each folder. Both getReleaseScheme() and getFilespace() return String values of their respective outputs. getReleaseLevel() returns a String array of Release Levels.

    CSFolderObjectInfo fol_oi = null;
List folders = getFolderList(tm, tree);

for (int i=0; i<folders.size(); i++) {

String folderName = folders.get(i).toString();
System.out.println( " " + (i+1) + ": " + folderName );

fol_oi = (CSFolderObjectInfo)ObjectInfo.createByKey( ObjectInfo.tFolder, folderName );

System.out.println( " " + "Release Scheme: " + fol_oi.getReleaseScheme() );
System.out.println( " " + "File Space: " + fol_oi.getFilespace() );

System.out.println( " " + "Release Levels: ");
String[] fol_rellevels = fol_oi.getReleaseLevel();

// release level array values start at 1, but still has element zero
for (int j=1; j<fol_rellevels.length; j++) {
System.out.println( " " + " " + j + ": " + fol_rellevels[j] );
}

fol_oi = null;

System.out.println(); // blank line for readability
System.out.flush(); // flush to see data in output file immediately
}
 


In the next installment, I'll show yet more information about folders that can be gathered, including folder and role based authorizations.

No comments: