Acs is enabled or not(test code)
/********************************************************************* *
- TestACS - verifies ACS functionality
Checks acs server map, dm_acs_configThen executes a real world test of the ACS server*
- author: fabian.lee * * *
- Example compilation in windows
javac -classpath "c:\progra~1\documentum\shared\dfc.jar;c:\documentum\config;." TestACS.java* *
- Example of usage in windows
java -classpath "c:\progra~1\documentum\shared\dfc.jar;c:\documentum\config;." TestACS mydocbase dmadmin dmpass "/Temp/fabtest.txt"* * **************************************************************/ import com.documentum.fc.client.; import com.documentum.fc.common.; import com.documentum.com.; import com.documentum.operations.; import com.documentum.fc.client.acs.; import java.net.; import java.io.;
public class TestACS {
public static void main(String args[]) throws Exception { TestACS test = new TestACS("aix17","fangh","fangh","/方慧_fangh/33"); } public TestACS(String docbase,String user,String pass,String objectPath) throws Exception { //************************************************************** // Establish session //************************************************************** IDfClientX clientx = new DfClientX(); IDfClient client = clientx.getLocalClient(); // get session IDfLoginInfo loginInfo = clientx.getLoginInfo(); loginInfo.setUser(user); loginInfo.setPassword(pass); IDfSessionManager sMgr = client.newSessionManager(); sMgr.setIdentity(docbase,loginInfo); IDfSession session = sMgr.getSession(docbase); //************************************************************** // Pull info from acs server map, checks known status //************************************************************** IDfDocbrokerClient dbclient = clientx.getDocbrokerClient(); IDfTypedObject acsmap = dbclient.getAcsServerMap(session.getDocbaseName()); System.out.println("ACS server/status=" + acsmap.getValue("r_host_name") + "/" + acsmap.getValue("r_last_status")); for (int i = 0; i < acsmap.getAttrCount(); i++) { IDfAttr attr = acsmap.getAttr(i); System.out.println("\t" + attr.getName() + "=" + acsmap.getValueAt(i).toString()); } //************************************************************** // Pull base url from dm_acs_config, checks base url for validity //************************************************************** IDfCollection coll = null; IDfQuery query = clientx.getQuery(); query.setDQL("select r_object_id,acs_base_url from dm_acs_config"); coll = query.execute(session,IDfQuery.DF_READ_QUERY); while(coll.next()) { String baseURL = coll.getString("acs_base_url"); System.out.println("acs_base_url=" + baseURL); // now pull this URL and see if we get back a valid response if(baseURL!=null && baseURL.length()>0) { URL url = new URL(baseURL); URLConnection conn = url.openConnection(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; while ((line = rd.readLine()) != null) { System.out.println("ACS returned: " + line); if("ACS Server is running".equals(line)) { System.out.println("SUCCESS connecting to acs server at " + baseURL); }else { System.out.println("ERROR with response coming from " + baseURL); } } rd.close(); }else { System.out.println("PROBLEM: there was a problem with the acs_base_url on " + coll.getString("r_object_id")); } } //************************************************************** // now get object we will test ACS with //************************************************************** IDfSysObject docObj = (IDfSysObject) session.getObjectByPath(objectPath); if(docObj==null) throw new DfException("could not find object by path: " + objectPath); //************************************************************** // Export using ACS URL //************************************************************** IDfAcsTransferPreferences atp = clientx.getAcsTransferPreferences(); atp.preferAcsTransfer(true); IDfExportOperation exportOp = clientx.getExportOperation(); // setting ACS preferences to true in export operation // means that it won't be exported to the local file system // and intstead will return ACS URL for download exportOp.setAcsTransferPreferences(atp); IDfExportNode exportNode = (IDfExportNode) exportOp.add(docObj); boolean result = exportOp.execute(); if (result) { IDfList nodes = exportOp.getNodes(); for (int i = 0, size = nodes.getCount(); i < size; i++) { IDfExportNode node = (IDfExportNode) nodes.get(i); IDfEnumeration acsRequests = node.getAcsRequests(); //这里很奇怪,每次都是false while (acsRequests.hasMoreElements()) { IDfAcsRequest acsRequest = (IDfAcsRequest) acsRequests .nextElement(); // get ACS URL String docURL = acsRequest.makeURL(); System.out.println("docURL= " + docURL + "\r\n"); //************************************************************** // Now try pulling real content from ACS server //************************************************************** URL url = new URL(docURL); URLConnection conn = url.openConnection(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = null; while ((line = rd.readLine()) != null) { System.out.println(line); } rd.close(); } // each acs request } // each node } // successful execution // release session sMgr.release(session); }}