2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Modifications Copyright (c) 2019 Samsung
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.so.utils;
26 import java.util.UUID;
28 import org.onap.so.logger.MessageEnum;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
34 public class UUIDChecker {
36 private static final Logger logger = LoggerFactory.getLogger(UUIDChecker.class);
38 private UUIDChecker() {
41 public static boolean isValidUUID (String id) {
46 UUID uuid = UUID.fromString(id);
47 return uuid.toString().equalsIgnoreCase(id);
48 } catch (IllegalArgumentException iae) {
49 logger.debug("IllegalArgumentException", iae);
54 public static String getUUID () {
55 String result = UUID.randomUUID().toString();
56 logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID, result);