AEMManager.AemActions.GetCombinedBundleStatus C# (CSharp) Method

GetCombinedBundleStatus() public static method

public static GetCombinedBundleStatus ( AemInstance pInstance ) : BundleStatus
pInstance AemInstance
return BundleStatus
        public static BundleStatus GetCombinedBundleStatus(AemInstance pInstance)
        {
            if (pInstance == null) {
            return BundleStatus.NO_ACTIVE_INSTANCE;
              }

              // check if process is running
              if (!pInstance.RemoteProcess) {
            Process process = pInstance.GetInstanceJavaProcess();
            if (process == null || process.HasExited) {
              return BundleStatus.DISABLED;
            }
              }

              // get bundle status
              BundleStatus bundleStatus = BundleStatus.UNKNOWN;
              string bundleListUrl = pInstance.UrlWithContextPath + "/system/console/bundles/.json";
              Stopwatch responseTimeStopwatch = new Stopwatch();
              try {
            mLog.Debug("Get bundle list from URL: " + bundleListUrl);

            WebRequest request = pInstance.WebRequestCreate(bundleListUrl);
            request.Method = "GET";
            request.Timeout = AEMManager.Properties.Settings.Default.BundleListTimeout;

            responseTimeStopwatch.Start();
            using (WebResponse response = request.GetResponse()) {
              responseTimeStopwatch.Stop();

              String responseText;
              using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) {
            responseText = streamReader.ReadToEnd();
              }

              // parse JSON
              bool success = false;
              object value = JSON.JsonDecode(responseText, ref success);
              if (success) {
            bundleStatus = GetCombinedBundleStatus(value, responseTimeStopwatch.ElapsedMilliseconds);
              }
              else {
            mLog.Warn("Parsing JSON response failed: " + responseText);
              }
            }

              }
              catch (WebException ex) {
            if (ex.Status == WebExceptionStatus.Timeout) {
              mLog.Debug("Unable to connect to " + bundleListUrl + " due to timeout. "
            + "Configured timeout: " + AEMManager.Properties.Settings.Default.BundleListTimeout + "ms, "
            + "measured response time: " + responseTimeStopwatch.ElapsedMilliseconds + "ms");
            }
            else {
              mLog.Debug("Unable to connect to " + bundleListUrl + ": " + ex.Message);
              bundleStatus = BundleStatus.UNKNOWN;
            }
              }
              catch (Exception ex) {
            mLog.Error("Error getting bundle list from URL: " + bundleListUrl, ex);
            bundleStatus = BundleStatus.UNKNOWN;
              }

              return bundleStatus;
        }

Same methods

AemActions::GetCombinedBundleStatus ( object pJsonObject, long pRepsonseTime ) : BundleStatus

Usage Example

Example #1
0
 private void timerBundleStatus_Tick(object sender, EventArgs e)
 {
     foreach (AemInstance instance in Program.InstanceList)
     {
         if (instance.ShowInTaskbar)
         {
             instance.UpdateNofiyIconText(AemActions.GetCombinedBundleStatus(instance));
         }
     }
 }