2 * Copyright 2016 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openo.gso.gui.servicegateway.util.validate;
19 import org.openo.baseservice.remoteservice.exception.ServiceException;
20 import org.openo.gso.gui.servicegateway.exception.ErrorCode;
21 import org.openo.gso.gui.servicegateway.exception.HttpCode;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.springframework.util.StringUtils;
32 * @version GSO 0.5 2016/8/19
34 public class ValidateUtil {
39 private static final Logger LOGGER = LoggerFactory.getLogger(ValidateUtil.class);
48 private ValidateUtil() {
53 * Assert String parameter.<br/>
55 * @param param parameter data
56 * @throws ServiceException when parameter is null or empty.
59 public static void assertStringNotNull(String param) throws ServiceException {
60 if(StringUtils.hasLength(param)) {
64 LOGGER.error("Parameter is null or empty.");
65 throw new ServiceException(ErrorCode.SVCMGR_SERVICEMGR_BAD_PARAM, HttpCode.BAD_REQUEST);
69 * Assert object is null.<br/>
71 * @param object data object
72 * @throws ServiceException when object is null.
75 public static void assertObjectNotNull(Object object) throws ServiceException {
77 LOGGER.error("Object is null.");
78 throw new ServiceException(ErrorCode.SVCMGR_SERVICEMGR_BAD_PARAM, "Object is null.");