Graceful Fallback if no decryption
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / utils / EcompPortalUtils.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalapp.portal.utils;
39
40 import java.io.IOException;
41 import java.net.InetAddress;
42 import java.net.UnknownHostException;
43 import java.nio.charset.Charset;
44 import java.text.SimpleDateFormat;
45 import java.util.ArrayList;
46 import java.util.Arrays;
47 import java.util.Base64;
48 import java.util.Date;
49 import java.util.List;
50 import java.util.regex.Pattern;
51
52 import javax.servlet.http.HttpServletResponse;
53 import javax.xml.bind.DatatypeConverter;
54
55 import org.apache.commons.codec.binary.Hex;
56 import org.apache.commons.lang.StringUtils;
57 import org.hibernate.Session;
58 import org.hibernate.Transaction;
59 import org.onap.portalapp.portal.domain.EPUser;
60 import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum;
61 import org.onap.portalapp.portal.logging.logic.EPLogUtil;
62 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
63 import org.onap.portalsdk.core.onboarding.util.CipherUtil;
64 import org.onap.portalsdk.core.onboarding.util.KeyConstants;
65 import org.onap.portalsdk.core.onboarding.util.KeyProperties;
66 import org.onap.portalsdk.core.util.SystemProperties;
67 import org.slf4j.MDC;
68 import org.springframework.http.HttpHeaders;
69 import org.springframework.http.MediaType;
70
71 import com.fasterxml.jackson.core.JsonProcessingException;
72 import com.fasterxml.jackson.databind.ObjectMapper;
73
74 public class EcompPortalUtils {
75
76         private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EcompPortalUtils.class);
77
78         private static final String FUNCTION_PIPE = "|";
79
80         // TODO: GLOBAL_LOGIN_URL is the same as in SessionTimeoutInterceptor.
81         // It should be defined in SystemProperties.
82         private static final String GLOBAL_LOGIN_URL = "global-login-url";
83
84         // It is a regular expression used for while creating a External Central Auth
85         // Role
86         public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:^-])";
87         public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS_EXCLUDE_HYPHEN = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:])";
88
89         public static final String slash = "/";
90
91         /**
92          * @param orgUserId User ID to validate
93          * @return true if orgUserId is not empty and contains only alphanumeric, false
94          *         otherwise
95          */
96         public static boolean legitimateUserId(String orgUserId) {
97                 return orgUserId.matches("^[a-zA-Z0-9/_/-/@]+$");
98         }
99
100         /**
101          * Splits the string into a list of tokens using the specified regular
102          * expression
103          * 
104          * @param source String to split
105          * @param regex  tokens
106          * @return List of tokens split from the source
107          */
108         public static List<String> parsingByRegularExpression(String source, String regex) {
109                 List<String> tokens = new ArrayList<String>();
110                 if (source != null && source.length() > 0) {
111                         String[] parsed = source.split(regex);
112                         for (String token : parsed) {
113                                 if (token.length() > 0) {
114                                         tokens.add(token);
115                                 }
116                         }
117                 }
118                 return tokens;
119         }
120
121         /**
122          * Builds a JSON object with error code and message information.
123          * 
124          * @param errorCode    error code
125          * @param errorMessage message
126          * @return JSON object as a String
127          */
128         public static String jsonErrorMessageResponse(int errorCode, String errorMessage) {
129                 return "{\"error\":{\"code\":" + errorCode + "," + "\"message\":\"" + errorMessage + "\"}}";
130         }
131
132         /**
133          * Builds a JSON object with the specified message
134          * 
135          * @param message Message to embed
136          * @return JSON object as a String
137          */
138         public static String jsonMessageResponse(String message) {
139                 return String.format("{\"message\":\"%s\"}", message);
140         }
141
142         /**
143          * Serializes the specified object as JSON and writes the result to the debug
144          * log. If serialization fails, logs a message to the error logger.
145          * 
146          * @param logger Logger for the class where the object was built; the logger
147          *               carries the class name.
148          * @param source First portion of the log message
149          * @param msg    Second portion of the log message
150          * @param obj    Object to serialize as JSON
151          */
152         public static void logAndSerializeObject(EELFLoggerDelegate logger, String source, String msg, Object obj) {
153                 try {
154                         String objectAsJson = new ObjectMapper().writeValueAsString(obj);
155                         logger.debug(EELFLoggerDelegate.debugLogger,
156                                         String.format("source= [%s]; %s [%s];", source, msg, objectAsJson));
157                 } catch (JsonProcessingException e) {
158                         logger.warn(EELFLoggerDelegate.errorLogger, "logAndSerializedObject failed to serialize", e);
159                         EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e);
160                 } catch (Exception e) {
161                         logger.error(EELFLoggerDelegate.errorLogger, "logAndSerializedObject failed", e);
162                         EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e);
163                 }
164         }
165
166         /**
167          * Serializes the specified object as JSON and writes the result to the debug
168          * log. If serialization fails, logs a message to the error logger.
169          * 
170          * @param source First portion of the log message
171          * @param msg    Second portion of the log message
172          * @param obj    Object to serialize as JSON
173          */
174         public static void logAndSerializeObject(String source, String msg, Object obj) {
175                 logAndSerializeObject(logger, source, msg, obj);
176         }
177
178         public static void rollbackTransaction(Transaction transaction, String errorMessage) {
179                 logger.error(EELFLoggerDelegate.errorLogger, errorMessage);
180                 try {
181                         if (transaction != null) {
182                                 transaction.rollback();
183                         }
184                 } catch (Exception e) {
185                         EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeExecuteRollbackError, e);
186                         logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing a rollback transaction",
187                                         e);
188                 }
189         }
190
191         public static void closeLocalSession(Session localSession, String errorMessage) {
192                 logger.error(EELFLoggerDelegate.errorLogger, errorMessage);
193                 try {
194                         if (localSession != null) {
195                                 localSession.close();
196                         }
197                 } catch (Exception e) {
198                         EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoCloseSessionError, e);
199                         logger.error(EELFLoggerDelegate.errorLogger, errorMessage + ", closeLocalSession exception", e);
200                 }
201         }
202
203         /**
204          * Set response status to Unauthorized if user == null and to Forbidden in all
205          * (!) other cases. Logging is not performed if invocator == null
206          * 
207          * @param user      User object
208          * @param response  HttpServletResponse
209          * @param invocator may be null
210          */
211         public static void setBadPermissions(EPUser user, HttpServletResponse response, String invocator) {
212                 if (user == null) {
213                         String loginUrl = SystemProperties.getProperty(EPCommonSystemProperties.LOGIN_URL_NO_RET_VAL);
214                         response.setHeader(GLOBAL_LOGIN_URL, loginUrl);
215                         response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
216                         MDC.put(EPCommonSystemProperties.RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_UNAUTHORIZED));
217                 } else {
218                         response.setStatus(HttpServletResponse.SC_FORBIDDEN);
219                         MDC.put(EPCommonSystemProperties.RESPONSE_CODE, Integer.toString(HttpServletResponse.SC_FORBIDDEN));
220                 }
221                 if (invocator != null) {
222                         logger.warn(EELFLoggerDelegate.errorLogger,
223                                         invocator + ", permissions problem, response status = " + response.getStatus());
224                 }
225         }
226
227         public static int getExternalAppResponseCode() {
228                 String responseCode = MDC.get(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE);
229                 int responseCodeInt = 0;
230                 try {
231                         if (responseCode != null && responseCode != "") {
232                                 responseCodeInt = Integer.valueOf(responseCode);
233                         }
234                 } catch (Exception e) {
235                         logger.error(EELFLoggerDelegate.errorLogger, "getExternalAppResponseCode failed", e);
236                 }
237                 return responseCodeInt;
238         }
239
240         // This method might be just for testing purposes.
241         public static void setExternalAppResponseCode(int responseCode) {
242                 try {
243                         /*
244                          * String code = String.valueOf(responseCode);
245                          * MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE,code );
246                          * code=StringUtils.EMPTY;
247                          */
248                         String code = Integer.toString(responseCode);
249                         MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE, code);
250                         char[] chars = code.toCharArray();
251                         Arrays.fill(chars, ' ');
252                 } catch (Exception e) {
253                         logger.error(EELFLoggerDelegate.errorLogger, "setExternalAppResponseCode failed", e);
254                 }
255         }
256
257         public static String getHTTPStatusString(int httpStatusCode) {
258                 String httpStatusString = "unknown_error";
259                 try {
260                         httpStatusString = org.springframework.http.HttpStatus.valueOf(httpStatusCode).name();
261                         if (httpStatusString != null) {
262                                 httpStatusString = httpStatusString.toLowerCase();
263                         }
264                 } catch (Exception e) {
265                         logger.error(EELFLoggerDelegate.errorLogger, "getHTTPStatusString failed", e);
266                 }
267                 return httpStatusString;
268         }
269
270         public static String getFEErrorString(Boolean internal, int responseCode) {
271                 // Return a String like the following:
272                 // "Internal Onap Error: 500 internal_server_error" or
273                 // "External App Error: 404 not_found"
274                 // TODO: create our own Ecomp error codes, starting with 1000 and up.
275                 String internalExternalString = internal ? "Ecomp Error: " : "App Error: ";
276                 String httpStatusString = "unknown_error";
277                 try {
278                         if (responseCode < 1000) {
279                                 httpStatusString = getHTTPStatusString(responseCode);
280                         }
281                 } catch (Exception e) {
282                         logger.error(EELFLoggerDelegate.errorLogger, "getFEErrorString failed", e);
283                 }
284                 String responseString = internalExternalString + responseCode + " " + httpStatusString;
285                 return responseString;
286         }
287
288         public static boolean isProductionBuild() {
289                 boolean productionBuild = true;
290                 String epVersion = EcompVersion.buildNumber;
291                 if (epVersion != null) {
292                         int buildNum = epVersion.lastIndexOf('.');
293                         if (buildNum > 0) {
294                                 int buildNumber = Integer.parseInt(epVersion.substring(buildNum + 1));
295                                 if (buildNumber < 3000) // Production versions are 3000+, (ie
296                                                                                 // 1.0.3003)
297                                 {
298                                         productionBuild = false;
299                                 }
300                         }
301                 }
302                 return productionBuild;
303         }
304
305         public static String getMyIpAdddress() {
306                 InetAddress ip;
307                 String localIp;
308                 try {
309                         ip = InetAddress.getLocalHost();
310                         localIp = ip.getHostAddress();
311                 } catch (UnknownHostException e) {
312                         localIp = "unknown";
313                         logger.error(EELFLoggerDelegate.errorLogger, "getMyIpAdddress failed ", e);
314                 }
315                 return localIp;
316         }
317
318         public static String getMyHostName() {
319                 InetAddress ip;
320                 String hostName;
321                 try {
322                         ip = InetAddress.getLocalHost();
323                         hostName = ip.getHostName();
324                 } catch (UnknownHostException e) {
325                         hostName = "unknown";
326                         logger.error(EELFLoggerDelegate.errorLogger, "getMyHostName failed", e);
327                 }
328                 return hostName;
329         }
330
331         /**
332          * Returns a default property if the expected one is not available
333          * 
334          * @param property     Key
335          * @param defaultValue default Value
336          * @return Default value if property is not defined or yields the empty string;
337          *         else the property value.
338          */
339         public static String getPropertyOrDefault(String property, String defaultValue) {
340                 if (!SystemProperties.containsProperty(property))
341                         return defaultValue;
342                 String value = SystemProperties.getProperty(property);
343                 if (value == null || "".equals(value))
344                         return defaultValue;
345                 return value;
346         }
347
348         /**
349          * Calculates the time duration of a function call for logging purpose. It
350          * stores the result by using "MDC.put(SystemProperties.MDC_TIMER,
351          * timeDifference);" It is important to call
352          * "MDC.remove(SystemProperties.MDC_TIMER);" after this method call to clean up
353          * the record in MDC
354          *
355          * @param beginDateTime the given begin time for the call
356          * @param endDateTime   the given end time for the call
357          * 
358          */
359         public static void calculateDateTimeDifferenceForLog(String beginDateTime, String endDateTime) {
360                 if (beginDateTime != null && endDateTime != null) {
361                         try {
362                                 SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
363
364                                 Date beginDate = ecompLogDateFormat.parse(beginDateTime);
365                                 Date endDate = ecompLogDateFormat.parse(endDateTime);
366                                 String timeDifference = String.format("%d", endDate.getTime() - beginDate.getTime());
367                                 MDC.put(SystemProperties.MDC_TIMER, timeDifference);
368                         } catch (Exception e) {
369                                 logger.error(EELFLoggerDelegate.errorLogger, "calculateDateTimeDifferenceForLog failed", e);
370                         }
371                 }
372         }
373
374         /**
375          * Answers the protocol to use.
376          * 
377          * @return Protocol name from property file; defaults to https.
378          */
379         public static String widgetMsProtocol() {
380                 return getPropertyOrDefault(EPCommonSystemProperties.WIDGET_MS_PROTOCOL, "https");
381         }
382         
383         /**
384          * Answers the protocol to use.
385          * 
386          * @return Protocol name from property file; defaults to https.
387          */
388         public static String widgetMLProtocol() {
389                 return getPropertyOrDefault(EPCommonSystemProperties.WIDGET_ML_PROTOCOL, "https");
390         }
391
392         /**
393          * Answers the host to use.
394          * 
395          * @return Host name from property file; defaults to localhost.
396          */
397         public static String localOrDockerHost() {
398                 return getPropertyOrDefault(EPCommonSystemProperties.WIDGET_MS_HOSTNAME, "localhost");
399         }
400         
401         /**
402          * Answers the host to use.
403          * 
404          * @return Host name from property file; defaults to localhost.
405          */
406         public static String mlLocalOrDockerHost() {
407                 return getPropertyOrDefault(EPCommonSystemProperties.WIDGET_ML_HOSTNAME, "localhost");
408         }
409
410         /**
411          * It returns headers where username and password of external central auth is
412          * encoded to base64
413          * 
414          * @return header which contains external central auth username and password
415          *         base64 encoded
416          * @throws Exception if unable to decrypt the password
417          */
418         public static HttpHeaders base64encodeKeyForAAFBasicAuth() throws Exception {
419                 String userName = "";
420                 String decryptedPass = "";
421                 if (EPCommonSystemProperties.containsProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_AUTH_USER_NAME)
422                                 && EPCommonSystemProperties.containsProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_AUTH_PASSWORD)) {
423                         decryptedPass = SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_AUTH_PASSWORD);
424                         userName = SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_CENTRAL_AUTH_USER_NAME);
425                 }
426                 String decPass;
427                 try {
428                         decPass = decrypted(decryptedPass);
429                 } catch (Exception e) {
430                         logger.warn(EELFLoggerDelegate.errorLogger, "decryptedPassword failed using non decrypted pwd from the Properties file", e);
431                         decPass = decryptedPass;
432                 }
433                 String usernamePass = userName + ":" + decPass;
434                 String encToBase64 = String.valueOf((DatatypeConverter.printBase64Binary(usernamePass.getBytes())));
435                 HttpHeaders headers = new HttpHeaders();
436                 headers.add("Authorization", "Basic " + encToBase64);
437                 headers.setContentType(MediaType.APPLICATION_JSON);
438                 return headers;
439         }
440
441         private static String decrypted(String encrypted) throws Exception {
442                 String result = "";
443                 if (encrypted != null && encrypted.length() > 0) {
444                         try {
445                                 result = CipherUtil.decryptPKC(encrypted,
446                                                 KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
447                         } catch (Exception e) {
448                                 logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
449                                 throw e;
450                         }
451                 }
452                 return result;
453         }
454
455         public static String truncateString(String originString, int size) {
456                 if (originString.length() >= size) {
457                         StringBuilder stringBuilder = new StringBuilder();
458                         stringBuilder.append(originString);
459                         stringBuilder.setLength(size);
460                         stringBuilder.append("...");
461                         return stringBuilder.toString();
462                 }
463                 return originString;
464         }
465
466         /**
467          * 
468          * If function code value has any pipes it does pipe filter and returns value.
469          * 
470          * @param functionCode
471          * @return function instance without pipe
472          */
473         public static String getFunctionCode(String functionCode) {
474                 String finalFunctionCodeVal = "";
475                 if (functionCode.contains(FUNCTION_PIPE)) {
476                         int count = StringUtils.countMatches(functionCode, FUNCTION_PIPE);
477                         if (count == 2)
478                                 finalFunctionCodeVal = functionCode.substring(functionCode.indexOf(FUNCTION_PIPE) + 1,
479                                                 functionCode.lastIndexOf(FUNCTION_PIPE));
480                         else
481                                 finalFunctionCodeVal = functionCode.substring(functionCode.lastIndexOf(FUNCTION_PIPE) + 1);
482                 } else {
483                         finalFunctionCodeVal = functionCode;
484                 }
485                 return finalFunctionCodeVal;
486         }
487
488         /**
489          * 
490          * If function code value has any pipes it does pipe filter and returns value.
491          * 
492          * @param functionCode
493          * @return function Type without pipe
494          */
495         public static String getFunctionType(String functionCode) {
496                 String finalFunctionCodeVal = "";
497                 if (functionCode.contains(FUNCTION_PIPE)) {
498                         int count = StringUtils.countMatches(functionCode, FUNCTION_PIPE);
499                         if (count == 2) {
500                                 String[] getTypeValue = functionCode.split("\\" + FUNCTION_PIPE);
501                                 finalFunctionCodeVal = getTypeValue[0];
502                         }
503                 } else {
504                         finalFunctionCodeVal = functionCode;
505                 }
506                 return finalFunctionCodeVal;
507         }
508
509         /**
510          * 
511          * If function code value has any pipes it does pipe filter and returns value.
512          * 
513          * @param functionCode
514          * @return function Action without pipe
515          */
516         public static String getFunctionAction(String functionCode) {
517                 String finalFunctionCodeVal = "";
518                 if (functionCode.contains(FUNCTION_PIPE)) {
519                         int count = StringUtils.countMatches(functionCode, FUNCTION_PIPE);
520                         if (count == 2)
521                                 finalFunctionCodeVal = functionCode.substring(functionCode.lastIndexOf(FUNCTION_PIPE) + 1);
522                 } else {
523                         finalFunctionCodeVal = functionCode;
524                 }
525                 return finalFunctionCodeVal;
526         }
527
528         /**
529          * 
530          * It check whether the external auth namespace is matching with current
531          * namespace exists in local DB
532          * 
533          * @param permTypeVal
534          * @param appNamespaceVal
535          * @return true or false
536          */
537         public static boolean checkNameSpaceMatching(String permTypeVal, String appNamespaceVal) {
538                 String[] typeNamespace = permTypeVal.split("\\.");
539                 String[] appNamespace = appNamespaceVal.split("\\.");
540                 boolean isNamespaceMatching = true;
541                 if (appNamespace.length <= typeNamespace.length) {
542                         for (int k = 0; k < appNamespace.length; k++) {
543                                 if (!appNamespace[k].equals(typeNamespace[k]))
544                                         isNamespaceMatching = false;
545                         }
546                 } else {
547                         isNamespaceMatching = false;
548                 }
549                 return isNamespaceMatching;
550         }
551
552         public static boolean checkIfRemoteCentralAccessAllowed() {
553                 boolean result = false;
554                 String rmtCentralAccess = SystemProperties
555                                 .getProperty(EPCommonSystemProperties.REMOTE_CENTRALISED_SYSTEM_ACCESS);
556                 if (rmtCentralAccess == null) {
557                         logger.error(EELFLoggerDelegate.errorLogger,
558                                         "Please check in system.properties whether the property exists or not!");
559                         return false;
560                 } else if (new Boolean(rmtCentralAccess)) {
561                         logger.debug(EELFLoggerDelegate.debugLogger, "checkIfRemoteCentralAccessAllowed: {}", rmtCentralAccess);
562                         result = true;
563                 }
564                 return result;
565         }
566
567         /**
568          * 
569          * It validates whether given string is JSON or not
570          * 
571          * @param jsonInString
572          * @return true or false
573          */
574         public static boolean isJSONValid(String jsonInString) {
575                 try {
576                         final ObjectMapper mapper = new ObjectMapper();
577                         mapper.readTree(jsonInString);
578                         return true;
579                 } catch (IOException e) {
580                         logger.error(EELFLoggerDelegate.errorLogger, "Failed to parse Json!", e);
581                         return false;
582                 }
583         }
584
585         /**
586          * 
587          * It retrieves account information from input String
588          * 
589          * @param authValue
590          * @return Array of Account information
591          * 
592          */
593         public static String[] getUserNamePassword(String authValue) {
594                 String base64Credentials = authValue.substring("Basic".length()).trim();
595                 String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
596                 final String[] values = credentials.split(":", 2);
597                 return values;
598         }
599
600         /**
601          * It encodes the function code based on Hex encoding
602          * 
603          * @param funCode
604          * 
605          */
606         public static String encodeFunctionCode(String funCode) {
607                 String encodedString = funCode;
608                 Pattern encodePattern = Pattern.compile(EcompPortalUtils.slash);
609                 return encodedString = encodePattern.matcher(encodedString)
610                                 .replaceAll("%" + Hex.encodeHexString(encodePattern.toString().getBytes()))
611                                 .replaceAll("\\*", "%" + Hex.encodeHexString("*".getBytes()));
612         }
613
614         public static boolean checkFunctionCodeHasEncodePattern(String code) {
615                 return code.contains(EcompPortalUtils.slash);
616         }
617
618 }