Add log for debugger
[holmes/rule-management.git] / rulemgt / src / main / java / org / openo / holmes / rulemgt / bolt / enginebolt / EngineWrapper.java
index beecdd3..c351bbb 100644 (file)
  */\r
 package org.openo.holmes.rulemgt.bolt.enginebolt;\r
 \r
+import java.io.IOException;\r
 import javax.inject.Inject;\r
 import lombok.extern.slf4j.Slf4j;\r
 import net.sf.json.JSONObject;\r
 import org.apache.http.HttpResponse;\r
+import org.apache.http.util.EntityUtils;\r
 import org.jvnet.hk2.annotations.Service;\r
 import org.openo.holmes.common.exception.CorrelationException;\r
 import org.openo.holmes.common.utils.I18nProxy;\r
@@ -38,7 +40,7 @@ public class EngineWrapper {
         try {\r
             httpResponse = engineService.deploy(correlationRule);\r
         } catch (Exception e) {\r
-            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED,e);\r
+            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED, e);\r
         }\r
         if (httpResponse.getStatusLine().getStatusCode() == RuleMgtConstant.RESPONSE_STATUS_OK) {\r
             log.info("Call deploy rule rest interface in engine successfully.");\r
@@ -47,7 +49,7 @@ public class EngineWrapper {
                 JSONObject json = JSONObject.fromObject(content);\r
                 return json.get(RuleMgtConstant.PACKAGE).toString();\r
             } catch (Exception e) {\r
-                throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR,e);\r
+                throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR, e);\r
             }\r
         } else {\r
             throw new CorrelationException(I18nProxy.ENGINE_DEPLOY_RULE_FAILED);\r
@@ -59,7 +61,7 @@ public class EngineWrapper {
         try {\r
             httpResponse = engineService.delete(packageName);\r
         } catch (Exception e) {\r
-            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED,e);\r
+            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED, e);\r
         }\r
         if (httpResponse.getStatusLine().getStatusCode() == RuleMgtConstant.RESPONSE_STATUS_OK) {\r
             log.info("Call delete rule rest interface in engine successfully.");\r
@@ -75,13 +77,19 @@ public class EngineWrapper {
         try {\r
             httpResponse = engineService.check(correlationCheckRule4Engine);\r
         } catch (Exception e) {\r
-            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED,e);\r
+            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED, e);\r
         }\r
         if (httpResponse.getStatusLine().getStatusCode() == RuleMgtConstant.RESPONSE_STATUS_OK) {\r
             log.info("Call check rule rest interface in engine successfully.");\r
             return true;\r
         } else {\r
-            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CHECK_NO_PASS);\r
+            try {\r
+                log.info(httpResponse.getStatusLine().getStatusCode() + "," + EntityUtils\r
+                        .toString(httpResponse.getEntity()));\r
+                throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CHECK_NO_PASS);\r
+            } catch (IOException e) {\r
+                throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CHECK_NO_PASS);\r
+            }\r
         }\r
     }\r
 }\r