javafilenet-p8filenet-content-engine

Searching for a folder in FileNet ContentEngine and retrieving its class


I had gotten the code to work to search for folders and retrieve properties. Ref: Search folder hierarchy in FileNet for a particular folder

I am trying to retrieve the class name of the folder object so as to differentiate between different types of docs that will get stored in custom folders.

I iterated thru the Properties collection, but the name of the class isn't a property.

String sqlStatement = "SELECT * FROM [Folder] WHERE ([FolderName] LIKE '%MyFolder%')";
SearchSQL sqlObject = new SearchSQL(sqlStatement);
RepositoryRowSet rowSet = searchScope.fetchRows(sqlObject, null, null, new Boolean(true));
Iterator iter = myRows.iterator();
while (iter.hasNext()) {
    RepositoryRow row = (RepositoryRow) iter.next();
    String folderID = row.getProperties().getIdValue("ID").toString();
}

I tried row.getClass() but that just returns: RepositoryRowImpl


Solution

  • If you use the * in your SELECT clause then the repository row object will contain all the properties of the object. This will also include a property called This. This property is a reference to the object that is returned. Therefore you can use the following code to fetch the class of the folder:

    EngineObject eo = row.getProperties().getEngineObjectValue("This");
    String className = eo.getClassName();
    

    Instead of the * you can also explicitly select This. In that case your query will be like this:

    String sqlStatement = "SELECT This,Id FROM [Folder] WHERE ([FolderName] LIKE '%MyFolder%')";
    

    This will limit the amount of data that is fetched from the server.