From 4ed15bda06c8e9a407c12d527b8224737ba339d5 Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Sat, 13 Aug 2016 14:10:39 +0800 Subject: Initial code import Change-Id: I839b84e5200aedece6c33deb16bec1bf9dbb61df Signed-off-by: HuabingZhao --- .../java/org/openo/msb/wrapper/util/RouteUtil.java | 135 +++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/RouteUtil.java (limited to '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 index 0000000..5f60bd8 --- /dev/null +++ b/apiroute/apiroute-service/src/main/java/org/openo/msb/wrapper/util/RouteUtil.java @@ -0,0 +1,135 @@ +/** +* Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package org.openo.msb.wrapper.util; + +import org.apache.commons.lang3.StringUtils; +import org.openo.msb.api.DiscoverInfo; + + +public class RouteUtil { + + public static String IUI_ROOT_PATH="iui"; + + public static String API_ROOT_PATH="api"; + + public static final String ROUTE_PATH="msb:routing"; + + public static final String APIROUTE="api"; + + public static final String IUIROUTE="iui"; + + public static final String CUSTOMROUTE="custom"; + + public static final String P2PROUTE="p2p"; + + + public static final String ROUTE_PATH_INFO="info"; + + public static final String ROUTE_PATH_LOADBALANCE="lb"; + + public static final String APIROUTE_PATH_LIFE="life"; + + + public static final String REQUEST_SUCCESS = "SUCCESS"; + + public static final String REQUEST_FAIL = "FAIL"; + + public static String PROTOCOL_LIST="REST,UI,MQ,FTP,SNMP,TCP,UDP"; + + public static DiscoverInfo discoverInfo=new DiscoverInfo(); + + + public static String[] visualRangeRange={"0","1"}; + + public static String[] controlRangeMatches={"0","1","2"}; + + public static String[] statusRangeMatches={"0","1"}; + + public static String[] useOwnUpstreamRangeMatches={"0","1"}; + + public static String[] visualRangeMatches={"1"}; + + /** + * @Title: getPrefixedKey + * @Description: TODO(Add base path prefix radis assembly path) + * @param: @param serviceName + * @param: @param version + * @param: @param type + * @param: @return + * @return: String + */ + + public static String getPrefixedKey(String...paths){ + StringBuffer sb= new StringBuffer(); + + if(paths[0].trim().equals("") || paths[0].equals(String.valueOf(JedisUtil.serverPort))){ + sb.append(ROUTE_PATH); + } + else{ + sb.append(paths[0]); + } + + for (int i = 1; i < paths.length; i++) { + sb.append(":"); + sb.append(paths[i]); + } + return sb.toString(); + } + + + public static Object[] concat(Object[] a, Object[] b) { + Object[] c= new Object[a.length+b.length]; + System.arraycopy(a, 0, c, 0, a.length); + System.arraycopy(b, 0, c, a.length, b.length); + return c; + } + + public static boolean contain(String[] array,String str){ + for(int i=0;i