2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation. All rights reserved.
4 * Copyright (C) 2020-2021 Nokia. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
20 package org.onap.dcaegen2.collectors.datafile.commons;
22 import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
25 * Enum specifying the schemes that DFC support for downloading files.
27 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
31 FTPES, SFTP, HTTP, HTTPS;
33 public static final String DFC_DOES_NOT_SUPPORT_PROTOCOL_ERROR_MSG = "DFC does not support protocol ";
34 public static final String SUPPORTED_PROTOCOLS_ERROR_MESSAGE =
35 ". Supported protocols are FTPeS, sFTP, HTTP and HTTPS";
38 * Get a <code>Scheme</code> from a string.
40 * @param schemeString the string to convert to <code>Scheme</code>.
41 * @return The corresponding <code>Scheme</code>
42 * @throws DatafileTaskException if the value of the string doesn't match any defined scheme.
44 public static Scheme getSchemeFromString(String schemeString) throws DatafileTaskException {
46 if ("FTPES".equalsIgnoreCase(schemeString)) {
47 result = Scheme.FTPES;
48 } else if ("SFTP".equalsIgnoreCase(schemeString)) {
50 } else if ("HTTP".equalsIgnoreCase(schemeString)) {
52 } else if ("HTTPS".equalsIgnoreCase(schemeString)) {
53 result = Scheme.HTTPS;
55 throw new DatafileTaskException(
56 DFC_DOES_NOT_SUPPORT_PROTOCOL_ERROR_MSG + schemeString + SUPPORTED_PROTOCOLS_ERROR_MESSAGE);
62 * Check if <code>Scheme</code> is FTP type or HTTP type.
64 * @param scheme the <code>Scheme</code> which has to be checked.
65 * @return true if <code>Scheme</code> is FTP type or false if it is HTTP type
67 public static boolean isFtpScheme(Scheme scheme) {
68 return scheme == SFTP || scheme == FTPES;