Initial code import
[msb/apigateway.git] / apiroute / apiroute-service / src / main / java / org / openo / msb / wrapper / util / RouteUtil.java
diff --git a/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/RouteUtil.java b/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/RouteUtil.java
new file mode 100644 (file)
index 0000000..5f60bd8
--- /dev/null
@@ -0,0 +1,135 @@
+/**\r
+* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)\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
+*\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
+*/\r
+\r
+package org.openo.msb.wrapper.util;\r
+\r
+import org.apache.commons.lang3.StringUtils;\r
+import org.openo.msb.api.DiscoverInfo;\r
+\r
+\r
+public class RouteUtil {\r
+\r
+    public static String IUI_ROOT_PATH="iui";  \r
+    \r
+    public static  String API_ROOT_PATH="api"; \r
+    \r
+       public static final String ROUTE_PATH="msb:routing";   \r
+       \r
+       public static final String APIROUTE="api";  \r
+       \r
+       public static final String IUIROUTE="iui";  \r
+       \r
+       public static final String CUSTOMROUTE="custom";  \r
+       \r
+       public static final String P2PROUTE="p2p";  \r
+       \r
+       \r
+       public static final String ROUTE_PATH_INFO="info";  \r
+       \r
+       public static final String ROUTE_PATH_LOADBALANCE="lb"; \r
+       \r
+       public static final String APIROUTE_PATH_LIFE="life";  \r
+       \r
+\r
+       public static final String REQUEST_SUCCESS = "SUCCESS";\r
+       \r
+       public static final String REQUEST_FAIL = "FAIL";\r
+       \r
+    public static String PROTOCOL_LIST="REST,UI,MQ,FTP,SNMP,TCP,UDP"; \r
+    \r
+    public static DiscoverInfo discoverInfo=new DiscoverInfo();\r
+    \r
+    \r
+    public static String[] visualRangeRange={"0","1"};\r
+    \r
+    public static String[] controlRangeMatches={"0","1","2"};\r
+    \r
+    public static String[] statusRangeMatches={"0","1"};\r
+    \r
+    public static String[] useOwnUpstreamRangeMatches={"0","1"};\r
+    \r
+    public static String[] visualRangeMatches={"1"};\r
+       \r
+       /** \r
+       * @Title: getPrefixedKey  \r
+       * @Description: TODO(Add base path prefix radis assembly path) \r
+       * @param: @param serviceName\r
+       * @param: @param version\r
+       * @param: @param type\r
+       * @param: @return      \r
+       * @return: String    \r
+       */\r
+       \r
+       public static String getPrefixedKey(String...paths){\r
+               StringBuffer sb= new StringBuffer();\r
+               \r
+                   if(paths[0].trim().equals("") || paths[0].equals(String.valueOf(JedisUtil.serverPort))){\r
+                   sb.append(ROUTE_PATH);\r
+               }\r
+               else{\r
+                  sb.append(paths[0]); \r
+               }\r
+       \r
+               for (int i = 1; i < paths.length; i++) {\r
+                       sb.append(":");\r
+                       sb.append(paths[i]);\r
+               }\r
+               return sb.toString();\r
+       }\r
+       \r
+       \r
+       public static Object[] concat(Object[] a, Object[] b) {\r
+           Object[] c= new Object[a.length+b.length];\r
+        System.arraycopy(a, 0, c, 0, a.length);\r
+        System.arraycopy(b, 0, c, a.length, b.length);\r
+        return c;\r
+     }\r
+       \r
+       public static boolean contain(String[] array,String str){\r
+           for(int i=0;i<array.length;i++){\r
+                 if(array[i].equals(str)){\r
+                    return true;  \r
+                 }\r
+           }\r
+           return false;\r
+\r
+         }\r
+       \r
+       public static boolean contain(String[] array,String value[]){\r
+        for(int i=0;i<array.length;i++){\r
+            for(int n=0;n<value.length;n++){\r
+              if(array[i].equals(value[n])){\r
+                 return true;  \r
+              }\r
+            }\r
+        }\r
+        return false;\r
+\r
+      }\r
+       \r
+       public static String show(String[] array){\r
+           \r
+        return StringUtils.join(array, "|");\r
+\r
+      }\r
+       \r
+       public static void main(String[] args) {\r
+           String array[]={"1","2"};\r
+           System.out.println(StringUtils.join(array, "|"));\r
+    }\r
+       \r
+\r
+}\r