How to Create a Document in IBM FileNet Content Engine

import java.util.Date;

import javax.security.auth.Subject;

import com.filenet.api.constants.AutoClassify;
import com.filenet.api.constants.CheckinType;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Document;
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 Document doc = Factory.Document.createInstance(os, "Sample");

    doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);

    doc.save(RefreshMode.NO_REFRESH);

    uc.popSubject();
  }

}

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