Invoking UCF in custom import component

1)I have made some changes in the component defination. This instantiated ucf session when component is initialized.
<ucfrequired>
<events>
<!-- only one supported right now -->
<event name="onInit" enabled="true"/>
</events>
<pages>
<!-- all pages are enabled by default -->
<page name="start" enabled="true"></page>
<page name="invokeucf" enabled="true"></page>
</pages>
</ucfrequired>

 


2) Following code can be used to utilize ucf session

UcfTransportManager transportManager = UcfTransportManager.getManager();

System.out.println("is UCF required"+transportManager.isUcfRequired(this));
if ( transportManager == null ) {
System.out.println("ucfSessionManager is null ");
}
UcfSessionManager ucfSessionManager = transportManager.getSessionManager();

if ( ucfSessionManager == null ) {
}

System.out.println("Is sesssion available"+ ucfSessionManager.isSessionAvailable());
IServerSession serverSession = ucfSessionManager.getSession();

if ( serverSession == null ) {
System.out.println("serverSession is null ");
}

IRequestFactory reqFactory = serverSession.getRequestFactory();

IGetFileRequest request = reqFactory.newGetFileRequest(files[0].getPath());


serverSession.addRequest(request);


IRequestResponseIterator reqRespIter = serverSession.execute();

File file = serverSession.getTempWorkingDir();
if (file != null){
System.out.println(" FIlepath "+ file.getPath());
System.out.println(" getName "+ file.getName());
}

for (;reqRespIter.hasNext();){
IRequestResponsePair pair = reqRespIter.next();
IGetFileRequest request1 = (IGetFileRequest)pair.getRequest();
IServerResponse response = pair.getResponse();
response.getAttachmentAsFile(file.getPath()+"\\"+files[0].getName());
}



ucfSessionManager.release(serverSession);

}
catch(Exception e){
System.out.println("Error in ucf "+e);
}

你可能感兴趣的:(webtop,documentum,ucf)