package com.xqsr.ARSystemInfo; import java.util.List; import com.bmc.arsys.api.ARException; import com.bmc.arsys.api.ARServerUser; import com.bmc.arsys.api.Entry; import com.bmc.arsys.api.QualifierInfo; public class ARSystemApplicationInfo { public static void main(String[] args) { // Initialize a new ARServerUser object, this is the main object we are // using for all actions ARServerUser context = new ARServerUser("Demo", "", "","192.168.184.128"); ARSystemApplicationInfo arSystemInfo = new ARSystemApplicationInfo(); arSystemInfo.getApplicationInfo(context); } public void getApplicationInfo(ARServerUser context){ try{ int[] fieldsFromShareApp = new int[2]; System.out.println(""); fieldsFromShareApp[0] = 400081800; // Property Value fieldsFromShareApp[1] = 400081600; // Application ID QualifierInfo qualSearch = context.parseQualification( "SHARE:Application_Properties", "'Property Name' = \"Name\""); List foundAppNames = context.getListEntryObjects( "SHARE:Application_Properties", qualSearch, 0, 0, null, fieldsFromShareApp, false, null); System.out.println(foundAppNames.size() + " Applications in SHARE:Application_Properties"); QualifierInfo qualSearchVersion = context.parseQualification( "SHARE:Application_Properties", "'Property Name' = \"Version\""); List foundAppVersions = context.getListEntryObjects( "SHARE:Application_Properties", qualSearchVersion, 0, 0, null, fieldsFromShareApp, false, null); // System.out.println(foundAppVersions.size()+ " Versions in SHARE:Application_Properties"); QualifierInfo qualSearchLanguagepacks = context.parseQualification( "SHARE:Application_Properties", "'Property Name' = \"Languagepacks\""); List foundAppLanguagepacks = context.getListEntryObjects( "SHARE:Application_Properties", qualSearchLanguagepacks, 0, 0, null, fieldsFromShareApp, false, null); // System.out.println(foundAppLanguagepacks.size() // + " Languagepacks in SHARE:Application_Properties"); QualifierInfo qualSearchPatch = context.parseQualification( "SHARE:Application_Properties", "'Property Name' = \"Patch\""); List foundAppPatches = context.getListEntryObjects( "SHARE:Application_Properties", qualSearchPatch, 0, 0, null, fieldsFromShareApp, false, null); //System.out.println(foundAppPatches.size() // + " Patches in SHARE:Application_Properties"); System.out.println(""); // this for loop extracts all the application names // we match them up with a version and patch by looping through the // patches for (int i = 0; i < foundAppNames.size(); i++) { Entry foundApp = foundAppNames.get(i); String appName = foundApp.get(400081800).toString(); String appID = foundApp.get(400081600).toString(); String appVersion = null; String appPatch = null; String appLanguagepack = null; // now find the versions for (int v = 0; v < foundAppVersions.size(); v++) { Entry foundAppVersion = foundAppVersions.get(v); String appIDVersion = foundAppVersion.get(400081600) .toString(); if (appIDVersion.equals(appID)) { appVersion = foundAppVersion.get(400081800).toString(); } }// end for loop versions // see if there is a patch installed for (int p = 0; p < foundAppPatches.size(); p++) { Entry foundAppPatch = foundAppPatches.get(p); String appIDPatch = foundAppPatch.get(400081600).toString(); if (appIDPatch.equals(appID)) { appPatch = foundAppPatch.get(400081800).toString(); } }// end for loop patches // Language packs installed for (int p = 0; p < foundAppLanguagepacks.size(); p++) { Entry foundAppLanguagepack = foundAppLanguagepacks.get(p); String appIDLanguagepack = foundAppLanguagepack.get( 400081600).toString(); if (appIDLanguagepack.equals(appID)) { appLanguagepack = foundAppLanguagepack.get(400081800) .toString(); } }// end for loop patches System.out.print(appName + " Version: " + appVersion); if (appPatch != null) { System.out.print(" Patch " + appPatch); } if (appLanguagepack != null) { System.out.print(" " + appLanguagepack); } System.out.println(); } // end for loop appNames } catch (ARException arException) { arException.printStackTrace(); } } }