Merge "Tried to Fix Some Vulnerability Issues"
[holmes/rule-management.git] / rulemgt / src / main / java / org / onap / holmes / rulemgt / resources / RuleMgtResources.java
index 041377f..445c2f9 100644 (file)
@@ -1,17 +1,15 @@
 /**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2020 ZTE Corporation.\r
  *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
  *\r
  * http://www.apache.org/licenses/LICENSE-2.0\r
  *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
  */\r
 package org.onap.holmes.rulemgt.resources;\r
 \r
@@ -20,21 +18,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;\r
 import io.swagger.annotations.ApiParam;\r
 import io.swagger.annotations.SwaggerDefinition;\r
-import java.util.Locale;\r
-import javax.inject.Inject;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.ws.rs.DELETE;\r
-import javax.ws.rs.GET;\r
-import javax.ws.rs.POST;\r
-import javax.ws.rs.PUT;\r
-import javax.ws.rs.Path;\r
-import javax.ws.rs.PathParam;\r
-import javax.ws.rs.Produces;\r
-import javax.ws.rs.QueryParam;\r
-import javax.ws.rs.core.Context;\r
-import javax.ws.rs.core.MediaType;\r
 import lombok.extern.slf4j.Slf4j;\r
-import net.sf.json.JSONObject;\r
 import org.jvnet.hk2.annotations.Service;\r
 import org.onap.holmes.common.exception.CorrelationException;\r
 import org.onap.holmes.common.utils.ExceptionUtil;\r
@@ -50,6 +34,13 @@ import org.onap.holmes.rulemgt.bean.response.RuleQueryListResponse;
 import org.onap.holmes.rulemgt.constant.RuleMgtConstant;\r
 import org.onap.holmes.rulemgt.wrapper.RuleMgtWrapper;\r
 \r
+import javax.inject.Inject;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.ws.rs.*;\r
+import javax.ws.rs.core.Context;\r
+import javax.ws.rs.core.MediaType;\r
+import java.util.Locale;\r
+\r
 @Service\r
 @SwaggerDefinition\r
 @Path("/rule")\r
@@ -68,8 +59,8 @@ public class RuleMgtResources {
     @Timed\r
     public RuleAddAndUpdateResponse addCorrelationRule(@Context HttpServletRequest request,\r
             @ApiParam(value =\r
-                    "The request entity of the HTTP call, which comprises \"rulename\"(required), "\r
-                            + "\"loopcontrolname\"(required), \"content\"(required), \"enabled\"(required) "\r
+                    "The request entity of the HTTP call, which comprises \"ruleName\"(required), "\r
+                            + "\"loopControlName\"(required), \"content\"(required), \"enabled\"(required) "\r
                             + "and \"description\"(optional)", required = true)\r
                     RuleCreateRequest ruleCreateRequest) {\r
         Locale locale = LanguageUtil.getLocale(request);\r
@@ -91,7 +82,7 @@ public class RuleMgtResources {
     @Timed\r
     public RuleAddAndUpdateResponse updateCorrelationRule(@Context HttpServletRequest request,\r
             @ApiParam(value =\r
-                    "The request entity of the HTTP call, which comprises \"ruleid\"(required), "\r
+                    "The request entity of the HTTP call, which comprises \"ruleId\"(required), "\r
                             + "\"content\"(required), \"enabled\"(required) and \"description\"(optional)", required = true)\r
                     RuleUpdateRequest ruleUpdateRequest) {\r
         Locale locale = LanguageUtil.getLocale(request);\r
@@ -137,12 +128,12 @@ public class RuleMgtResources {
                     required = false) @QueryParam("queryrequest") String ruleQueryRequest) {\r
         Locale locale = LanguageUtil.getLocale(request);\r
         RuleQueryListResponse ruleQueryListResponse;\r
+\r
         RuleQueryCondition ruleQueryCondition = getRuleQueryCondition(ruleQueryRequest, request);\r
         try {\r
             ruleQueryListResponse = ruleMgtWrapper\r
                     .getCorrelationRuleByCondition(ruleQueryCondition);\r
-            log.info("query rule successful by condition:" + JSONObject\r
-                    .fromObject(ruleQueryCondition));\r
+            log.info("query rule successful by condition:" + ruleQueryCondition);\r
             return ruleQueryListResponse;\r
         } catch (CorrelationException e) {\r
             log.error("query rule failed,cause query condition conversion failure", e);\r
@@ -153,10 +144,10 @@ public class RuleMgtResources {
     private RuleQueryCondition getRuleQueryCondition(String queryRequest,\r
             HttpServletRequest request) {\r
         Locale locale = LanguageUtil.getLocale(request);\r
-\r
-        RuleQueryCondition ruleQueryCondition = GsonUtil.jsonToBean(queryRequest, RuleQueryCondition.class);\r
+        RuleQueryCondition ruleQueryCondition = GsonUtil\r
+                .jsonToBean(queryRequest, RuleQueryCondition.class);\r
         if (queryRequest == null) {\r
-            if(ruleQueryCondition==null){\r
+            if (ruleQueryCondition == null) {\r
                 ruleQueryCondition = new RuleQueryCondition();\r
             }\r
             ruleQueryCondition.setEnabled(RuleMgtConstant.STATUS_RULE_ALL);\r