2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. 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.apex.client.editor.rest.handling;
23 import org.onap.policy.apex.model.modelapi.ApexApiResult;
24 import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
26 // TODO: Auto-generated Javadoc
28 * This interface defines the methods that a REST handler must implement to handle REST editor commands.
31 public interface RestCommandHandler {
34 * Process a REST command.
36 * @param session the Apex editor session
37 * @param commandType the type of REST command to execute
38 * @param command the REST command to execute
39 * @return the apex api result the result of the execution
41 public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
42 final RestCommand command);
45 * Process a REST command.
47 * @param session the Apex editor session
48 * @param commandType the type of REST command to execute
49 * @param command the REST command to execute
50 * @param jsonString the json string to use to execute the command
51 * @return the apex api result the result of the execution
53 public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
54 final RestCommand command, final String jsonString);
57 * Process a REST command.
59 * @param session the Apex editor session
60 * @param commandType the type of REST command to execute
61 * @param command the REST command to execute
62 * @param name the concept name on which to execute
63 * @param version the concept version the version on which to execute
64 * @return the apex api result the result of the execution
66 public ApexApiResult executeRestCommand(final RestSession session, final RestCommandType commandType,
67 final RestCommand command, final String name, final String version);
70 * Get an unsupported command result message.
72 * @param session the Apex editor session
73 * @param commandType the type of REST command to execute
74 * @param command the REST command to execute
76 public default ApexApiResult getUnsupportedCommandResultMessage(final RestSession session,
77 final RestCommandType commandType, final RestCommand command) {
78 return new ApexApiResult(Result.FAILED, "session " + session.getSessionId() + ", command type " + commandType
79 + ", command" + command + " invalid");
83 * Convert blank incoming fields to nulls.
85 * @param incomingField the field to check
86 * @return null if the field is blank, otherwise, the field trimmed
88 public default String blank2Null(final String incomingField) {
89 if (incomingField == null) {
93 String trimmedField = incomingField.trim();
95 if (trimmedField.isEmpty()) {