2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Nokia. 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.onap.aaf.certservice.api;
23 import io.swagger.v3.oas.annotations.Operation;
24 import io.swagger.v3.oas.annotations.media.Content;
25 import io.swagger.v3.oas.annotations.media.Schema;
26 import io.swagger.v3.oas.annotations.responses.ApiResponse;
27 import io.swagger.v3.oas.annotations.responses.ApiResponses;
28 import io.swagger.v3.oas.annotations.tags.Tag;
29 import org.onap.aaf.certservice.certification.configuration.CmpServersConfig;
30 import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException;
31 import org.onap.aaf.certservice.certification.exception.ErrorResponseModel;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.http.HttpStatus;
36 import org.springframework.http.ResponseEntity;
37 import org.springframework.web.bind.annotation.GetMapping;
38 import org.springframework.web.bind.annotation.RestController;
41 @Tag(name = "CertificationService")
42 public class ReloadConfigController {
44 private static final Logger LOGGER = LoggerFactory.getLogger(ReloadConfigController.class);
46 private final CmpServersConfig cmpServersConfig;
49 public ReloadConfigController(CmpServersConfig cmpServersConfig) {
50 this.cmpServersConfig = cmpServersConfig;
53 @GetMapping(value = "/reload", produces = "application/json; charset=utf-8")
54 @ApiResponses(value = {
55 @ApiResponse(responseCode = "200", description = "configuration has been successfully reloaded"),
56 @ApiResponse(responseCode = "500", description = "something went wrong during configuration loading",
57 content = @Content(schema = @Schema(implementation = ErrorResponseModel.class)))
60 summary = "reload service configuration from file",
61 description = "Web endpoint for performing configuration reload. Used to reload configuration file from file.",
62 tags = { "CertificationService" })
63 public ResponseEntity<String> reloadConfiguration() throws CmpServersConfigLoadingException {
64 cmpServersConfig.reloadConfiguration();
65 return new ResponseEntity<>(HttpStatus.OK);