Friday, 26 May 2017

FileNet P8 domain

FileNet P8 domain

A logical grouping of physical resources.
  • Content Engine servers
  • Sites
  • Object stores
  • Index areas
  • Storage areas
  • Content cache areas
  • Other elements
  • Global Configuration Database (GCD)
  • Holds the information defining the FileNet P8 domain.

The FileNet P8 domain is initially created when the FileNet P8 system is installed. After that, you can add new servers to the existing domain.

The Global Configuration Database (GCD) stores hierarchical configuration data related to the FileNet P8 domain. Only one GCD is available for each FileNet P8 domain. Data stored in the GCD includes the domain configuration (sites, virtual servers, and server instances), marking sets, object store definitions, add-ons, fixed content devices, and any other data that must be shared between all object store services in a FileNet P8 domain. The GCD is a proprietary format database, and contains a security descriptor which controls access to specific GCD objects.

Enterprise Manager is the FileNet P8 administrator interface to the GCD and its configuration data about the FileNet P8 domain. Enterprise Manager displays the domain hierarchy, object stores, and associated file and content cache stores for a single FileNet P8 domain, based on the information it finds in the GCD. The GCD needs to be backed up regularly. If the database server hosting the GCD database is unavailable, the system administrator cannot reach the FileNet P8 domain.

Stop and Start sequence of FileNet 5.1 system components (Same sequence for FileNet 5.0 also)

Start sequence

  1. Directory service (Ex: AD, TDS... )
  2. RDBMS (Ex: DB2, SQL,Oracle....)
  3. Machine for the Web application server hosting the Content Engine (Windows, UNIX, or Linux)
  4. Java EE application server hosting the Content Engine (IBM WebSphere, )
  5. Content Engine (FileNetEngine application, which can be set to start automatically)
  6. Machine for the Process Engine
  7. Process Engine server in Process Task Manager on Windows or UNIX, or if the Process Engine runs on a Windows machine, IMS ControlService and Process Engine Services Manager
  8. Machine for the Java EE application server hosting the Application Engine (Windows, UNIX, or Linux)
  9. Java EE application server hosting Workplace, Workplace XT
  10. Workplace (FileNetWorkplace) or Workplace XT (WorkplaceXT) application or both (can be set to start automatically)
  11. Process AE Services Manager, Process WP XT Services Manager, or both started on a Windows host machine for the user interface
  12. Component Managers on the host machine for the Application Engine or Workplace XT if a supported business solution uses a component.
  13. FileNet add-on products, such as Records Manager, Email Manager, or eForms Manager.

Stop Sequence

  1. Stop any FileNet add-on products first, such as Records Manager.
  2. Stop the Component Manager on the host server.
  3. Use WAS to stop the application WorkplaceXT.
  4. Stop the Process Engine with Process Task Manager.
  5. Use WAS to stop the application FileNetEngine(Content Engine).
  6. The directory service and RDBMS are stopped by their respective administrators if necessary.

Sample JAVA code to retrieve Realm, Group names and User names in FileNet (FileNet Content Engine API)

//Sample JAVA code to retrieve Realm, Group names and User names in FileNet

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.GroupSet;
import com.filenet.api.collection.UserSet;
import com.filenet.api.constants.PrincipalSearchAttribute;
import com.filenet.api.constants.PrincipalSearchSortType;
import com.filenet.api.constants.PrincipalSearchType;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Factory;
import com.filenet.api.util.UserContext;
public class CEUtil {
    private static Connection conn = null;

    public static Connection getCEConn()
    {
        try {
            String ceURI =    "http://localhost:9080/wsi/FNCEWS40MTOM/";
            String userName ="user";
            String password ="pwd";
            if(conn==null){
            conn = Factory.Connection.getConnection(ceURI);
            Subject subject = UserContext.createSubject(conn, userName, password, null);
            UserContext uc = UserContext.get();
            uc.pushSubject(subject);
            }

        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        System.out.println("CE Connection"+conn);
        return conn;
    }
    public static void getRealm(String osName) throws IOException{
       
        try{
            Connection conn = getCEConn();
            com.filenet.api.core.EntireNetwork entireNetwork= Factory.EntireNetwork.fetchInstance(conn, null);
            com.filenet.api.security.Realm realm= entireNetwork.get_MyRealm();String realmName= realm.get_Name();
            System.out.println(realmName+ " is retrieved");
           
            //retrieve user names
            String pattern ="username";
            UserSet users = realm.findUsers(pattern, PrincipalSearchType.PREFIX_MATCH,PrincipalSearchAttribute.SHORT_NAME,PrincipalSearchSortType.NONE,Integer.valueOf("50"), null);
            com.filenet.api.security.User user;
            Iterator it = users.iterator();
            while (it.hasNext())
            {
            user = (com.filenet.api.security.User)it.next();
            System.out.println("distinguishedname =" +user.get_DistinguishedName());
            System.out.println("shortname =" + user.get_ShortName());
            System.out.println("name=" + user.get_Name());
            System.out.println("displayname =" + user.get_DisplayName());
            }
           
            //retrieve group names
            String pattern1="groupName";
            GroupSet groups = realm.findGroups(pattern1,PrincipalSearchType.PREFIX_MATCH,PrincipalSearchAttribute.SHORT_NAME,PrincipalSearchSortType.NONE,Integer.valueOf("50"), null);
            com.filenet.api.security.Group group;
            Iterator groupIt= groups.iterator();
            while (groupIt.hasNext())
            {
            group=(com.filenet.api.security.Group)groupIt.next();
            System.out.println("name=" + group.get_Name());
            System.out.println("Distinguishedname = " + group.get_DistinguishedName());
            System.out.println("shortname =" + group.get_ShortName());
            //System.out.println("Users =" + group.get_Users());
            }
           
            System.out.println("Done");


        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main(String[] args) throws IOException {
        getRealm("OSNAME");
    }
}

Sample Java code to set folder permissions (FileNet Content Engine API)

//Sample code to set folder permissions

import java.io.IOException;
import java.util.Iterator;

import javax.security.auth.Subject;

import com.filenet.api.collection.AccessPermissionList;
import com.filenet.api.collection.FolderSet;
import com.filenet.api.constants.AccessLevel;
import com.filenet.api.constants.AccessType;
import com.filenet.api.constants.RefreshMode;
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.security.AccessPermission;
import com.filenet.api.util.UserContext;
public class CEUtil {
    private static Connection conn = null;

    public static Connection getCEConn()
    {
        try {
            String ceURI =    "http://localhost:9080/wsi/FNCEWS40MTOM/";
            String userName ="username";
            String password ="pwd";
            if(conn==null){
            conn = Factory.Connection.getConnection(ceURI);
            Subject subject = UserContext.createSubject(conn, userName, password, null);
            UserContext uc = UserContext.get();
            uc.pushSubject(subject);
            }

        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        System.out.println("CE Connection"+conn);
        return conn;
    }
    public static void setPermissions(String osName) throws IOException{
       
        try{
            Connection conn = getCEConn();
            Domain domain = Factory.Domain.fetchInstance(conn,null, null);
            ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
            String folder= "/Test";
           
            com.filenet.api.core.Folder folderOj= Factory.Folder.fetchInstance(objStore,folder, null);
            System.out.println("Folder :: "+folderOj.get_Name());
   
            AccessPermission permission = Factory.AccessPermission.createInstance();
            permission.set_GranteeName("User");
            permission.set_AccessType(AccessType.ALLOW);
            permission.set_InheritableDepth(new Integer(-1));
            permission.set_AccessMask(new Integer(AccessLevel.FULL_CONTROL_FOLDER_AS_INT));
           
            AccessPermissionList permissions = folderOj.get_Permissions();
            permissions.add(permission);
            folderOj.set_Permissions(permissions);
            folderOj.save(RefreshMode.REFRESH);   
            System.out.println("Done");
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main(String[] args) throws IOException {
        setPermissions("OSNAME");
    }
}

Sample code to get object permissions (FileNet Content Engine API)

//Sample code to get object permissions

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.AccessPermissionList;
import com.filenet.api.collection.IndependentObjectSet;
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.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.security.AccessPermission;
import com.filenet.api.util.UserContext;
public class CEUtil {
    private static Connection conn = null;

    public static Connection getCEConn()
    {
        try {
            String ceURI =    "http://localhost:9080/wsi/FNCEWS40MTOM/";
            String userName ="username";
            String password ="pwd";
            if(conn==null){
            conn = Factory.Connection.getConnection(ceURI);
            Subject subject = UserContext.createSubject(conn, userName, password, null);
            UserContext uc = UserContext.get();
            uc.pushSubject(subject);
            }

        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        System.out.println("CE Connection"+conn);
        return conn;
    }
    public static void getObjectPermissions(String osName) throws IOException{
       
        try{
            Connection conn = getCEConn();
            Domain domain = Factory.Domain.fetchInstance(conn,null, null);
            ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
            SearchScope searchScope = new SearchScope(objStore);
            int count=0;
            String sqlStr = "Select * FROM docClass where DocumentTitle='doc123.pdf'";
            SearchSQL searchSQL = new SearchSQL(sqlStr);
            System.out.println("Query ::"+sqlStr);
            IndependentObjectSet independentObjectSet = searchScope.fetchObjects(searchSQL, new Integer(10), null, new Boolean(true));
            if(!(independentObjectSet.isEmpty())){
                Iterator it=independentObjectSet.iterator();
               
                while(it.hasNext())    {
                    Document document=(Document)it.next();
                    AccessPermissionList permissions= document.get_Permissions();
                    Iterator it1 = permissions.iterator();
                    while (it1.hasNext())
                    {
                    AccessPermission permission = (AccessPermission)it1.next();
                    System.out.println("GranteeName="+ permission.get_GranteeName());
                    System.out.println("GranteeType=" + permission.get_GranteeType().toString());
                    System.out.println("PermissionSource=" +permission.get_PermissionSource().toString());
                    //System.out.println("Accesslevel = " + AccessLevel.getInstanceFromInt(permission.get_AccessMask().intValue()).toString());
                    System.out.println("Accesstype =" +permission.get_AccessType().toString());
                    System.out.println("Inheritabledepth=" +permission.get_InheritableDepth());
                    }
                count++;
                System.out.println("Count:::"+count);
                }
             System.out.println("Count:::;"+count);
             System.out.println("Done");
                }

        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
    public static void main(String[] args) throws IOException {
        getObjectPermissions("OSNAME");
    }
}

Tuesday, 8 November 2016

Java code to demote a version for a document (FileNet Content Engine API)

//Java code to demote a version for a document (FileNet Content Engine API)

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.IndependentObjectSet;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.constants.VersionStatus;
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.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class CEUtil {
private static Connection conn = null;

public static Connection getCEConnection()
{
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName ="username";
String password ="pwd";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}
public static void demoteVersionDocument(String osName) throws IOException{

try{
Connection conn = getCEConnection();
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
SearchScope searchScope = new SearchScope(objStore);
int count=0;
String sqlStr = "Select * FROM docClass where DocumentTitle='doc123.pdf'";
SearchSQL searchSQL = new SearchSQL(sqlStr);
System.out.println("Query ::"+sqlStr);
IndependentObjectSet independentObjectSet = searchScope.fetchObjects(searchSQL, new Integer(10), null, new Boolean(true)); 
if(!(independentObjectSet.isEmpty())){
Iterator it=independentObjectSet.iterator();

while(it.hasNext()) {
Document document=(Document)it.next();
if (document.get_IsCurrentVersion().booleanValue()== false) 
document = (Document)document.get_CurrentVersion();
if ((document.get_VersionStatus().getValue() == VersionStatus.RELEASED_AS_INT) && (document.get_IsReserved().booleanValue() == false))
{
document.demoteVersion();
document.save(RefreshMode.REFRESH);
}
count++;
   System.out.println("Count:::"+count);
}
System.out.println("Count:::;"+count);
System.out.println("Done");
}

}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
demoteVersionDocument("OSNAME");
}
}

Java code to promote a version for a document (FileNet Content Engine API)

//Java code to promote a version for a document (FileNet Content Engine API)

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.IndependentObjectSet;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.constants.VersionStatus;
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.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class CEUtil {
private static Connection conn = null;

public static Connection getCEConnection()
{
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName ="username";
String password ="pwd";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}
public static void promoteVersionDocument(String osName) throws IOException{

try{
Connection conn = getCEConnection();
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
SearchScope searchScope = new SearchScope(objStore);
int count=0;
String sqlStr = "Select * FROM docClass where DocumentTitle='doc123.pdf'";
SearchSQL searchSQL = new SearchSQL(sqlStr);
System.out.println("Query ::"+sqlStr);
IndependentObjectSet independentObjectSet = searchScope.fetchObjects(searchSQL, new Integer(10), null, new Boolean(true)); 
if(!(independentObjectSet.isEmpty())){
Iterator it=independentObjectSet.iterator();

while(it.hasNext()) {
Document document=(Document)it.next();
if (document.get_IsCurrentVersion().booleanValue() == false)
document=(Document)document.get_CurrentVersion();
if ((document.get_VersionStatus().getValue() == VersionStatus.IN_PROCESS_AS_INT) &&(document.get_IsReserved().booleanValue() == false))
{
document.promoteVersion();
document.save(RefreshMode.NO_REFRESH);
}

count++;
   System.out.println("Count:::"+count);
}
System.out.println("Count:::;"+count);
System.out.println("Done");
}

}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
promoteVersionDocument("OSNAME");
}
}

Java code to Check IN a CE document (FileNet Content Engine API)

//Java code to Check IN a CE document (FileNet Content Engine API)

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ContentElementList;
import com.filenet.api.collection.IndependentObjectSet;
import com.filenet.api.constants.AutoClassify;
import com.filenet.api.constants.CheckinType;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.constants.VersionStatus;
import com.filenet.api.core.Connection;
import com.filenet.api.core.ContentTransfer;
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.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class CEUtil {
private static Connection conn = null;

public static Connection getCEConnection()
{
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName ="username";
String password ="pwd";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}
public static void checkInDocument(String osName) throws IOException{

try{
Connection conn = getCEConnection();
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
SearchScope searchScope = new SearchScope(objStore);
int count=0;
String sqlStr = "Select * FROM docClass where DocumentTitle='doc123.pdf'";
SearchSQL searchSQL = new SearchSQL(sqlStr);
System.out.println("Query ::"+sqlStr);
IndependentObjectSet independentObjectSet = searchScope.fetchObjects(searchSQL, new Integer(10), null, new Boolean(true)); 
if(!(independentObjectSet.isEmpty())){
Iterator it=independentObjectSet.iterator();

while(it.hasNext()) {
Document doc=(Document)it.next();

//Check the version
if(doc.get_IsCurrentVersion().booleanValue()== false)
{
doc= (Document) doc.get_CurrentVersion();
}
if (doc.get_IsReserved().booleanValue()== true)
{
if (doc.get_VersionStatus().getValue() !=VersionStatus.RESERVATION_AS_INT)
{
Document reservationDoc= (Document) doc.get_Reservation();
}

//Check in Document
ContentElementList contentList= Factory.ContentElement.createList();
ContentTransfer content1 = Factory.ContentTransfer.createInstance();
content1.setCaptureSource(new FileInputStream("C:/Users/Public/Pictures/Sample Pictures/Desert.jpg")); 
content1.set_ContentType("image/jpeg");
contentList.add(content1);
doc.set_ContentElements(contentList);
doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MINOR_VERSION); 
doc.save(RefreshMode.REFRESH);
}

count++;
   System.out.println("Count:::"+count);
}
System.out.println("Count:::;"+count);
System.out.println("Done");
}

}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
checkInDocument("OSNAME");
}
}


Java code to Cancel Check-out a CE document (FileNet Content Engine API)

//Java code to Cancel check-out a CE document (FileNet Content Engine API)

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.IndependentObjectSet;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.constants.ReservationType;
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.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class CEUtil {
private static Connection conn = null;

public static Connection getCEConnection()
{
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName ="ceusr";
String password ="pwd";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}
public static void cancelCheckOutDocument(String osName) throws IOException{

try{
Connection conn = getCEConnection();
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
SearchScope searchScope = new SearchScope(objStore);
int count=0;
String sqlStr = "Select * FROM docClass where DocumentTitle='doc123.pdf4'";
SearchSQL searchSQL = new SearchSQL(sqlStr);
System.out.println("Query ::"+sqlStr);
IndependentObjectSet independentObjectSet = searchScope.fetchObjects(searchSQL, new Integer(10), null, new Boolean(true)); 
if(!(independentObjectSet.isEmpty())){
Iterator it=independentObjectSet.iterator();

while(it.hasNext()) {
Document doc=(Document)it.next();

if(doc.get_IsCurrentVersion().booleanValue()== false)
{
doc=(Document)doc.get_CurrentVersion();
}
if (doc.get_IsReserved().booleanValue()== true)
{
Document reservationdoc= (Document)doc.cancelCheckout();
reservationdoc.save(RefreshMode.REFRESH);
}
count++;
   System.out.println("Count:::"+count);
}
System.out.println("Count:::;"+count);
System.out.println("Done");
}

}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
cancelCheckOutDocument("OSNAME"); //Object Store
}
}


Sample code to check out a document (Filenet Content Engine API)

//Sample code to check out a document (Filenet Content Engine API)

import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.IndependentObjectSet;
import com.filenet.api.constants.RefreshMode;
import com.filenet.api.constants.ReservationType;
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.query.SearchSQL;
import com.filenet.api.query.SearchScope;
import com.filenet.api.util.UserContext;
public class CEUtil {
private static Connection conn = null;
public static Connection getCEConnection()
{
try {
String ceURI = "http://localhost:9080/wsi/FNCEWS40MTOM/";
String userName ="ceusr";
String password ="pwd";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}
public static void checkOut(String osName) throws IOException{

try{
Connection conn = getCEConnection();
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
ObjectStore objStore = Factory.ObjectStore.fetchInstance(domain, osName,null);
SearchScope searchScope = new SearchScope(objStore);
int count=0;
String sqlStr = "Select * FROM docTitle where DocumentTitle='doc123.pdf'";
SearchSQL searchSQL = new SearchSQL(sqlStr);
System.out.println("Query ::"+sqlStr);
IndependentObjectSet independentObjectSet = searchScope.fetchObjects(searchSQL, new Integer(10), null, new Boolean(true)); 
if(!(independentObjectSet.isEmpty())){
Iterator it=independentObjectSet.iterator();

while(it.hasNext()) {
Document doc=(Document)it.next();
//Check out the document
if (doc.get_IsCurrentVersion().booleanValue()== false) 
doc =(Document)doc.get_CurrentVersion();
if (doc.get_IsReserved().booleanValue() == false) 
{
doc.checkout(ReservationType.EXCLUSIVE,null, null, null);
doc.save(RefreshMode.REFRESH);
}
count++;
   System.out.println("Count:::"+count);
}
System.out.println("Count:::;"+count);
System.out.println("Done");
}

}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
checkOut("OSNAME"); //Object store
}
}