Filenet storing and getting objects from store - Java Step Processor

1k views Asked by At

I'm implementing Filenet Java Step Processor. I have to get a document from object store, moddify and store modified version to the same object store. I have a working applet for tests. I can't ask user for additional sending login and password, I have to work with VWSession object. Document which I have to get is send as step attachment. I know how to get attached document ID. How to get document by ID from Java Step Processor using VWSession object as my connection point to Object Store?

2

There are 2 answers

0
Robert vd S On

Getting the user credentials is not that difficult. In the stepprocessor java module just dop the following:

String userName = controller.getDataStore().getServerCredentials().getUserId();
String userPwd = controller.getDataStore().getServerCredentials().getPassword();

For getting the document you mean, normally you will not get that over a VWConnection but over a Content engine connection.

getting your document via ID:

Factory.Document.fetchInstance(objectStore, guid, null);

Hope it helps

0
WiredCoder On

Get an ObjectStore instance (Get the domainId from the VWSession, and construct the domain using the Connection from VWSession also) and pass the Attachment to the method below:

private String getIdFromAttachment(VWAttachment att, ObjectStore os) {
    if (att.getLibraryType() != 3) {
        String libtype = String.valueOf(att.getLibraryType());
        throw new VWException("hk.ibm.ecm.cpa.uwfcustomcomponent.InvalidLibraryType",
                "Cannot convert object from non-CE repository, type {0}.", libtype);
    }

    String attId = att.getId();
    switch (att.getType()) {
    case 3:
    case 4:
        VersionSeries vs = (VersionSeries) os.getObject("VersionSeries", attId);
        vs.refresh();
        String ver = att.getVersion();
        return getIdBasedOnVersion(vs, ver);
    default:
        return attId;
    }
}

private String getIdBasedOnVersion(VersionSeries vs, String ver) {
    if (ver == null) {
        Document current = (Document) vs.get_CurrentVersion();
        current.refresh();
        return current.get_Id().toString();
    } else if ("-1".equals(ver)) {
        Document released = (Document) vs.get_ReleasedVersion();
        released.refresh();
        return released.get_Id().toString();
    } else {
        return ver;
    }
}