2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2022 Nordix Foundation. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.common.filters;
23 import java.io.IOException;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.List;
27 import javax.servlet.FilterChain;
28 import javax.servlet.ServletException;
29 import javax.servlet.ServletRequest;
30 import javax.servlet.ServletResponse;
31 import javax.servlet.http.HttpServletResponse;
32 import org.apache.commons.lang3.StringUtils;
33 import org.openecomp.sdc.common.CommonConfigurationManager;
34 import org.openecomp.sdc.common.errors.DefaultExceptionMapper;
35 import org.openecomp.sdc.exception.NotAllowedSpecialCharsException;
38 * Implements DataValidatorFilter for onboarding.
39 * Extends {@link DataValidatorFilterAbstract}
41 public class DataValidatorFilter extends DataValidatorFilterAbstract {
43 private final DefaultExceptionMapper defaultExceptionMapper;
45 public DataValidatorFilter() {
46 defaultExceptionMapper = new DefaultExceptionMapper();
50 public void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain)
51 throws IOException, ServletException, NotAllowedSpecialCharsException {
53 super.doFilter(request, response, chain);
54 } catch (final NotAllowedSpecialCharsException e) {
55 defaultExceptionMapper.writeToResponse(e, (HttpServletResponse) response);
60 protected List<String> getDataValidatorFilterExcludedUrls() {
61 final CommonConfigurationManager commonConfigurationManager = CommonConfigurationManager.getInstance();
62 if (commonConfigurationManager != null) {
63 final String dataValidatorFilterExcludedUrls = commonConfigurationManager.getConfigValue(DATA_VALIDATOR_FILTER_EXCLUDED_URLS, "");
64 if (StringUtils.isNotBlank(dataValidatorFilterExcludedUrls)) {
65 return Arrays.asList(dataValidatorFilterExcludedUrls.split(","));
68 return new ArrayList<>();