EngineConnection.java
---------------------------------
import com.filenet.api.core.*;
import com.filenet.api.util.UserContext;
import javax.security.auth.Subject;
public class EngineConnection {
Connection giveConnection()
{
String url="http://192.168.2.22:9080/wsi/FNCEWS40MTOM";
Connection connection = Factory.Connection.getConnection(url);
Subject subject =UserContext.createSubject(connection, "p8admin", "ecm@dmin1", null);
UserContext context=UserContext.get();
context.pushSubject(subject);
if(connection!=null)
return connection;
return connection;
}
}
BulkDownloading.java
---------------------------------
import com.filenet.api.collection.ContentElementList;
import com.filenet.api.collection.DocumentSet;
import com.filenet.api.core.*;
import com.filenet.api.util.Id;
import java.util.Iterator;
import java.io.*;
public class BulkDownloading {
public static void main(String []args)
{
EngineConnection mine=new EngineConnection();
Connection connection= mine.giveConnection();
if(connection !=null)
{
Domain domain=Factory.Domain.fetchInstance(connection, null, null);
ObjectStore object_store=Factory.ObjectStore.fetchInstance(domain, "CMTOS", null);
System.out.println(""+object_store.get_DisplayName());
Folder folder=Factory.Folder.fetchInstance(object_store, "/Practise Folder/Practise Sub Folder", null);
System.out.println(""+folder.get_FolderName());
//get all documents from this folder now
DocumentSet document_set=folder.get_ContainedDocuments();
Document current_document=null;
FileOutputStream output_data=null;
InputStream input_data=null;
Document working_document=null;
ContentElementList content_element_list=null;
Iterator<DocumentSet>doc_iterator= document_set.iterator();
while(doc_iterator.hasNext())
{
current_document=(Document)doc_iterator.next();
//System.out.println(""+current_document.get_Name()+current_document.get_MimeType());
String mime=current_document.get_MimeType();
if(mime.startsWith("applica"))
{
mime="pdf";
}
try
{
output_data = new FileOutputStream("d:\\sample\\"+current_document.get_Name()+"."+mime);
working_document=Factory.Document.fetchInstance(object_store,current_document.get_Id(), null);
content_element_list=working_document.get_ContentElements();
//iterate through these
Iterator ite=content_element_list.iterator();
while(ite.hasNext())
{
ContentTransfer ct=(ContentTransfer)ite.next();
input_data=ct.accessContentStream();
int data_length=ct.get_ContentSize().intValue();
byte buff[]=new byte[data_length];
try
{
input_data.read(buff);
output_data.write(buff);
}
catch(Exception e)
{
System.out.println(""+e.getLocalizedMessage());
}
}
}
catch(Exception e)
{
System.out.println(""+e.getLocalizedMessage());
}
}
System.out.println("Operation completed");
}
}
}
---------------------------------
import com.filenet.api.core.*;
import com.filenet.api.util.UserContext;
import javax.security.auth.Subject;
public class EngineConnection {
Connection giveConnection()
{
String url="http://192.168.2.22:9080/wsi/FNCEWS40MTOM";
Connection connection = Factory.Connection.getConnection(url);
Subject subject =UserContext.createSubject(connection, "p8admin", "ecm@dmin1", null);
UserContext context=UserContext.get();
context.pushSubject(subject);
if(connection!=null)
return connection;
return connection;
}
}
BulkDownloading.java
---------------------------------
import com.filenet.api.collection.ContentElementList;
import com.filenet.api.collection.DocumentSet;
import com.filenet.api.core.*;
import com.filenet.api.util.Id;
import java.util.Iterator;
import java.io.*;
public class BulkDownloading {
public static void main(String []args)
{
EngineConnection mine=new EngineConnection();
Connection connection= mine.giveConnection();
if(connection !=null)
{
Domain domain=Factory.Domain.fetchInstance(connection, null, null);
ObjectStore object_store=Factory.ObjectStore.fetchInstance(domain, "CMTOS", null);
System.out.println(""+object_store.get_DisplayName());
Folder folder=Factory.Folder.fetchInstance(object_store, "/Practise Folder/Practise Sub Folder", null);
System.out.println(""+folder.get_FolderName());
//get all documents from this folder now
DocumentSet document_set=folder.get_ContainedDocuments();
Document current_document=null;
FileOutputStream output_data=null;
InputStream input_data=null;
Document working_document=null;
ContentElementList content_element_list=null;
Iterator<DocumentSet>doc_iterator= document_set.iterator();
while(doc_iterator.hasNext())
{
current_document=(Document)doc_iterator.next();
//System.out.println(""+current_document.get_Name()+current_document.get_MimeType());
String mime=current_document.get_MimeType();
if(mime.startsWith("applica"))
{
mime="pdf";
}
try
{
output_data = new FileOutputStream("d:\\sample\\"+current_document.get_Name()+"."+mime);
working_document=Factory.Document.fetchInstance(object_store,current_document.get_Id(), null);
content_element_list=working_document.get_ContentElements();
//iterate through these
Iterator ite=content_element_list.iterator();
while(ite.hasNext())
{
ContentTransfer ct=(ContentTransfer)ite.next();
input_data=ct.accessContentStream();
int data_length=ct.get_ContentSize().intValue();
byte buff[]=new byte[data_length];
try
{
input_data.read(buff);
output_data.write(buff);
}
catch(Exception e)
{
System.out.println(""+e.getLocalizedMessage());
}
}
}
catch(Exception e)
{
System.out.println(""+e.getLocalizedMessage());
}
}
System.out.println("Operation completed");
}
}
}
Không có nhận xét nào:
Đăng nhận xét