123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- import com.cognos.developer.schemas.bibus._3.Account;
- import com.cognos.developer.schemas.bibus._3.BaseClass;
- import com.cognos.developer.schemas.bibus._3.PropEnum;
- import com.cognos.developer.schemas.bibus._3.QueryOptions;
- import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;
- import com.cognos.developer.schemas.bibus._3.Sort;
- public class CMTester
- {
-
- public String contentMgrTester(CRNConnect connection)
- {
- String output = new String();
- PropEnum props[] =
- new PropEnum[] {
- PropEnum.searchPath,
- PropEnum.defaultName,
- PropEnum.creationTime,
- PropEnum.version };
- if (connection.getCMService() == null)
- {
- System.out.println(
- "\n\nInvalid parameter passed to function contentMgrTester.");
- output =
- output.concat(
- "Invalid parameter passed to function contentMgrTester.");
- return output;
- }
- try
- {
- BaseClass bc[] =
- connection.getCMService().query(
- new SearchPathMultipleObject("~"),
- props,
- new Sort[] {},
- new QueryOptions());
- if (bc != null)
- {
- if (bc.length > 0)
- {
- for (int i = 0; i < bc.length; i++)
- {
- Account myAccount = (Account)bc[i];
- String sCD = new String();
-
- String crDatTim = new String();
- sCD = myAccount.getCreationTime().getValue().toString();
-
-
- String yrSrchStr = new String();
- yrSrchStr = ",YEAR=";
- String monSrchStr = new String();
- monSrchStr = ",MONTH=";
- String daySrchStr = new String();
- daySrchStr = ",DAY_OF_MONTH=";
- String hrSrchStr = new String();
- hrSrchStr = ",HOUR_OF_DAY=";
- String minSrchStr = new String();
- minSrchStr = ",MINUTE=";
- String secSrchStr = new String();
- secSrchStr = ",SECOND=";
-
-
- int yearPos = sCD.indexOf(yrSrchStr);
- int monthPos = sCD.indexOf(monSrchStr);
- int dayPos = sCD.indexOf(daySrchStr);
- int hourPos = sCD.indexOf(hrSrchStr);
- int minPos = sCD.indexOf(minSrchStr);
- int secPos = sCD.indexOf(secSrchStr);
- String chrsMonth = new String();
-
-
- String char1 =
- sCD.substring(monthPos + 8, monthPos + 9);
- if (char1.equals(","))
- {
- crDatTim =
- "The CreationTime is: 0"
- + sCD.substring(monthPos + 7, monthPos + 8)
- + "/";
- chrsMonth =
- sCD.substring(monthPos + 7, monthPos + 8);
- }
- else
- {
- crDatTim =
- "The CreationTime is: "
- + sCD.substring(monthPos + 7, monthPos + 9)
- + "/";
- chrsMonth =
- sCD.substring(monthPos + 7, monthPos + 9);
- }
-
-
- int intMonth;
- intMonth = Integer.parseInt(chrsMonth);
- intMonth = intMonth + 1;
- crDatTim =
- "The creation time is: "
- + Integer.toString(intMonth)
- + "/";
-
- String char2 = sCD.substring(dayPos + 15, dayPos + 16);
- if (char2.equals(","))
- {
- crDatTim =
- crDatTim
- + sCD.substring(dayPos + 14, dayPos + 15)
- + "/";
- }
- else
- {
- crDatTim =
- crDatTim
- + sCD.substring(dayPos + 14, dayPos + 16)
- + "/";
- }
-
- crDatTim =
- crDatTim
- + sCD.substring(yearPos + 6, yearPos + 10)
- + " ";
-
- String char3 =
- sCD.substring(hourPos + 14, hourPos + 15);
- if (char3.equals(","))
- {
- crDatTim =
- crDatTim
- + "0"
- + sCD.substring(hourPos + 13, hourPos + 14)
- + ":";
- }
- else
- {
- crDatTim =
- crDatTim
- + sCD.substring(hourPos + 13, hourPos + 15)
- + ":";
- }
-
- String char4 = sCD.substring(minPos + 9, minPos + 10);
- if (char4.equals(","))
- {
- crDatTim =
- crDatTim
- + "0"
- + sCD.substring(minPos + 8, minPos + 9)
- + ":";
- }
- else
- {
- crDatTim =
- crDatTim
- + sCD.substring(minPos + 8, minPos + 10)
- + ":";
- }
-
- String char5 = sCD.substring(secPos + 9, secPos + 10);
- if (char5.equals(","))
- {
- crDatTim =
- crDatTim
- + "0"
- + sCD.substring(secPos + 8, secPos + 9)
- + " \n";
- }
- else
- {
- crDatTim =
- crDatTim
- + sCD.substring(secPos + 8, secPos + 10)
- + " \n";
- }
- System.out.println(
- "The searchPath is: "
- + myAccount.getSearchPath().getValue());
- System.out.println(
- "\n\nThe DefaultName is: "
- + myAccount.getDefaultName().getValue());
- System.out.println(crDatTim);
- System.out.println(
- "The Version is: "
- + myAccount.getVersion().getValue());
- System.out.println(
- "\nContent Manager is responding and operational.");
- output =
- output.concat(
- "The searchPath is: "
- + myAccount.getSearchPath().getValue()
- + "\n");
- output =
- output.concat(
- "The DefaultName is: "
- + myAccount.getDefaultName().getValue()
- + "\n");
- output = output.concat(crDatTim);
- output =
- output.concat(
- "The Version is: "
- + myAccount.getVersion().getValue()
- + "\n\n");
- output =
- output.concat(
- "Content Manager is responding and operational.");
- }
- }
- }
- else
- {
- System.out.println("\n\nError occurred in contentMgrTester.");
- output = output.concat("Error occurred in contentMgrTester.");
- }
- }
- catch (java.rmi.RemoteException remoteEx)
- {
- output =
- output.concat(
- "CM Tester:"
- + "\nCannot connect to CM."
- + "\nEnsure that IBM Cognos is running.");
- output = output.concat("\n\n" + remoteEx.getMessage());
- }
- return output;
- }
- }
|