How to List Properties of a Document Class in IBM FileNet Content Engine

import java.util.Iterator;

import javax.security.auth.Subject;

import com.filenet.api.admin.ClassDefinition;
import com.filenet.api.admin.PropertyDefinition;
import com.filenet.api.collection.PropertyDefinitionList;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;

public final class FileNetSample {

  public static void main(final String[] args) throws Exception {
    final Connection conn = Factory.Connection.getConnection("http://localhost:9080/wsi/FNCEWS40MTOM"); // for the SOAP transport

    final UserContext uc = UserContext.get();

    final Subject subject = UserContext.createSubject(conn, "user", "password", null);

    uc.pushSubject(subject);

    final Domain domain = Factory.Domain.getInstance(conn, null);

    final ObjectStore os = Factory.ObjectStore.getInstance(domain, "Sample");

    final ClassDefinition cls = Factory.ClassDefinition.fetchInstance(os, args[0], null); // args[0] = class definition id

    final PropertyDefinitionList propLst = cls.get_PropertyDefinitions();

    final Iterator<?> propIter = propLst.iterator();

    while (propIter.hasNext()) {
      final PropertyDefinition prop = (PropertyDefinition) propIter.next();

      ...
    }

    uc.popSubject();
  }

}

2 thoughts on “How to List Properties of a Document Class in IBM FileNet Content Engine

  1. It’s a good idea to always balance UserContext.pushSubject() calls with matching popSubject() calls. You never know where a code fragment will get used, and the matching can be very important in web apps.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s