2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2018 Intel. All rights reserved.
 
   4  *  Modifications Copyright (C) 2019 Nordix Foundation.
 
   5  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
 
  19  * SPDX-License-Identifier: Apache-2.0
 
  20  * ============LICENSE_END=========================================================
 
  23 package org.onap.policy.distribution.reception.handling.file;
 
  28 import org.onap.policy.common.parameters.BeanValidationResult;
 
  29 import org.onap.policy.common.parameters.BeanValidator;
 
  30 import org.onap.policy.common.parameters.ObjectValidationResult;
 
  31 import org.onap.policy.common.parameters.ValidationResult;
 
  32 import org.onap.policy.common.parameters.ValidationStatus;
 
  33 import org.onap.policy.common.parameters.annotations.NotBlank;
 
  34 import org.onap.policy.common.parameters.annotations.NotNull;
 
  35 import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
 
  38  * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json
 
  39  * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
 
  45 public class FileSystemReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
 
  47     private String watchPath;
 
  48     private int maxThread;
 
  50     public FileSystemReceptionHandlerConfigurationParameterGroup() {
 
  51         super(FileSystemReceptionHandlerConfigurationParameterGroup.class.getSimpleName());
 
  58     public BeanValidationResult validate() {
 
  59         final BeanValidationResult validationResult = new BeanValidator().validateTop(getClass().getSimpleName(), this);
 
  60         validationResult.addResult(validatePathElement(watchPath, "watchPath"));
 
  61         return validationResult;
 
  66      * Validate the string element.
 
  68      * @param element the element to validate
 
  69      * @param elementName the element name for error message
 
  71     private ValidationResult validatePathElement(final String element, final String elementName) {
 
  72         if (element != null) {
 
  73             final File file = new File(element);
 
  74             if (file.exists() && file.isDirectory()) {
 
  79         return new ObjectValidationResult(elementName, element, ValidationStatus.INVALID, "is not a valid directory");