2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2018 Intel. All rights reserved.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.distribution.reception.handling.sdc;
 
  25 import org.onap.policy.common.parameters.GroupValidationResult;
 
  26 import org.onap.policy.common.parameters.ValidationStatus;
 
  27 import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
 
  30  * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json
 
  31  * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
 
  33 public class FileSystemReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
 
  35     private String watchPath;
 
  38      * The constructor for instantiating {@link FileSystemReceptionHandlerConfigurationParameterGroup} class.
 
  40      * @param builder the SDC configuration builder
 
  42     public FileSystemReceptionHandlerConfigurationParameterGroup(
 
  43             final FileSystemReceptionHandlerConfigurationParameterBuilder builder) {
 
  44         watchPath = builder.getWatchPath();
 
  47     public String getWatchPath() {
 
  55     public GroupValidationResult validate() {
 
  56         final GroupValidationResult validationResult = new GroupValidationResult(this);
 
  57         validatePathElement(validationResult, watchPath, "watchPath");
 
  58         return validationResult;
 
  63      * Validate the string element.
 
  65      * @param validationResult the result object
 
  66      * @param element the element to validate
 
  67      * @param elementName the element name for error message
 
  69     private void validatePathElement(final GroupValidationResult validationResult, final String element,
 
  70             final String elementName) {
 
  71         File file = new File(element);
 
  72         if (!(file.exists() && file.isDirectory())) {
 
  73             validationResult.setResult(elementName, ValidationStatus.INVALID,
 
  74                     elementName + " must be a valid directory");