2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2019 China Mobile
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.datalake.feeder.service;
24 import org.onap.datalake.feeder.domain.Portal;
25 import org.onap.datalake.feeder.dto.PortalConfig;
26 import org.onap.datalake.feeder.repository.PortalRepository;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.stereotype.Service;
30 import java.util.ArrayList;
31 import java.util.List;
40 public class PortalService {
43 private PortalRepository portalRepository;
45 public Portal fillPortalConfiguration(PortalConfig portalConfig)
47 Portal portal = new Portal();
48 fillPortal(portalConfig, portal);
51 public void fillPortalConfiguration(PortalConfig portalConfig, Portal portal)
53 fillPortal(portalConfig, portal);
56 private void fillPortal(PortalConfig portalConfig, Portal portal) {
58 portal.setName(portalConfig.getName());
59 portal.setLogin(portalConfig.getLogin());
60 portal.setPass(portalConfig.getPass());
61 portal.setEnabled(portalConfig.getEnabled());
62 portal.setHost(portalConfig.getHost());
63 portal.setPort(portalConfig.getPort());
68 public List<String> listNames(boolean enabled){
70 List<String> names = new ArrayList<>();
71 Iterable<Portal> ret = portalRepository.findByEnabled(enabled);
72 for(Portal portal:ret) {
73 names.add(portal.getName());