diff options
68 files changed, 5781 insertions, 5541 deletions
diff --git a/onap-eclipse-format.xml b/onap-eclipse-format.xml index 093866a..f4065a2 100755 --- a/onap-eclipse-format.xml +++ b/onap-eclipse-format.xml @@ -1,313 +1,313 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<profiles version="12"> -<profile kind="CodeFormatterProfile" name="ONAP Java Rule" version="12"> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> -<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="48"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> -<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/> -<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> -<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="3"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> -<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/> -<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/> -<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> -<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="48"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> -<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> -<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/> -<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="0"/> -<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> -<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> -</profile> +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<profiles version="12">
+<profile kind="CodeFormatterProfile" name="ONAP Java Rule" version="12">
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="48"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="3"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="48"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+</profile>
</profiles>
\ No newline at end of file diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml new file mode 100755 index 0000000..1400e3e --- /dev/null +++ b/packages/docker/pom.xml @@ -0,0 +1,157 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.adapters.so-nssmf-adapter</groupId>
+ <artifactId>packages</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.so.adapters.so-nssmf-adapter.packages</groupId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <artifactId>docker</artifactId>
+ <name>SO NSSMF Adapter Docker Packaging</name>
+
+ <properties>
+ <nssmf-adapter-project-version>${project.version}</nssmf-adapter-project-version>
+ <docker.skip>false</docker.skip>
+ <docker.skip.build>false</docker.skip.build>
+ <docker.skip.push>false</docker.skip.push>
+ <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
+ <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+ <docker.image.prefix>onap/so</docker.image.prefix>
+ <docker.push.phase>deploy</docker.push.phase>
+ </properties>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ println 'Project version: ' + project.properties['nssmf-adapter-project-version'];
+ def versionArray;
+ if (project.properties['nssmf-adapter-project-version'] != null) {
+ versionArray = project.properties['nssmf-adapter-project-version'].split('-');
+ }
+
+ if (project.properties['nssmf-adapter-project-version'].endsWith("-SNAPSHOT")) {
+ project.properties['project.docker.latesttag.version'] = versionArray[0] + "-SNAPSHOT-latest";
+ } else {
+ project.properties['project.docker.latesttag.version'] = versionArray[0] + "-STAGING-latest";
+ }
+
+ println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <configuration combine.self="override">
+ <verbose>true</verbose>
+ <apiVersion>1.23</apiVersion>
+ <pullRegistry>${docker.pull.registry}</pullRegistry>
+ <pushRegistry>${docker.push.registry}</pushRegistry>
+ <images>
+ <image>
+ <name>${docker.image.prefix}/base-image:1.0</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFile>docker-files/Dockerfile.so-base-image</dockerFile>
+ </build>
+ </image>
+ <image>
+ <name>${docker.image.prefix}/so-nssmf-adapter</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFile>docker-files/Dockerfile.so-app</dockerFile>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latesttag.version}</tag>
+ </tags>
+ <assembly>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>
+ org.onap.so.adapters.so-nssmf-adapter:so-nssmf-adapter-application
+ </include>
+ </includes>
+ <outputFileNameMapping>app.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+
+ </images>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>clean-images</id>
+ <phase>pre-clean</phase>
+ <goals>
+ <goal>remove</goal>
+ </goals>
+ <configuration>
+ <removeAll>true</removeAll>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>generate-images</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>push-images</id>
+ <phase>${docker.push.phase}</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.prefix}/so-nssmf-adapter</image>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.so.adapters.so-nssmf-adapter</groupId>
+ <artifactId>so-nssmf-adapter-application</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file diff --git a/Dockerfile b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app index 483c219..1048027 100644 --- a/Dockerfile +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app @@ -1,30 +1,31 @@ -FROM adoptopenjdk/openjdk11:jre-11.0.8_10-alpine - -ARG JAR_FILE=*.jar -ARG http_proxy -ENV HTTP_PROXY=$http_proxy -ENV http_proxy=$HTTP_PROXY -ARG https_proxy -ENV HTTPS_PROXY=$https_proxy -ENV https_proxy=$HTTPS_PROXY -USER root -RUN mkdir -p /app/config -RUN mkdir -p /app/certificates -RUN mkdir -p /app/logs -RUN mkdir -p /app/ca-certificates -RUN apk update && apk add apache2-utils -COPY target/${JAR_FILE} /app/app.jar - -COPY configs/logging/logback-spring.xml /app -COPY scripts/start-app.sh /app -COPY scripts/wait-for.sh /app -COPY ca-certificates/onap-ca.crt /app/ca-certificates/onap-ca.crt -#RUN chown -R so:so /app -#USER so -# Springboot configuration (required) -VOLUME /app/config -# Root certificates (optional) -VOLUME /app/ca-certificates -WORKDIR /app -ENTRYPOINT ["/app/start-app.sh"] - +FROM onap/so/base-image:1.0
+
+ARG http_proxy
+ENV HTTP_PROXY=$http_proxy
+ENV http_proxy=$HTTP_PROXY
+ARG https_proxy
+ENV HTTPS_PROXY=$https_proxy
+ENV https_proxy=$HTTPS_PROXY
+
+USER root
+RUN mkdir -p /app/config
+RUN mkdir -p /app/certificates
+RUN mkdir -p /app/logs
+RUN mkdir -p /app/ca-certificates
+
+COPY maven/app.jar /app
+COPY configs/logging/logback-spring.xml /app
+COPY scripts/start-app.sh /app
+COPY scripts/wait-for.sh /app
+COPY ca-certificates/onap-ca.crt /app/ca-certificates/onap-ca.crt
+RUN chown -R so:so /app
+
+USER so
+# Springboot configuration (required)
+VOLUME /app/config
+
+# Root certificates (optional)
+VOLUME /app/ca-certificates
+
+WORKDIR /app
+ENTRYPOINT ["/app/start-app.sh"]
diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image new file mode 100644 index 0000000..0bc4aba --- /dev/null +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image @@ -0,0 +1,19 @@ +FROM adoptopenjdk/openjdk11:jre-11.0.8_10-alpine
+
+ARG http_proxy
+ARG https_proxy
+ENV HTTP_PROXY=$http_proxy
+ENV HTTPS_PROXY=$https_proxy
+ENV http_proxy=$HTTP_PROXY
+ENV https_proxy=$HTTPS_PROXY
+
+# Install commonly needed tools
+RUN apk --no-cache add curl netcat-openbsd nss apache2-utils java-cacerts
+
+# Create symlink for default Java truststore
+RUN set -eux; \
+ rm -rf "$JAVA_HOME/lib/security/cacerts"; \
+ ln -sT /etc/ssl/certs/java/cacerts "$JAVA_HOME/lib/security/cacerts"
+
+# Create 'so' user
+RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so
diff --git a/ca-certificates/onap-ca.crt b/packages/docker/src/main/docker/docker-files/ca-certificates/onap-ca.crt index e9a50d7..98f620c 100644 --- a/ca-certificates/onap-ca.crt +++ b/packages/docker/src/main/docker/docker-files/ca-certificates/onap-ca.crt @@ -1,31 +1,31 @@ ------BEGIN CERTIFICATE----- -MIIFPjCCAyagAwIBAgIJAJ6u7cCnzrWdMA0GCSqGSIb3DQEBCwUAMCwxDjAMBgNV -BAsMBU9TQUFGMQ0wCwYDVQQKDARPTkFQMQswCQYDVQQGEwJVUzAeFw0xODA0MDUx -NDE1MjhaFw0zODAzMzExNDE1MjhaMCwxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQK -DARPTkFQMQswCQYDVQQGEwJVUzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC -ggIBAMA5pkgRs7NhGG4ew5JouhyYakgYUyFaG121+/h8qbSdt0hVQv56+EA41Yq7 -XGie7RYDQK9NmAFF3gruE+6X7wvJiChp+Cyd7sFMnb65uWhxEdxWTM2BJFrgfzUn -H8ZCxgaCo3XH4PzlKRy2LQQJEJECwl/RZmRCXijMt5e9h8XoZY/fKkKcZZUsWNCM -pTo266wjvA9MXLmdgReRj0+vrCjrNqy+htwJDztoiHWiYPqT6o8EvGcgjNqjlZx7 -NUNf8MfLDByqKF6+wRbHv1GKjn3/Vijd45Fv8riyRYROiFanvbV6jIfBkv8PZbXg -2VDWsYsgp8NAvMxK+iV8cO+Ck3lBI2GOPZbCEqpPVTYbLUz6sczAlCXwQoPzDIZY -wYa3eR/gYLY1gP2iEVHORag3bLPap9ZX5E8DZkzTNTjovvLk8KaCmfcaUMJsBtDd -ApcUitz10cnRyZc1sX3gE1f3DpzQM6t9C5sOVyRhDcSrKqqwb9m0Ss04XAS9FsqM -P3UWYQyqDXSxlUAYaX892u8mV1hxnt2gjb22RloXMM6TovM3sSrJS0wH+l1nznd6 -aFXftS/G4ZVIVZ/LfT1is4StoyPWZCwwwly1z8qJQ/zhip5NgZTxQw4mi7ww35DY -PdAQOCoajfSvFjqslQ/cPRi/MRCu079heVb5fQnnzVtnpFQRAgMBAAGjYzBhMB0G -A1UdDgQWBBRTVTPyS+vQUbHBeJrBKDF77+rtSTAfBgNVHSMEGDAWgBRTVTPyS+vQ -UbHBeJrBKDF77+rtSTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAN -BgkqhkiG9w0BAQsFAAOCAgEAPx/IaK94n02wPxpnYTy+LVLIxwdq/kawNd6IbiMz -L87zmNMDmHcGbfoRCj8OkhuggX9Lx1/CkhpXimuYsZOFQi5blr/u+v4mIbsgbmi9 -7j+cUHDP0zLycvSvxKHty51LwmaX9a4wkJl5zBU4O1sd/H9tWcEmwJ39ltKoBKBx -c94Zc3iMm5ytRWGj+0rKzLDAXEWpoZ5bE5PLJauA6UDCxDLfs3FwhbS7uDggxYvf -jySF5FCNET94oJ+m8s7VeHvoa8iPGKvXrIqdd7XDHnqJJlVKr7m9S0fMbyEB8ci2 -RtOXDt93ifY1uhoEtEykn4dqBSp8ezvNMnwoXdYPDvTd9uCAFeWFLVreBAWxd25h -PsBTkZA5hpa/rA+mKv6Af4VBViYr8cz4dZCsFChuioVebe9ighrfjB//qKepFjPF -CyjzKN1u0JKm/2x/ORqxkTONG8p3uDwoIOyimUcTtTMv42bfYD88RKakqSFXE9G+ -Z0LlaKABqfjK49o/tsAp+c5LoNlYllKhnetO3QAdraHwdmC36BhoghzR1jpX751A -cZn2VH3Q4XKyp01cJNCJIrua+A+bx6zh3RyW6zIIkbRCbET+UD+4mr8WIcSE3mtR -ZVlnhUDO4z9//WKMVzwS9Rh8/kuszrGFI1KQozXCHLrce3YP6RYZfOed79LXaRwX -dYY= ------END CERTIFICATE----- +-----BEGIN CERTIFICATE-----
+MIIFPjCCAyagAwIBAgIJAJ6u7cCnzrWdMA0GCSqGSIb3DQEBCwUAMCwxDjAMBgNV
+BAsMBU9TQUFGMQ0wCwYDVQQKDARPTkFQMQswCQYDVQQGEwJVUzAeFw0xODA0MDUx
+NDE1MjhaFw0zODAzMzExNDE1MjhaMCwxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQK
+DARPTkFQMQswCQYDVQQGEwJVUzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
+ggIBAMA5pkgRs7NhGG4ew5JouhyYakgYUyFaG121+/h8qbSdt0hVQv56+EA41Yq7
+XGie7RYDQK9NmAFF3gruE+6X7wvJiChp+Cyd7sFMnb65uWhxEdxWTM2BJFrgfzUn
+H8ZCxgaCo3XH4PzlKRy2LQQJEJECwl/RZmRCXijMt5e9h8XoZY/fKkKcZZUsWNCM
+pTo266wjvA9MXLmdgReRj0+vrCjrNqy+htwJDztoiHWiYPqT6o8EvGcgjNqjlZx7
+NUNf8MfLDByqKF6+wRbHv1GKjn3/Vijd45Fv8riyRYROiFanvbV6jIfBkv8PZbXg
+2VDWsYsgp8NAvMxK+iV8cO+Ck3lBI2GOPZbCEqpPVTYbLUz6sczAlCXwQoPzDIZY
+wYa3eR/gYLY1gP2iEVHORag3bLPap9ZX5E8DZkzTNTjovvLk8KaCmfcaUMJsBtDd
+ApcUitz10cnRyZc1sX3gE1f3DpzQM6t9C5sOVyRhDcSrKqqwb9m0Ss04XAS9FsqM
+P3UWYQyqDXSxlUAYaX892u8mV1hxnt2gjb22RloXMM6TovM3sSrJS0wH+l1nznd6
+aFXftS/G4ZVIVZ/LfT1is4StoyPWZCwwwly1z8qJQ/zhip5NgZTxQw4mi7ww35DY
+PdAQOCoajfSvFjqslQ/cPRi/MRCu079heVb5fQnnzVtnpFQRAgMBAAGjYzBhMB0G
+A1UdDgQWBBRTVTPyS+vQUbHBeJrBKDF77+rtSTAfBgNVHSMEGDAWgBRTVTPyS+vQ
+UbHBeJrBKDF77+rtSTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAN
+BgkqhkiG9w0BAQsFAAOCAgEAPx/IaK94n02wPxpnYTy+LVLIxwdq/kawNd6IbiMz
+L87zmNMDmHcGbfoRCj8OkhuggX9Lx1/CkhpXimuYsZOFQi5blr/u+v4mIbsgbmi9
+7j+cUHDP0zLycvSvxKHty51LwmaX9a4wkJl5zBU4O1sd/H9tWcEmwJ39ltKoBKBx
+c94Zc3iMm5ytRWGj+0rKzLDAXEWpoZ5bE5PLJauA6UDCxDLfs3FwhbS7uDggxYvf
+jySF5FCNET94oJ+m8s7VeHvoa8iPGKvXrIqdd7XDHnqJJlVKr7m9S0fMbyEB8ci2
+RtOXDt93ifY1uhoEtEykn4dqBSp8ezvNMnwoXdYPDvTd9uCAFeWFLVreBAWxd25h
+PsBTkZA5hpa/rA+mKv6Af4VBViYr8cz4dZCsFChuioVebe9ighrfjB//qKepFjPF
+CyjzKN1u0JKm/2x/ORqxkTONG8p3uDwoIOyimUcTtTMv42bfYD88RKakqSFXE9G+
+Z0LlaKABqfjK49o/tsAp+c5LoNlYllKhnetO3QAdraHwdmC36BhoghzR1jpX751A
+cZn2VH3Q4XKyp01cJNCJIrua+A+bx6zh3RyW6zIIkbRCbET+UD+4mr8WIcSE3mtR
+ZVlnhUDO4z9//WKMVzwS9Rh8/kuszrGFI1KQozXCHLrce3YP6RYZfOed79LXaRwX
+dYY=
+-----END CERTIFICATE-----
diff --git a/configs/logging/logback-spring.xml b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml index e4be709..693d8c4 100644 --- a/configs/logging/logback-spring.xml +++ b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml @@ -1,203 +1,203 @@ -<!-- - ============LICENSE_START======================================================= - ONAP - SO - ================================================================================ - Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= ---> -<configuration scan="true" debug="false"> - <contextListener class="org.onap.so.logger.LoggerStartupListener" /> - <include resource="org/springframework/boot/logging/logback/defaults.xml" /> - - <property name="queueSize" value="256" /> - <property name="maxFileSize" value="200MB" /> - <property name="maxHistory" value="30" /> - <property name="totalSizeCap" value="10GB" /> - - <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> - - <property name="currentTimeStamp" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",UTC}" /> - - <property name="errorPattern" - value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode:-500}|%X{ErrorDesc}|%msg%n" /> - - <property name="debugPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%logger{50} - %msg%n" /> - - <property name="auditPattern" - value="%X{EntryTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||%marker|%mdc|||%msg%n" /> - - <property name="metricPattern" - value="%X{InvokeTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|%marker|%mdc|||%msg%n" /> - - <property name="defaultPattern" - value="%nopexception%logger - \t%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} - \t%level - \t%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'} - \t%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'} - \t%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'} - \t%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'} - \t%thread - \t%n" /> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${errorPattern}</pattern> - </encoder> - </appender> - - <appender name="Audit" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> - <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> - <marker>EXIT</marker> - </evaluator> - <onMismatch>DENY</onMismatch> - <onMatch>ACCEPT</onMatch> - </filter> - <file>${logs_dir:-.}/${auditLogName}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${auditPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Audit" /> - </appender> - - <appender name="Metric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> - <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> - <marker>INVOKE-RETURN</marker> - </evaluator> - <onMismatch>DENY</onMismatch> - <onMatch>ACCEPT</onMatch> - </filter> - <file>${logs_dir:-.}/${metricsLogName}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${metricPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Metric" /> - </appender> - - <appender name="Error" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>ERROR</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <file>${logs_dir:-.}/${errorLogName}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${errorPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Error" /> - </appender> - - <appender name="Debug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> - <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> - <marker>INVOKE</marker> - <marker>INVOKE-RETURN</marker> - <marker>ENTRY</marker> - <marker>EXIT</marker> - </evaluator> - <onMismatch>ACCEPT</onMismatch> - <onMatch>DENY</onMatch> - </filter> - <file>${logs_dir:-.}/${debugLogName}.log</file> - <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${debugPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Debug" /> - <includeCallerData>true</includeCallerData> - </appender> - - <!-- Spring related loggers --> - <logger name="org.springframework" level="WARN" /> - <logger name="org.springframework.security.authentication.dao.DaoAuthenticationProvider" level="DEBUG" /> - - <!-- Camunda related loggers --> - <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" /> - <logger name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" level="WARN" /> - - <logger name="org.apache.wire" level="DEBUG" /> - <logger name="org.onap" level="DEBUG" /> - <logger name="com.att.ecomp" level="DEBUG" /> - <logger name="org.apache.cxf.interceptor" level="DEBUG" /> - <logger name="com.att.commons" level="DEBUG" /> - <logger name="org.reflections" level="ERROR" /> - - <logger name="AUDIT" level="INFO" additivity="false"> - <appender-ref ref="asyncAudit" /> - </logger> - - <logger name="METRIC" level="INFO" additivity="false"> - <appender-ref ref="asyncMetric" /> - </logger> - - <root level="INFO"> - <appender-ref ref="asyncDebug" /> - <appender-ref ref="asyncError" /> - <appender-ref ref="asyncAudit" /> - <appender-ref ref="asyncMetric" /> - <appender-ref ref="STDOUT" /> - </root> - +<!--
+ ============LICENSE_START=======================================================
+ ONAP - SO
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+-->
+<configuration scan="true" debug="false">
+ <contextListener class="org.onap.so.logger.LoggerStartupListener" />
+ <include resource="org/springframework/boot/logging/logback/defaults.xml" />
+
+ <property name="queueSize" value="256" />
+ <property name="maxFileSize" value="200MB" />
+ <property name="maxHistory" value="30" />
+ <property name="totalSizeCap" value="10GB" />
+
+ <!-- log file names -->
+ <property name="errorLogName" value="error" />
+ <property name="metricsLogName" value="metrics" />
+ <property name="auditLogName" value="audit" />
+ <property name="debugLogName" value="debug" />
+
+ <property name="currentTimeStamp" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",UTC}" />
+
+ <property name="errorPattern"
+ value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode:-500}|%X{ErrorDesc}|%msg%n" />
+
+ <property name="debugPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%logger{50} - %msg%n" />
+
+ <property name="auditPattern"
+ value="%X{EntryTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||%marker|%mdc|||%msg%n" />
+
+ <property name="metricPattern"
+ value="%X{InvokeTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|%marker|%mdc|||%msg%n" />
+
+ <property name="defaultPattern"
+ value="%nopexception%logger
+ \t%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}
+ \t%level
+ \t%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'}
+ \t%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}
+ \t%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'}
+ \t%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}
+ \t%thread
+ \t%n" />
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="Audit" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>EXIT</marker>
+ </evaluator>
+ <onMismatch>DENY</onMismatch>
+ <onMatch>ACCEPT</onMatch>
+ </filter>
+ <file>${logs_dir:-.}/${auditLogName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>${maxFileSize}</maxFileSize>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${auditPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="Audit" />
+ </appender>
+
+ <appender name="Metric" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>INVOKE-RETURN</marker>
+ </evaluator>
+ <onMismatch>DENY</onMismatch>
+ <onMatch>ACCEPT</onMatch>
+ </filter>
+ <file>${logs_dir:-.}/${metricsLogName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>${maxFileSize}</maxFileSize>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
+ </encoder>
+ </appender>
+
+
+ <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="Metric" />
+ </appender>
+
+ <appender name="Error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>ERROR</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <file>${logs_dir:-.}/${errorLogName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>${maxFileSize}</maxFileSize>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="Error" />
+ </appender>
+
+ <appender name="Debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+ <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
+ <marker>INVOKE</marker>
+ <marker>INVOKE-RETURN</marker>
+ <marker>ENTRY</marker>
+ <marker>EXIT</marker>
+ </evaluator>
+ <onMismatch>ACCEPT</onMismatch>
+ <onMatch>DENY</onMatch>
+ </filter>
+ <file>${logs_dir:-.}/${debugLogName}.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>${maxFileSize}</maxFileSize>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="Debug" />
+ <includeCallerData>true</includeCallerData>
+ </appender>
+
+ <!-- Spring related loggers -->
+ <logger name="org.springframework" level="WARN" />
+ <logger name="org.springframework.security.authentication.dao.DaoAuthenticationProvider" level="DEBUG" />
+
+ <!-- Camunda related loggers -->
+ <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" />
+ <logger name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" level="WARN" />
+
+ <logger name="org.apache.wire" level="DEBUG" />
+ <logger name="org.onap" level="DEBUG" />
+ <logger name="com.att.ecomp" level="DEBUG" />
+ <logger name="org.apache.cxf.interceptor" level="DEBUG" />
+ <logger name="com.att.commons" level="DEBUG" />
+ <logger name="org.reflections" level="ERROR" />
+
+ <logger name="AUDIT" level="INFO" additivity="false">
+ <appender-ref ref="asyncAudit" />
+ </logger>
+
+ <logger name="METRIC" level="INFO" additivity="false">
+ <appender-ref ref="asyncMetric" />
+ </logger>
+
+ <root level="INFO">
+ <appender-ref ref="asyncDebug" />
+ <appender-ref ref="asyncError" />
+ <appender-ref ref="asyncAudit" />
+ <appender-ref ref="asyncMetric" />
+ <appender-ref ref="STDOUT" />
+ </root>
+
</configuration>
\ No newline at end of file diff --git a/scripts/.gitattributes b/packages/docker/src/main/docker/docker-files/scripts/.gitattributes index b905d1d..b905d1d 100644 --- a/scripts/.gitattributes +++ b/packages/docker/src/main/docker/docker-files/scripts/.gitattributes diff --git a/scripts/start-app.sh b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh index 54ed9ed..54ed9ed 100755..100644 --- a/scripts/start-app.sh +++ b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh diff --git a/scripts/wait-for.sh b/packages/docker/src/main/docker/docker-files/scripts/wait-for.sh index 2525821..2525821 100755..100644 --- a/scripts/wait-for.sh +++ b/packages/docker/src/main/docker/docker-files/scripts/wait-for.sh diff --git a/packages/pom.xml b/packages/pom.xml new file mode 100644 index 0000000..83ed04d --- /dev/null +++ b/packages/pom.xml @@ -0,0 +1,35 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.adapters.so-nssmf-adapter</groupId>
+ <artifactId>so-nssmf-adapter</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>packages</artifactId>
+ <packaging>pom</packaging>
+ <version>1.8.0-SNAPSHOT</version>
+ <name>SO NSSMF Adapter Packages</name>
+
+ <profiles>
+ <!-- DO NOT CHANGE THE *ORDER* IN WHICH THESE PROFILES ARE DEFINED! -->
+
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ </profile>
+
+ <!-- Those profile are exclusive, choose docker or with-integration-tests -->
+ <profile>
+ <id>docker</id>
+ <modules>
+ <module>docker</module>
+ </modules>
+ <properties>
+ <docker.skip.push>false</docker.skip.push>
+ </properties>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file diff --git a/pom-format.properties b/pom-format.properties index 4452c2a..0831416 100755 --- a/pom-format.properties +++ b/pom-format.properties @@ -1,5 +1,5 @@ -maxLineLength=120 -wrapLongLines=true -tabInsteadOfSpaces=false -tabWidth=2 +maxLineLength=120
+wrapLongLines=true
+tabInsteadOfSpaces=false
+tabWidth=2
splitMultiAttrs=false
\ No newline at end of file @@ -1,263 +1,112 @@ -<!-- - ~* - ~============LICENSE_START======================================================= - ~* ONAP - SO - ~*================================================================================ - ~* Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - ~*================================================================================ - ~* Licensed under the Apache License, Version 2.0 (the "License"); - ~* you may not use this file except in compliance with the License. - ~* You may obtain a copy of the License at - ~* - ~* http://www.apache.org/licenses/LICENSE-2.0 - ~* - ~* Unless required by applicable law or agreed to in writing, software - ~* distributed under the License is distributed on an "AS IS" BASIS, - ~* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~* See the License for the specific language governing permissions and - ~* limitations under the License. - ~* ============LICENSE_END========================================================= - ~*/ - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.so</groupId> - <artifactId>adapters</artifactId> - <version>1.8.0-SNAPSHOT</version> - </parent> - <groupId>org.onap.so.adapters</groupId> - <artifactId>so-nssmf-adapter</artifactId> - <packaging>jar</packaging> - <name>so-nssmf-adapter</name> - <description>Web service endpoint for nssmf operations</description> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-dependencies</artifactId> - <version>${springboot.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <build> - <finalName>${project.artifactId}-${project.version}</finalName> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <mainClass>org.onap.so.adapters.nssmf.MSONssmfApplication</mainClass> - </configuration> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>net.revelc.code.formatter</groupId> - <artifactId>formatter-maven-plugin</artifactId> - <version>2.9.0</version> - <executions> - <execution> - <id>format-java</id> - <goals> - <goal>format</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <skip>${format.skipExecute}</skip> - <configFile>${project.basedir}/onap-eclipse-format.xml</configFile> - </configuration> - </execution> - <execution> - <id>format-xml</id> - <goals> - <goal>format</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <skip>${format.skipExecute}</skip> - <sourceDirectory>${project.basedir}</sourceDirectory> - <configXmlFile>${project.basedir}/pom-format.properties</configXmlFile> - <includes> - <include>pom.xml</include> - </includes> - </configuration> - </execution> - <execution> - <id>validate-java</id> - <goals> - <goal>validate</goal> - </goals> - <configuration> - <skip>${format.skipValidate}</skip> - <configFile>${project.basedir}/onap-eclipse-format.xml</configFile> - </configuration> - </execution> - <execution> - <id>validate-poms</id> - <goals> - <goal>validate</goal> - </goals> - <configuration> - <skip>${format.skipValidate}</skip> - <configFile>${project.basedir}/pom-format.properties</configFile> - <includes> - <include>pom.xml</include> - </includes> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-annotations</artifactId> - <version>2.9.8</version> - </dependency> - </dependencies> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.6.0</version> - <executions> - <execution> - <id>docker-build</id> - <phase>install</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <dockerFile>Dockerfile</dockerFile> - <executable>docker</executable> - <workingDirectory>${project.basedir}</workingDirectory> - <arguments> - <argument>build</argument> - <argument>-t</argument> - <argument>${project.artifactId}:${project.version}</argument> - <argument>.</argument> - </arguments> - <buildArgs> - <JAR_FILE>${project.artifactId}-${project.version}.jar</JAR_FILE> - <ARTIFACT_ID>${project.artifactId}</ARTIFACT_ID> - </buildArgs> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - <excludes> - <exclude>**/*.p12</exclude> - <exclude>**/*.jks</exclude> - </excludes> - </resource> - <resource> - <directory>src/main/resources</directory> - <filtering>false</filtering> - <includes> - <include>**/*.p12</include> - <include>**/*.jks</include> - </includes> - </resource> - </resources> - </build> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-jdbc</artifactId> - <exclusions> - <exclusion> - <groupId>org.apache.tomcat</groupId> - <artifactId>tomcat-jdbc</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-data-jpa</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.so</groupId> - <artifactId>mso-requests-db</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.so</groupId> - <artifactId>mso-requests-db-repositories</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.mariadb.jdbc</groupId> - <artifactId>mariadb-java-client</artifactId> - </dependency> - <dependency> - <groupId>ch.vorburger.mariaDB4j</groupId> - <artifactId>mariaDB4j</artifactId> - <version>2.2.3</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-configuration-processor</artifactId> - <optional>true</optional> - </dependency> - <dependency> - <groupId>com.squareup.okhttp3</groupId> - <artifactId>okhttp</artifactId> - <version>3.14.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </dependency> - </dependencies> -</project> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so</groupId>
+ <artifactId>so</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.so.adapters.so-nssmf-adapter</groupId>
+ <artifactId>so-nssmf-adapter</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <name>SO NSSMF Adapter</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <java.version>11</java.version>
+ <version.java.compiler>11</version.java.compiler>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <version-swagger-codegen>2.3.1</version-swagger-codegen>
+ <gson-fire-version>1.8.2</gson-fire-version>
+ <retrofit-version>2.7.2</retrofit-version>
+ <threetenbp-version>1.3.5</threetenbp-version>
+ <oltu-version>1.0.1</oltu-version>
+ <swagger-core-version>1.5.21</swagger-core-version>
+ <okhttp3-version>3.14.0</okhttp3-version>
+ <okhttp-version>2.7.5</okhttp-version>
+ <okio-version>1.13.0</okio-version>
+ <spring-security-oauth2-version>2.3.6.RELEASE</spring-security-oauth2-version>
+ <jaxb-api>2.3.0</jaxb-api>
+ <snakeyaml-version>0.11</snakeyaml-version>
+ <hamcrest-version>2.2</hamcrest-version>
+ <equalsverifier-version>3.4.1</equalsverifier-version>
+ <so-core-version>1.8.0-SNAPSHOT</so-core-version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${version.java.compiler}</source>
+ <target>${version.java.compiler}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>net.revelc.code.formatter</groupId>
+ <artifactId>formatter-maven-plugin</artifactId>
+ <version>2.9.0</version>
+ <executions>
+ <execution>
+ <id>format-java</id>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>format-xml</id>
+ <goals>
+ <goal>format</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <skip>true</skip>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>validate-java</id>
+ <goals>
+ <goal>validate</goal>
+ </goals>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>validate-poms</id>
+ <goals>
+ <goal>validate</goal>
+ </goals>
+ <configuration>
+ <skip>true</skip>
+ <includes>
+ <include>pom.xml</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>so-nssmf-adapter-application</module>
+ <module>packages</module>
+ </modules>
+</project>
diff --git a/so-nssmf-adapter-application/pom.xml b/so-nssmf-adapter-application/pom.xml new file mode 100755 index 0000000..f380946 --- /dev/null +++ b/so-nssmf-adapter-application/pom.xml @@ -0,0 +1,179 @@ +<!-- + ~* + ~============LICENSE_START======================================================= + ~* ONAP - SO + ~*================================================================================ + ~* Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + ~*================================================================================ + ~* Licensed under the Apache License, Version 2.0 (the "License"); + ~* you may not use this file except in compliance with the License. + ~* You may obtain a copy of the License at + ~* + ~* http://www.apache.org/licenses/LICENSE-2.0 + ~* + ~* Unless required by applicable law or agreed to in writing, software + ~* distributed under the License is distributed on an "AS IS" BASIS, + ~* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~* See the License for the specific language governing permissions and + ~* limitations under the License. + ~* ============LICENSE_END========================================================= + ~*/ + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters.so-nssmf-adapter</groupId> + <artifactId>so-nssmf-adapter</artifactId> + <version>1.8.0-SNAPSHOT</version> + </parent> + <artifactId>so-nssmf-adapter-application</artifactId> + <version>1.8.0-SNAPSHOT</version> + <name>SO NSSMF Application Jar</name> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <mainClass>org.onap.so.adapters.nssmf.MSONssmfApplication</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>original</id> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <so.log.level>DEBUG</so.log.level> + </systemPropertyVariables> + <rerunFailingTestsCount>2</rerunFailingTestsCount> + <parallel>suites</parallel> + <useUnlimitedThreads>false</useUnlimitedThreads> + <threadCount>1</threadCount> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <excludes> + <exclude>**/*.p12</exclude> + <exclude>**/*.jks</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>**/*.p12</include> + <include>**/*.jks</include> + </includes> + </resource> + </resources> + </build> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-jdbc</artifactId> + <exclusions> + <exclusion> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-jdbc</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.9.8</version> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-spring-boot-starter-jaxws</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-service-description-swagger</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>mso-requests-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>mso-requests-db-repositories</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <version>2.2.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-configuration-processor</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>okhttp</artifactId> + <version>3.14.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> + </dependencies> +</project> diff --git a/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java index 83a09dc..ff71837 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/MSONssmfApplication.java @@ -1,33 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf; - - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication(scanBasePackages = {"org.onap.so"}) -public class MSONssmfApplication { - - public static void main(String... args) { - SpringApplication.run(MSONssmfApplication.class, args); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf;
+
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+public class MSONssmfApplication {
+
+ public static void main(String... args) {
+ SpringApplication.run(MSONssmfApplication.class, args);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java index 44f814a..506ef3c 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/annotation/RequestLogger.java @@ -1,31 +1,31 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.annotation; - - -import java.lang.annotation.*; - -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface RequestLogger { - boolean ignore() default false; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.annotation;
+
+
+import java.lang.annotation.*;
+
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface RequestLogger {
+ boolean ignore() default false;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java index 1de29bc..806c5b3 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/annotation/ServiceLogger.java @@ -1,36 +1,36 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.annotation; - - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface ServiceLogger { - - String value() default ""; - - boolean ignore() default false; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.annotation;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ServiceLogger {
+
+ String value() default "";
+
+ boolean ignore() default false;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java index 6a59244..85e79ad 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/config/NssmfAdapterConfig.java @@ -1,36 +1,36 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.config; - -import lombok.Getter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -@Configuration -@Getter -public class NssmfAdapterConfig { - - @Value("${mso.infra.endpoint}") - private String infraEndpoint; - - @Value("${mso.infra.auth}") - private String infraAuth; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.config;
+
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@Getter
+public class NssmfAdapterConfig {
+
+ @Value("${mso.infra.endpoint}")
+ private String infraEndpoint;
+
+ @Value("${mso.infra.auth}")
+ private String infraAuth;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java index dcb5d61..171cdab 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/config/RequestDbConfig.java @@ -1,68 +1,68 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.config; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Profile({"!test"}) -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory", - transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"}) -public class RequestDbConfig { - - @Primary - @Bean(name = "requestDataSource") - @ConfigurationProperties(prefix = "spring.datasource") - public DataSource dataSource() { - return DataSourceBuilder.create().build(); - } - - @Primary - @Bean(name = "requestEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, - @Qualifier("requestDataSource") DataSource dataSource) { - return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB") - .build(); - } - - @Primary - @Bean(name = "requestTransactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) { - return new JpaTransactionManager(entityManagerFactory); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.config;
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Profile({"!test"})
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
+public class RequestDbConfig {
+
+ @Primary
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+ @Primary
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java index 8f029e7..98a5a19 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java @@ -1,186 +1,186 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.consts; - -import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.enums.ExecutorType; -import org.onap.so.adapters.nssmf.enums.HttpMethod; -import org.onap.so.beans.nsmf.NetworkType; -import java.util.HashMap; -import java.util.Map; - -public class NssmfAdapterConsts { - - public final static String ONAP_INTERNAL_TAG = "ONAP_internal"; - - public final static String CURRENT_INTERNAL_NSSMF_API_VERSION = "v1"; - - private static Map<String, NssmfUrlInfo> urlInfoMap = new HashMap<>(); - - private final static String EXTERNAL_CN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles"; - - private final static String EXTERNAL_TN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles"; - - private final static String EXTERNAL_AN_ALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles"; - - private final static String INTERNAL_ALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/allocate"; - - private final static String EXTERNAL_CN_DEALLOCATE_URL = - "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{sliceProfileId}"; - - private final static String EXTERNAL_TN_DEALLOCATE_URL = - "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{sliceProfileId}"; - - private final static String EXTERNAL_AN_DEALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles/{sliceProfileId}"; - - private final static String INTERNAL_DEALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deAllocate"; - - private final static String EXTERNAL_CN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/activation"; - - private final static String EXTERNAL_TN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/activation"; - - private final static String EXTERNAL_AN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/activations"; - - private final static String INTERNAL_ACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/activate"; - - private final static String EXTERNAL_CN_DEACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/deactivation"; - - private final static String EXTERNAL_TN_DEACTIVATE_URL = - "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/deactivation"; - - private final static String EXTERNAL_AN_DEACTIVATE_URL = - "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/deactivation"; - - private final static String INTERNAL_DEACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deActivate"; - - // - private final static String EXTERNAL_CN_TERMINATE_URL = - "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{SliceProfileId}"; - - private final static String EXTERNAL_TN_TERMINATE_URL = - "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{SliceProfileId}"; - - private final static String EXTERNAL_AN_TERMINATE_URL = - "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}"; - - private final static String INTERNAL_TERMINATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/terminate"; - - // - private final static String EXTERNAL_AN_MODIFY_URL = - "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}"; - - private final static String INTERNAL_MODIFY_URL = "/onap/so/infra/3gppservices/{apiVersion}/modify"; - - // - private final static String EXTERNAL_QUERY_JOB_STATUS = "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}"; - - private final static String INTERNAL_QUERY_SUB_NET_CAPABILITY = - "/onap/so/infra/3gppservices/{apiVersion}/subnetCapabilityQuery"; - - static { - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ALLOCATE), - new NssmfUrlInfo(EXTERNAL_AN_ALLOCATE_URL, HttpMethod.POST)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ALLOCATE), - new NssmfUrlInfo(EXTERNAL_TN_ALLOCATE_URL, HttpMethod.POST)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ALLOCATE), - new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.POST)); - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ALLOCATE), - new NssmfUrlInfo(INTERNAL_ALLOCATE_URL, HttpMethod.POST)); - - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEALLOCATE), - new NssmfUrlInfo(EXTERNAL_AN_DEALLOCATE_URL, HttpMethod.DELETE)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEALLOCATE), - new NssmfUrlInfo(EXTERNAL_TN_DEALLOCATE_URL, HttpMethod.DELETE)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEALLOCATE), - new NssmfUrlInfo(EXTERNAL_CN_DEALLOCATE_URL, HttpMethod.DELETE)); - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEALLOCATE), - new NssmfUrlInfo(INTERNAL_DEALLOCATE_URL, HttpMethod.DELETE)); - - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ACTIVATE), - new NssmfUrlInfo(EXTERNAL_AN_ACTIVATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ACTIVATE), - new NssmfUrlInfo(EXTERNAL_TN_ACTIVATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ACTIVATE), - new NssmfUrlInfo(EXTERNAL_CN_ACTIVATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ACTIVATE), - new NssmfUrlInfo(INTERNAL_ACTIVATE_URL, HttpMethod.POST)); - - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEACTIVATE), - new NssmfUrlInfo(EXTERNAL_AN_DEACTIVATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEACTIVATE), - new NssmfUrlInfo(EXTERNAL_TN_DEACTIVATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEACTIVATE), - new NssmfUrlInfo(EXTERNAL_CN_DEACTIVATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEACTIVATE), - new NssmfUrlInfo(INTERNAL_DEACTIVATE_URL, HttpMethod.PUT)); - - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.TERMINATE), - new NssmfUrlInfo(EXTERNAL_AN_TERMINATE_URL, HttpMethod.DELETE)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.TERMINATE), - new NssmfUrlInfo(EXTERNAL_TN_TERMINATE_URL, HttpMethod.DELETE)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.TERMINATE), - new NssmfUrlInfo(EXTERNAL_CN_TERMINATE_URL, HttpMethod.DELETE)); - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.TERMINATE), - new NssmfUrlInfo(INTERNAL_TERMINATE_URL, HttpMethod.DELETE)); - - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.MODIFY), - new NssmfUrlInfo(EXTERNAL_AN_MODIFY_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.MODIFY), - new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.PUT)); - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.MODIFY), - new NssmfUrlInfo(INTERNAL_MODIFY_URL, HttpMethod.PUT)); - - - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.QUERY_JOB_STATUS), - new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.QUERY_JOB_STATUS), - new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); - urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.QUERY_JOB_STATUS), - new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET)); - - urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.QUERY_SUB_NET_CAPABILITY), - new NssmfUrlInfo(INTERNAL_QUERY_SUB_NET_CAPABILITY, HttpMethod.GET)); - } - - /** - * get nssmf url info from consts - * - * @param executorType {@link ExecutorType} - * @param networkType {@link NetworkType} - * @param actionType {@link ActionType} - * @return {@link NssmfUrlInfo} - */ - public static NssmfUrlInfo getNssmfUrlInfo(ExecutorType executorType, NetworkType networkType, - ActionType actionType) { - - return urlInfoMap.get(generateKey(executorType, networkType, actionType)); - } - - private static String generateKey(ExecutorType executorType, NetworkType networkType, ActionType actionType) { - if (ExecutorType.EXTERNAL.equals(executorType)) { - return executorType.name() + "_" + networkType.name() + "_" + actionType.name(); - } - return executorType.name() + "_" + actionType.name(); - } - - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.consts;
+
+import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.ExecutorType;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.beans.nsmf.NetworkType;
+import java.util.HashMap;
+import java.util.Map;
+
+public class NssmfAdapterConsts {
+
+ public final static String ONAP_INTERNAL_TAG = "ONAP_internal";
+
+ public final static String CURRENT_INTERNAL_NSSMF_API_VERSION = "v1";
+
+ private static Map<String, NssmfUrlInfo> urlInfoMap = new HashMap<>();
+
+ private final static String EXTERNAL_CN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles";
+
+ private final static String EXTERNAL_TN_ALLOCATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles";
+
+ private final static String EXTERNAL_AN_ALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles";
+
+ private final static String INTERNAL_ALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/allocate";
+
+ private final static String EXTERNAL_CN_DEALLOCATE_URL =
+ "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{sliceProfileId}";
+
+ private final static String EXTERNAL_TN_DEALLOCATE_URL =
+ "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{sliceProfileId}";
+
+ private final static String EXTERNAL_AN_DEALLOCATE_URL = "/ObjectManagement/NSS/SliceProfiles/{sliceProfileId}";
+
+ private final static String INTERNAL_DEALLOCATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deAllocate";
+
+ private final static String EXTERNAL_CN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/activation";
+
+ private final static String EXTERNAL_TN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/activation";
+
+ private final static String EXTERNAL_AN_ACTIVATE_URL = "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/activations";
+
+ private final static String INTERNAL_ACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/activate";
+
+ private final static String EXTERNAL_CN_DEACTIVATE_URL = "/api/rest/provMns/{apiVersion}/NSS/{snssai}/deactivation";
+
+ private final static String EXTERNAL_TN_DEACTIVATE_URL =
+ "/api/rest/provMns/{apiVersion}/tn/NSS/{snssai}/deactivation";
+
+ private final static String EXTERNAL_AN_DEACTIVATE_URL =
+ "/api/rest/provMns/{apiVersion}/an/NSS/{snssai}/deactivation";
+
+ private final static String INTERNAL_DEACTIVATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/deActivate";
+
+ //
+ private final static String EXTERNAL_CN_TERMINATE_URL =
+ "/api/rest/provMns/{apiVersion}/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String EXTERNAL_TN_TERMINATE_URL =
+ "/api/rest/provMns/{apiVersion}/tn/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String EXTERNAL_AN_TERMINATE_URL =
+ "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String INTERNAL_TERMINATE_URL = "/onap/so/infra/3gppservices/{apiVersion}/terminate";
+
+ //
+ private final static String EXTERNAL_AN_MODIFY_URL =
+ "/api/rest/provMns/{apiVersion}/an/NSS/SliceProfiles/{SliceProfileId}";
+
+ private final static String INTERNAL_MODIFY_URL = "/onap/so/infra/3gppservices/{apiVersion}/modify";
+
+ //
+ private final static String EXTERNAL_QUERY_JOB_STATUS = "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}";
+
+ private final static String INTERNAL_QUERY_SUB_NET_CAPABILITY =
+ "/onap/so/infra/3gppservices/{apiVersion}/subnetCapabilityQuery";
+
+ static {
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_AN_ALLOCATE_URL, HttpMethod.POST));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_TN_ALLOCATE_URL, HttpMethod.POST));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.POST));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ALLOCATE),
+ new NssmfUrlInfo(INTERNAL_ALLOCATE_URL, HttpMethod.POST));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_AN_DEALLOCATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_TN_DEALLOCATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(EXTERNAL_CN_DEALLOCATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEALLOCATE),
+ new NssmfUrlInfo(INTERNAL_DEALLOCATE_URL, HttpMethod.DELETE));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.ACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_AN_ACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.ACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_TN_ACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.ACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_CN_ACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.ACTIVATE),
+ new NssmfUrlInfo(INTERNAL_ACTIVATE_URL, HttpMethod.POST));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_AN_DEACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_TN_DEACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(EXTERNAL_CN_DEACTIVATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.DEACTIVATE),
+ new NssmfUrlInfo(INTERNAL_DEACTIVATE_URL, HttpMethod.PUT));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.TERMINATE),
+ new NssmfUrlInfo(EXTERNAL_AN_TERMINATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.TERMINATE),
+ new NssmfUrlInfo(EXTERNAL_TN_TERMINATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.TERMINATE),
+ new NssmfUrlInfo(EXTERNAL_CN_TERMINATE_URL, HttpMethod.DELETE));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.TERMINATE),
+ new NssmfUrlInfo(INTERNAL_TERMINATE_URL, HttpMethod.DELETE));
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.MODIFY),
+ new NssmfUrlInfo(EXTERNAL_AN_MODIFY_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.MODIFY),
+ new NssmfUrlInfo(EXTERNAL_CN_ALLOCATE_URL, HttpMethod.PUT));
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.MODIFY),
+ new NssmfUrlInfo(INTERNAL_MODIFY_URL, HttpMethod.PUT));
+
+
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.CORE, ActionType.QUERY_JOB_STATUS),
+ new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.ACCESS, ActionType.QUERY_JOB_STATUS),
+ new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET));
+ urlInfoMap.put(generateKey(ExecutorType.EXTERNAL, NetworkType.TRANSPORT, ActionType.QUERY_JOB_STATUS),
+ new NssmfUrlInfo(EXTERNAL_QUERY_JOB_STATUS, HttpMethod.GET));
+
+ urlInfoMap.put(generateKey(ExecutorType.INTERNAL, null, ActionType.QUERY_SUB_NET_CAPABILITY),
+ new NssmfUrlInfo(INTERNAL_QUERY_SUB_NET_CAPABILITY, HttpMethod.GET));
+ }
+
+ /**
+ * get nssmf url info from consts
+ *
+ * @param executorType {@link ExecutorType}
+ * @param networkType {@link NetworkType}
+ * @param actionType {@link ActionType}
+ * @return {@link NssmfUrlInfo}
+ */
+ public static NssmfUrlInfo getNssmfUrlInfo(ExecutorType executorType, NetworkType networkType,
+ ActionType actionType) {
+
+ return urlInfoMap.get(generateKey(executorType, networkType, actionType));
+ }
+
+ private static String generateKey(ExecutorType executorType, NetworkType networkType, ActionType actionType) {
+ if (ExecutorType.EXTERNAL.equals(executorType)) {
+ return executorType.name() + "_" + networkType.name() + "_" + actionType.name();
+ }
+ return executorType.name() + "_" + actionType.name();
+ }
+
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java index 3732e2c..ded0d17 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterController.java @@ -1,59 +1,59 @@ -package org.onap.so.adapters.nssmf.controller; - -import org.onap.so.adapters.nssmf.annotation.RequestLogger; -import org.onap.so.adapters.nssmf.service.NssmfManagerService; -import org.onap.so.beans.nsmf.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; - -@RestController -@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON}) -@RequestLogger -public class NssmfAdapterController { - - @Autowired - private NssmfManagerService nssmfManagerService; - - @PostMapping(value = "/NSS/SliceProfiles") - public ResponseEntity allocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest) { - return nssmfManagerService.allocateNssi(nbiRequest); - } - - @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}") - public ResponseEntity deAllocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest, - @PathVariable("sliceProfileId") final String sliceProfileId) { - return nssmfManagerService.deAllocateNssi(nbiRequest, sliceProfileId); - } - - - @PostMapping(value = "/NSS/{snssai}/activation") - public ResponseEntity activateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest, - @PathVariable("snssai") String snssai) { - return nssmfManagerService.activateNssi(nbiRequest, snssai); - } - - @PostMapping(value = "/NSS/{snssai}/deactivation") - public ResponseEntity deactivateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest, - @PathVariable("snssai") String snssai) { - return nssmfManagerService.deActivateNssi(nbiRequest, snssai); - } - - @PostMapping(value = "/NSS/jobs/{jobId}") - public ResponseEntity queryJobStatus(@RequestBody NssmfAdapterNBIRequest nbiRequest, - @PathVariable("jobId") String jobId) { - return nssmfManagerService.queryJobStatus(nbiRequest, jobId); - } - - @PostMapping(value = "/NSS/NSSISelectionCapability") - public ResponseEntity queryNSSISelectionCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) { - return nssmfManagerService.queryNSSISelectionCapability(nbiRequest); - } - - @PostMapping(value = "/NSS/subnetCapabilityQuery") - public ResponseEntity querySubnetCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) { - return nssmfManagerService.querySubnetCapability(nbiRequest); - } - -} +package org.onap.so.adapters.nssmf.controller;
+
+import org.onap.so.adapters.nssmf.annotation.RequestLogger;
+import org.onap.so.adapters.nssmf.service.NssmfManagerService;
+import org.onap.so.beans.nsmf.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+@RestController
+@RequestMapping(value = "/api/rest/provMns/v1", produces = {APPLICATION_JSON}, consumes = {APPLICATION_JSON})
+@RequestLogger
+public class NssmfAdapterController {
+
+ @Autowired
+ private NssmfManagerService nssmfManagerService;
+
+ @PostMapping(value = "/NSS/SliceProfiles")
+ public ResponseEntity allocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest) {
+ return nssmfManagerService.allocateNssi(nbiRequest);
+ }
+
+ @PostMapping(value = "/NSS/SliceProfiles/{sliceProfileId}")
+ public ResponseEntity deAllocateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("sliceProfileId") final String sliceProfileId) {
+ return nssmfManagerService.deAllocateNssi(nbiRequest, sliceProfileId);
+ }
+
+
+ @PostMapping(value = "/NSS/{snssai}/activation")
+ public ResponseEntity activateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("snssai") String snssai) {
+ return nssmfManagerService.activateNssi(nbiRequest, snssai);
+ }
+
+ @PostMapping(value = "/NSS/{snssai}/deactivation")
+ public ResponseEntity deactivateNssi(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("snssai") String snssai) {
+ return nssmfManagerService.deActivateNssi(nbiRequest, snssai);
+ }
+
+ @PostMapping(value = "/NSS/jobs/{jobId}")
+ public ResponseEntity queryJobStatus(@RequestBody NssmfAdapterNBIRequest nbiRequest,
+ @PathVariable("jobId") String jobId) {
+ return nssmfManagerService.queryJobStatus(nbiRequest, jobId);
+ }
+
+ @PostMapping(value = "/NSS/NSSISelectionCapability")
+ public ResponseEntity queryNSSISelectionCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) {
+ return nssmfManagerService.queryNSSISelectionCapability(nbiRequest);
+ }
+
+ @PostMapping(value = "/NSS/subnetCapabilityQuery")
+ public ResponseEntity querySubnetCapability(@RequestBody NssmfAdapterNBIRequest nbiRequest) {
+ return nssmfManagerService.querySubnetCapability(nbiRequest);
+ }
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java index a8653f8..cdd2ff8 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/ErrorResponse.java @@ -1,63 +1,63 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.entity; - -public class ErrorResponse { - - private int status; - - private String error; - - private String message; - - public ErrorResponse(int status, String message) { - this.status = status; - this.message = message; - this.error = "Bad Request"; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - public String getError() { - if (status == 500) { - this.error = "Internal Server Error"; - } - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.entity;
+
+public class ErrorResponse {
+
+ private int status;
+
+ private String error;
+
+ private String message;
+
+ public ErrorResponse(int status, String message) {
+ this.status = status;
+ this.message = message;
+ this.error = "Bad Request";
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getError() {
+ if (status == 500) {
+ this.error = "Internal Server Error";
+ }
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java index af26264..5cd08e0 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfInfo.java @@ -1,41 +1,41 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.entity; - -import lombok.Data; - -@Data -public class NssmfInfo { - - private String url; - - private String ipAddress; - - private String port; - - private String insecure; - - private String cacert; - - private String userName; - - private String password; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.entity;
+
+import lombok.Data;
+
+@Data
+public class NssmfInfo {
+
+ private String url;
+
+ private String ipAddress;
+
+ private String port;
+
+ private String insecure;
+
+ private String cacert;
+
+ private String userName;
+
+ private String password;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java index f55ff10..e9cce84 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/NssmfUrlInfo.java @@ -1,17 +1,17 @@ -package org.onap.so.adapters.nssmf.entity; - -import lombok.Data; -import org.onap.so.adapters.nssmf.enums.HttpMethod; - -@Data -public class NssmfUrlInfo { - - private String url; - - private HttpMethod httpMethod; - - public NssmfUrlInfo(String url, HttpMethod httpMethod) { - this.url = url; - this.httpMethod = httpMethod; - } -} +package org.onap.so.adapters.nssmf.entity;
+
+import lombok.Data;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+
+@Data
+public class NssmfUrlInfo {
+
+ private String url;
+
+ private HttpMethod httpMethod;
+
+ public NssmfUrlInfo(String url, HttpMethod httpMethod) {
+ this.url = url;
+ this.httpMethod = httpMethod;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java index 218867c..9f20f32 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/RestResponse.java @@ -1,92 +1,92 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.entity; - -import java.util.Map; - -public class RestResponse { - - // the response content - private String responseContent; - - // the response status - private int status; - - // the response header - private Map<String, String> respHeaderMap; - - public RestResponse() { - this.status = -1; - - this.respHeaderMap = null; - } - - public int getStatus() { - return this.status; - } - - public void setStatus(int status) { - this.status = status; - } - - public Map<String, String> getRespHeaderMap() { - return this.respHeaderMap; - } - - public void setRespHeaderMap(Map<String, String> header) { - this.respHeaderMap = header; - } - - public int getRespHeaderInt(String key) { - if (this.respHeaderMap != null) { - String result = this.respHeaderMap.get(key); - if (result != null) { - return Integer.parseInt(result); - } - } - return -1; - } - - public long getRespHeaderLong(String key) { - if (this.respHeaderMap != null) { - String result = this.respHeaderMap.get(key); - if (result != null) { - return Long.parseLong(result); - } - } - return -1L; - } - - public String getRespHeaderStr(String key) { - if (this.respHeaderMap != null) { - return this.respHeaderMap.get(key); - } - return null; - } - - public String getResponseContent() { - return this.responseContent; - } - - public void setResponseContent(String responseString) { - this.responseContent = responseString; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.entity;
+
+import java.util.Map;
+
+public class RestResponse {
+
+ // the response content
+ private String responseContent;
+
+ // the response status
+ private int status;
+
+ // the response header
+ private Map<String, String> respHeaderMap;
+
+ public RestResponse() {
+ this.status = -1;
+
+ this.respHeaderMap = null;
+ }
+
+ public int getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public Map<String, String> getRespHeaderMap() {
+ return this.respHeaderMap;
+ }
+
+ public void setRespHeaderMap(Map<String, String> header) {
+ this.respHeaderMap = header;
+ }
+
+ public int getRespHeaderInt(String key) {
+ if (this.respHeaderMap != null) {
+ String result = this.respHeaderMap.get(key);
+ if (result != null) {
+ return Integer.parseInt(result);
+ }
+ }
+ return -1;
+ }
+
+ public long getRespHeaderLong(String key) {
+ if (this.respHeaderMap != null) {
+ String result = this.respHeaderMap.get(key);
+ if (result != null) {
+ return Long.parseLong(result);
+ }
+ }
+ return -1L;
+ }
+
+ public String getRespHeaderStr(String key) {
+ if (this.respHeaderMap != null) {
+ return this.respHeaderMap.get(key);
+ }
+ return null;
+ }
+
+ public String getResponseContent() {
+ return this.responseContent;
+ }
+
+ public void setResponseContent(String responseString) {
+ this.responseContent = responseString;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java index bfcb875..d13dad7 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/TokenRequest.java @@ -1,33 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.entity; - -import lombok.Data; - -@Data -public class TokenRequest { - - private String grantType; - - private String userName; - - private String value; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.entity;
+
+import lombok.Data;
+
+@Data
+public class TokenRequest {
+
+ private String grantType;
+
+ private String userName;
+
+ private String value;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java index 552612a..7111639 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/entity/TokenResponse.java @@ -1,32 +1,32 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.entity; - - -import lombok.Data; - -@Data -public class TokenResponse { - - private String accessToken; - - private int expires; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.entity;
+
+
+import lombok.Data;
+
+@Data
+public class TokenResponse {
+
+ private String accessToken;
+
+ private int expires;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java index 530cc1b..222d3cc 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java @@ -1,67 +1,67 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.enums; - -import lombok.Getter; - -@Getter -public enum ActionType { - /** - * allocate - */ - ALLOCATE("allocate"), - - DEALLOCATE("deallocate"), - - CREATE("create"), - - TERMINATE("terminate"), - - ACTIVATE("activate"), - - DEACTIVATE("deactivate"), - - QUERY_JOB_STATUS("query_job_status"), - - MODIFY_BY_ID("modify_by_id"), - - MODIFY("modify"), - - QUERY_NSSI_SELECTION_CAPABILITY("query_nssi_selection_capability"), - - QUERY_SUB_NET_CAPABILITY("query_sub_net_capability"),; - - private String type; - - - ActionType(String type) { - this.type = type; - } - - public static ActionType getActionType(String value) { - for (ActionType actionType : ActionType.values()) { - if (actionType.type.equalsIgnoreCase(value)) { - return actionType; - } - } - return null; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum ActionType {
+ /**
+ * allocate
+ */
+ ALLOCATE("allocate"),
+
+ DEALLOCATE("deallocate"),
+
+ CREATE("create"),
+
+ TERMINATE("terminate"),
+
+ ACTIVATE("activate"),
+
+ DEACTIVATE("deactivate"),
+
+ QUERY_JOB_STATUS("query_job_status"),
+
+ MODIFY_BY_ID("modify_by_id"),
+
+ MODIFY("modify"),
+
+ QUERY_NSSI_SELECTION_CAPABILITY("query_nssi_selection_capability"),
+
+ QUERY_SUB_NET_CAPABILITY("query_sub_net_capability"),;
+
+ private String type;
+
+
+ ActionType(String type) {
+ this.type = type;
+ }
+
+ public static ActionType getActionType(String value) {
+ for (ActionType actionType : ActionType.values()) {
+ if (actionType.type.equalsIgnoreCase(value)) {
+ return actionType;
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java index a76a54c..344d98b 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/ExecutorType.java @@ -1,25 +1,25 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.enums; - -public enum ExecutorType { - INTERNAL, EXTERNAL -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.enums;
+
+public enum ExecutorType {
+ INTERNAL, EXTERNAL
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java index 9271bb5..5a523ff 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/HttpMethod.java @@ -1,41 +1,41 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.enums; - -public enum HttpMethod { - GET, POST, PUT, DELETE, PATCH; - - public static HttpMethod fromString(String s) { - if (s == null) - return null; - if (("get").equalsIgnoreCase(s)) - return GET; - if (("post").equalsIgnoreCase(s)) - return POST; - if (("put").equalsIgnoreCase(s)) - return PUT; - if (("delete").equalsIgnoreCase(s)) - return DELETE; - if (("patch").equalsIgnoreCase(s)) - return PATCH; - throw new IllegalArgumentException("Invalid value for HTTP Method: " + s); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.enums;
+
+public enum HttpMethod {
+ GET, POST, PUT, DELETE, PATCH;
+
+ public static HttpMethod fromString(String s) {
+ if (s == null)
+ return null;
+ if (("get").equalsIgnoreCase(s))
+ return GET;
+ if (("post").equalsIgnoreCase(s))
+ return POST;
+ if (("put").equalsIgnoreCase(s))
+ return PUT;
+ if (("delete").equalsIgnoreCase(s))
+ return DELETE;
+ if (("patch").equalsIgnoreCase(s))
+ return PATCH;
+ throw new IllegalArgumentException("Invalid value for HTTP Method: " + s);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java index d5cc1df..dfe3ed9 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/JobStatus.java @@ -1,42 +1,42 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.enums; - -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; - - -public enum JobStatus { - STARTED, PROCESSING, FINISHED, ERROR; - - public static JobStatus fromString(String s) throws ApplicationException { - if (s == null) - return null; - if (("started").equalsIgnoreCase(s)) - return STARTED; - if (("processing").equalsIgnoreCase(s)) - return PROCESSING; - if (("finished").equalsIgnoreCase(s)) - return FINISHED; - if (("error").equalsIgnoreCase(s)) - return ERROR; - throw new ApplicationException(500, "Invalid value for Job " + "Status: " + s); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.enums;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+
+
+public enum JobStatus {
+ STARTED, PROCESSING, FINISHED, ERROR;
+
+ public static JobStatus fromString(String s) throws ApplicationException {
+ if (s == null)
+ return null;
+ if (("started").equalsIgnoreCase(s))
+ return STARTED;
+ if (("processing").equalsIgnoreCase(s))
+ return PROCESSING;
+ if (("finished").equalsIgnoreCase(s))
+ return FINISHED;
+ if (("error").equalsIgnoreCase(s))
+ return ERROR;
+ throw new ApplicationException(500, "Invalid value for Job " + "Status: " + s);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java index 420dfdc..802eb25 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/enums/SelectionType.java @@ -1,27 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.enums; - -public enum SelectionType { - NSSMF, - - NSMF -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.enums;
+
+public enum SelectionType {
+ NSSMF,
+
+ NSMF
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java index 2461f5c..4b88232 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/exceptions/ApplicationException.java @@ -1,66 +1,66 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.exceptions; - -import org.onap.so.adapters.nssmf.entity.ErrorResponse; -import org.springframework.http.ResponseEntity; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - -public class ApplicationException extends Exception { - - private static final long serialVersionUID = 1L; - - private int errorCode; - - private String errorMsg; - - public ApplicationException(int errorCode, String errorMsg) { - this.errorCode = errorCode; - this.errorMsg = errorMsg; - } - - public int getErrorCode() { - return errorCode; - } - - public void setErrorCode(int errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public ResponseEntity buildErrorResponse() { - String message; - try { - ErrorResponse err = new ErrorResponse(errorCode, errorMsg); - message = marshal(err); - } catch (ApplicationException e) { - return ResponseEntity.status(500).body("Internal Server Error"); - } - return ResponseEntity.status(errorCode).body(message); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.exceptions;
+
+import org.onap.so.adapters.nssmf.entity.ErrorResponse;
+import org.springframework.http.ResponseEntity;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class ApplicationException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private int errorCode;
+
+ private String errorMsg;
+
+ public ApplicationException(int errorCode, String errorMsg) {
+ this.errorCode = errorCode;
+ this.errorMsg = errorMsg;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+ public ResponseEntity buildErrorResponse() {
+ String message;
+ try {
+ ErrorResponse err = new ErrorResponse(errorCode, errorMsg);
+ message = marshal(err);
+ } catch (ApplicationException e) {
+ return ResponseEntity.status(500).body("Internal Server Error");
+ }
+ return ResponseEntity.status(errorCode).body(message);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java index 61adfcf..6136e0c 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientPropertiesImpl.java @@ -1,69 +1,69 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.extclients.aai; - -import java.net.MalformedURLException; -import java.net.URL; -import org.onap.aaiclient.client.aai.AAIProperties; -import org.onap.aaiclient.client.aai.AAIVersion; -import org.onap.so.spring.SpringContextHelper; -import org.springframework.context.ApplicationContext; - -public class AaiClientPropertiesImpl implements AAIProperties { - - private final String endpoint; - - private final String encryptedBasicAuth; - - private final String encrytptionKey; - - public AaiClientPropertiesImpl() { - final ApplicationContext context = SpringContextHelper.getAppContext(); - this.endpoint = context.getEnvironment().getProperty("aai.endpoint"); - this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth"); - this.encrytptionKey = context.getEnvironment().getProperty("mso.key"); - } - - @Override - public AAIVersion getDefaultVersion() { - return AAIVersion.LATEST; - } - - @Override - public String getAuth() { - return encryptedBasicAuth; - } - - @Override - public String getKey() { - return encrytptionKey; - } - - @Override - public URL getEndpoint() throws MalformedURLException { - return new URL(endpoint); - } - - @Override - public String getSystemName() { - return "MSO"; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.extclients.aai;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.onap.aaiclient.client.aai.AAIProperties;
+import org.onap.aaiclient.client.aai.AAIVersion;
+import org.onap.so.spring.SpringContextHelper;
+import org.springframework.context.ApplicationContext;
+
+public class AaiClientPropertiesImpl implements AAIProperties {
+
+ private final String endpoint;
+
+ private final String encryptedBasicAuth;
+
+ private final String encrytptionKey;
+
+ public AaiClientPropertiesImpl() {
+ final ApplicationContext context = SpringContextHelper.getAppContext();
+ this.endpoint = context.getEnvironment().getProperty("aai.endpoint");
+ this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth");
+ this.encrytptionKey = context.getEnvironment().getProperty("mso.key");
+ }
+
+ @Override
+ public AAIVersion getDefaultVersion() {
+ return AAIVersion.LATEST;
+ }
+
+ @Override
+ public String getAuth() {
+ return encryptedBasicAuth;
+ }
+
+ @Override
+ public String getKey() {
+ return encrytptionKey;
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(endpoint);
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java index 5959b0e..77de78a 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiClientProvider.java @@ -1,34 +1,34 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.extclients.aai; - -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class AaiClientProvider { - - @Bean - public AAIResourcesClient getAaiClient() { - return new AAIResourcesClient(); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.extclients.aai;
+
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class AaiClientProvider {
+
+ @Bean
+ public AAIResourcesClient getAaiClient() {
+ return new AAIResourcesClient();
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java index 77662bf..74ce6ae 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProvider.java @@ -1,39 +1,39 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.extclients.aai; - -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrThirdpartySdncList; -import org.onap.aai.domain.yang.ServiceInstance; - -public interface AaiServiceProvider { - - EsrThirdpartySdncList invokeGetThirdPartySdncList(); - - EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId); - - void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, - String serviceInstanceId); - - ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); - - void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId); -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.extclients.aai;
+
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.aai.domain.yang.ServiceInstance;
+
+public interface AaiServiceProvider {
+
+ EsrThirdpartySdncList invokeGetThirdPartySdncList();
+
+ EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId);
+
+ void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType,
+ String serviceInstanceId);
+
+ ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId);
+
+ void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId);
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java index 1d7c42a..fe20b4a 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/extclients/aai/AaiServiceProviderImpl.java @@ -1,98 +1,98 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.extclients.aai; - - -import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.aai.domain.yang.EsrThirdpartySdncList; -import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class AaiServiceProviderImpl implements AaiServiceProvider { - - private static final Logger logger = LoggerFactory.getLogger(AaiServiceProviderImpl.class); - - private final AaiClientProvider aaiClientProvider; - - @Autowired - public AaiServiceProviderImpl(final AaiClientProvider aaiClientProvider) { - this.aaiClientProvider = aaiClientProvider; - } - - @Override - public EsrThirdpartySdncList invokeGetThirdPartySdncList() { - return aaiClientProvider.getAaiClient() - .get(EsrThirdpartySdncList.class, - AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrThirdpartySdncList())) - .orElseGet(() -> { - logger.debug("No VNFMs in AAI"); - return null; - }); - } - - @Override - public EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId) { - return aaiClientProvider.getAaiClient() - .get(EsrSystemInfoList.class, - AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.externalSystem().esrThirdpartySdnc((sdncId)).esrSystemInfoList())) - .orElseGet(() -> { - logger.debug("VNFM not found in AAI"); - return null; - }); - } - - - @Override - public void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType, - String serviceInstanceId) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() - .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); - aaiClientProvider.getAaiClient().create(uri, nssiInstance); - } - - @Override - public ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType, - String serviceInstanceId) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() - .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); - - return aaiClientProvider.getAaiClient().get(ServiceInstance.class, uri).orElseGet(() -> { - logger.debug("ServiceInstance " + serviceInstanceId + " not found in AAI"); - return null; - }); - } - - @Override - public void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() - .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId)); - - aaiClientProvider.getAaiClient().delete(uri); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.extclients.aai;
+
+
+import org.onap.aai.domain.yang.EsrSystemInfoList;
+import org.onap.aai.domain.yang.EsrThirdpartySdncList;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AaiServiceProviderImpl implements AaiServiceProvider {
+
+ private static final Logger logger = LoggerFactory.getLogger(AaiServiceProviderImpl.class);
+
+ private final AaiClientProvider aaiClientProvider;
+
+ @Autowired
+ public AaiServiceProviderImpl(final AaiClientProvider aaiClientProvider) {
+ this.aaiClientProvider = aaiClientProvider;
+ }
+
+ @Override
+ public EsrThirdpartySdncList invokeGetThirdPartySdncList() {
+ return aaiClientProvider.getAaiClient()
+ .get(EsrThirdpartySdncList.class,
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.externalSystem().esrThirdpartySdncList()))
+ .orElseGet(() -> {
+ logger.debug("No VNFMs in AAI");
+ return null;
+ });
+ }
+
+ @Override
+ public EsrSystemInfoList invokeGetThirdPartySdncEsrSystemInfo(String sdncId) {
+ return aaiClientProvider.getAaiClient()
+ .get(EsrSystemInfoList.class,
+ AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.externalSystem().esrThirdpartySdnc((sdncId)).esrSystemInfoList()))
+ .orElseGet(() -> {
+ logger.debug("VNFM not found in AAI");
+ return null;
+ });
+ }
+
+
+ @Override
+ public void invokeCreateServiceInstance(ServiceInstance nssiInstance, String globalSubscriberId, String serviceType,
+ String serviceInstanceId) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId));
+ aaiClientProvider.getAaiClient().create(uri, nssiInstance);
+ }
+
+ @Override
+ public ServiceInstance invokeGetServiceInstance(String globalSubscriberId, String serviceType,
+ String serviceInstanceId) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId));
+
+ return aaiClientProvider.getAaiClient().get(ServiceInstance.class, uri).orElseGet(() -> {
+ logger.debug("ServiceInstance " + serviceInstanceId + " not found in AAI");
+ return null;
+ });
+ }
+
+ @Override
+ public void invokeDeleteServiceInstance(String globalSubscriberId, String serviceType, String serviceInstanceId) {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(globalSubscriberId).serviceSubscription(serviceType).serviceInstance(serviceInstanceId));
+
+ aaiClientProvider.getAaiClient().delete(uri);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java index bca4a12..4a6bf05 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/interceptor/LoggerInterceptor.java @@ -1,55 +1,55 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.interceptor; - -import org.apache.logging.log4j.ThreadContext; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.ModelAndView; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.UUID; - -@Component -public class LoggerInterceptor implements HandlerInterceptor { - - private final static String TRACE_ID = "traceId"; - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - String traceId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase(); - ThreadContext.put(TRACE_ID, traceId); - return true; - } - - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, - ModelAndView modelAndView) throws Exception { - - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) - throws Exception { - ThreadContext.remove(TRACE_ID); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.interceptor;
+
+import org.apache.logging.log4j.ThreadContext;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.UUID;
+
+@Component
+public class LoggerInterceptor implements HandlerInterceptor {
+
+ private final static String TRACE_ID = "traceId";
+
+ @Override
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
+ throws Exception {
+ String traceId = UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
+ ThreadContext.put(TRACE_ID, traceId);
+ return true;
+ }
+
+ @Override
+ public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
+ ModelAndView modelAndView) throws Exception {
+
+ }
+
+ @Override
+ public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
+ throws Exception {
+ ThreadContext.remove(TRACE_ID);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java index 95f26b4..908cf91 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/interceptor/RequestLogAspect.java @@ -1,227 +1,227 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.adapters.nssmf.interceptor; - -import lombok.Data; -import lombok.ToString; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.*; -import org.aspectj.lang.reflect.MethodSignature; -import org.onap.so.adapters.nssmf.annotation.RequestLogger; -import org.onap.so.adapters.nssmf.annotation.ServiceLogger; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletRequest; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -/** - * support to print logger of service method - */ -@Aspect -@Order(100) -@Component -public class RequestLogAspect { - - private static final Logger logger = LoggerFactory.getLogger(RequestLogAspect.class); - - @Pointcut("execution(* org.onap.so.adapters.nssmf.service..*(..))") - public void serviceLogger() { - - } - - @Around("serviceLogger()") - public Object around(ProceedingJoinPoint joinPoint) { - try { - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - Method method = signature.getMethod(); - - Class<?> targetClass = method.getDeclaringClass(); - - StringBuilder classAndMethod = new StringBuilder(); - ServiceLogger classAnnotation = targetClass.getAnnotation(ServiceLogger.class); - ServiceLogger methodAnnotation = method.getAnnotation(ServiceLogger.class); - - if (classAnnotation == null && methodAnnotation == null) { - return joinPoint.proceed(); - } - - if (classAnnotation != null) { - if (classAnnotation.ignore()) { - return joinPoint.proceed(); - } - classAndMethod.append(classAnnotation.value()).append("-"); - } - - String target = targetClass.getName() + "#" + method.getName(); - - String params = NssmfAdapterUtil.marshal(joinPoint.getArgs()); - - logger.info("{} Start: Method = {} \nParams = {}", classAndMethod.toString(), target, params); - - long start = System.currentTimeMillis(); - Object result = joinPoint.proceed(); - long timeConsuming = System.currentTimeMillis() - start; - - logger.info("\n{} End: Method = {}, Spend time = {}ms \nResult = {}", classAndMethod.toString(), target, - timeConsuming, NssmfAdapterUtil.marshal(result)); - return result; - - } catch (Throwable e) { - logger.error(e.getMessage(), e); - } - return null; - } - - @Pointcut("execution(* org.onap.so.adapters.nssmf.controller..*(..))") - public void controllerLogger() { - - } - - @Around("controllerLogger()") - public Object doAroundRequest(ProceedingJoinPoint point) throws Throwable { - MethodSignature signature = (MethodSignature) point.getSignature(); - Method method = signature.getMethod(); - Class<?> targetClass = method.getDeclaringClass(); - - RequestLogger classAnnotation = targetClass.getAnnotation(RequestLogger.class); - RequestLogger methodAnnotation = method.getAnnotation(RequestLogger.class); - - if ((classAnnotation == null && methodAnnotation == null) - || (classAnnotation != null && classAnnotation.ignore()) - || (methodAnnotation != null && methodAnnotation.ignore())) { - return point.proceed(); - } - - long start = System.currentTimeMillis(); - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - - assert attributes != null; - HttpServletRequest request = attributes.getRequest(); - Object result = point.proceed(); - RequestInfo requestInfo = new RequestInfo(); - requestInfo.setIp(request.getRemoteAddr()); - requestInfo.setUrl(request.getRequestURL().toString()); - requestInfo.setHttpMethod(request.getMethod()); - requestInfo.setClassMethod(String.format("%s.%s", signature.getDeclaringTypeName(), signature.getName())); - requestInfo.setRequestParams(getRequestParamsByProceedingJoinPoint(point)); - requestInfo.setResult(result); - requestInfo.setTimeCost(System.currentTimeMillis() - start); - logger.info("Request Info : {}", NssmfAdapterUtil.marshal(requestInfo)); - return result; - } - - @AfterThrowing(pointcut = "controllerLogger()", throwing = "e") - public void doAfterRequestThrow(JoinPoint joinPoint, RuntimeException e) { - MethodSignature signature = (MethodSignature) joinPoint.getSignature(); - Method method = signature.getMethod(); - Class<?> targetClass = method.getDeclaringClass(); - - RequestLogger classAnnotation = targetClass.getAnnotation(RequestLogger.class); - RequestLogger methodAnnotation = method.getAnnotation(RequestLogger.class); - - if ((classAnnotation == null && methodAnnotation == null) - || (classAnnotation != null && classAnnotation.ignore()) - || (methodAnnotation != null && methodAnnotation.ignore())) { - return; - } - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - assert attributes != null; - HttpServletRequest request = attributes.getRequest(); - RequestErrorInfo requestErrorInfo = new RequestErrorInfo(); - requestErrorInfo.setIp(request.getRemoteAddr()); - requestErrorInfo.setUrl(request.getRequestURL().toString()); - requestErrorInfo.setHttpMethod(request.getMethod()); - requestErrorInfo.setClassMethod(String.format("%s.%s", joinPoint.getSignature().getDeclaringTypeName(), - joinPoint.getSignature().getName())); - requestErrorInfo.setRequestParams(getRequestParamsByJoinPoint(joinPoint)); - requestErrorInfo.setException(e); - String res; - try { - res = NssmfAdapterUtil.marshal(requestErrorInfo); - logger.info("Error Request Info : {}", res); - } catch (ApplicationException ex) { - logger.info("Error Request Info : {}", requestErrorInfo); - } - } - - private Map<String, Object> getRequestParamsByJoinPoint(JoinPoint joinPoint) { - String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames(); - Object[] paramValues = joinPoint.getArgs(); - - return buildRequestParam(paramNames, paramValues); - } - - - private Map<String, Object> getRequestParamsByProceedingJoinPoint(ProceedingJoinPoint proceedingJoinPoint) { - String[] paramNames = ((MethodSignature) proceedingJoinPoint.getSignature()).getParameterNames(); - Object[] paramValues = proceedingJoinPoint.getArgs(); - - return buildRequestParam(paramNames, paramValues); - } - - private Map<String, Object> buildRequestParam(String[] paramNames, Object[] paramValues) { - Map<String, Object> requestParams = new HashMap<>(); - for (int i = 0; i < paramNames.length; i++) { - Object value = paramValues[i]; - - if (value instanceof MultipartFile) { - MultipartFile file = (MultipartFile) value; - value = file.getOriginalFilename(); - } - - requestParams.put(paramNames[i], value); - } - - return requestParams; - } - - @Data - @ToString - private class RequestInfo { - private String ip; - private String url; - private String httpMethod; - private String classMethod; - private Object requestParams; - private Object result; - private Long timeCost; - } - - @Data - @ToString - private class RequestErrorInfo { - private String ip; - private String url; - private String httpMethod; - private String classMethod; - private Object requestParams; - private RuntimeException exception; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.nssmf.interceptor;
+
+import lombok.Data;
+import lombok.ToString;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.onap.so.adapters.nssmf.annotation.RequestLogger;
+import org.onap.so.adapters.nssmf.annotation.ServiceLogger;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * support to print logger of service method
+ */
+@Aspect
+@Order(100)
+@Component
+public class RequestLogAspect {
+
+ private static final Logger logger = LoggerFactory.getLogger(RequestLogAspect.class);
+
+ @Pointcut("execution(* org.onap.so.adapters.nssmf.service..*(..))")
+ public void serviceLogger() {
+
+ }
+
+ @Around("serviceLogger()")
+ public Object around(ProceedingJoinPoint joinPoint) {
+ try {
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+
+ Class<?> targetClass = method.getDeclaringClass();
+
+ StringBuilder classAndMethod = new StringBuilder();
+ ServiceLogger classAnnotation = targetClass.getAnnotation(ServiceLogger.class);
+ ServiceLogger methodAnnotation = method.getAnnotation(ServiceLogger.class);
+
+ if (classAnnotation == null && methodAnnotation == null) {
+ return joinPoint.proceed();
+ }
+
+ if (classAnnotation != null) {
+ if (classAnnotation.ignore()) {
+ return joinPoint.proceed();
+ }
+ classAndMethod.append(classAnnotation.value()).append("-");
+ }
+
+ String target = targetClass.getName() + "#" + method.getName();
+
+ String params = NssmfAdapterUtil.marshal(joinPoint.getArgs());
+
+ logger.info("{} Start: Method = {} \nParams = {}", classAndMethod.toString(), target, params);
+
+ long start = System.currentTimeMillis();
+ Object result = joinPoint.proceed();
+ long timeConsuming = System.currentTimeMillis() - start;
+
+ logger.info("\n{} End: Method = {}, Spend time = {}ms \nResult = {}", classAndMethod.toString(), target,
+ timeConsuming, NssmfAdapterUtil.marshal(result));
+ return result;
+
+ } catch (Throwable e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ @Pointcut("execution(* org.onap.so.adapters.nssmf.controller..*(..))")
+ public void controllerLogger() {
+
+ }
+
+ @Around("controllerLogger()")
+ public Object doAroundRequest(ProceedingJoinPoint point) throws Throwable {
+ MethodSignature signature = (MethodSignature) point.getSignature();
+ Method method = signature.getMethod();
+ Class<?> targetClass = method.getDeclaringClass();
+
+ RequestLogger classAnnotation = targetClass.getAnnotation(RequestLogger.class);
+ RequestLogger methodAnnotation = method.getAnnotation(RequestLogger.class);
+
+ if ((classAnnotation == null && methodAnnotation == null)
+ || (classAnnotation != null && classAnnotation.ignore())
+ || (methodAnnotation != null && methodAnnotation.ignore())) {
+ return point.proceed();
+ }
+
+ long start = System.currentTimeMillis();
+ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+
+ assert attributes != null;
+ HttpServletRequest request = attributes.getRequest();
+ Object result = point.proceed();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setIp(request.getRemoteAddr());
+ requestInfo.setUrl(request.getRequestURL().toString());
+ requestInfo.setHttpMethod(request.getMethod());
+ requestInfo.setClassMethod(String.format("%s.%s", signature.getDeclaringTypeName(), signature.getName()));
+ requestInfo.setRequestParams(getRequestParamsByProceedingJoinPoint(point));
+ requestInfo.setResult(result);
+ requestInfo.setTimeCost(System.currentTimeMillis() - start);
+ logger.info("Request Info : {}", NssmfAdapterUtil.marshal(requestInfo));
+ return result;
+ }
+
+ @AfterThrowing(pointcut = "controllerLogger()", throwing = "e")
+ public void doAfterRequestThrow(JoinPoint joinPoint, RuntimeException e) {
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ Class<?> targetClass = method.getDeclaringClass();
+
+ RequestLogger classAnnotation = targetClass.getAnnotation(RequestLogger.class);
+ RequestLogger methodAnnotation = method.getAnnotation(RequestLogger.class);
+
+ if ((classAnnotation == null && methodAnnotation == null)
+ || (classAnnotation != null && classAnnotation.ignore())
+ || (methodAnnotation != null && methodAnnotation.ignore())) {
+ return;
+ }
+ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+ assert attributes != null;
+ HttpServletRequest request = attributes.getRequest();
+ RequestErrorInfo requestErrorInfo = new RequestErrorInfo();
+ requestErrorInfo.setIp(request.getRemoteAddr());
+ requestErrorInfo.setUrl(request.getRequestURL().toString());
+ requestErrorInfo.setHttpMethod(request.getMethod());
+ requestErrorInfo.setClassMethod(String.format("%s.%s", joinPoint.getSignature().getDeclaringTypeName(),
+ joinPoint.getSignature().getName()));
+ requestErrorInfo.setRequestParams(getRequestParamsByJoinPoint(joinPoint));
+ requestErrorInfo.setException(e);
+ String res;
+ try {
+ res = NssmfAdapterUtil.marshal(requestErrorInfo);
+ logger.info("Error Request Info : {}", res);
+ } catch (ApplicationException ex) {
+ logger.info("Error Request Info : {}", requestErrorInfo);
+ }
+ }
+
+ private Map<String, Object> getRequestParamsByJoinPoint(JoinPoint joinPoint) {
+ String[] paramNames = ((MethodSignature) joinPoint.getSignature()).getParameterNames();
+ Object[] paramValues = joinPoint.getArgs();
+
+ return buildRequestParam(paramNames, paramValues);
+ }
+
+
+ private Map<String, Object> getRequestParamsByProceedingJoinPoint(ProceedingJoinPoint proceedingJoinPoint) {
+ String[] paramNames = ((MethodSignature) proceedingJoinPoint.getSignature()).getParameterNames();
+ Object[] paramValues = proceedingJoinPoint.getArgs();
+
+ return buildRequestParam(paramNames, paramValues);
+ }
+
+ private Map<String, Object> buildRequestParam(String[] paramNames, Object[] paramValues) {
+ Map<String, Object> requestParams = new HashMap<>();
+ for (int i = 0; i < paramNames.length; i++) {
+ Object value = paramValues[i];
+
+ if (value instanceof MultipartFile) {
+ MultipartFile file = (MultipartFile) value;
+ value = file.getOriginalFilename();
+ }
+
+ requestParams.put(paramNames[i], value);
+ }
+
+ return requestParams;
+ }
+
+ @Data
+ @ToString
+ private class RequestInfo {
+ private String ip;
+ private String url;
+ private String httpMethod;
+ private String classMethod;
+ private Object requestParams;
+ private Object result;
+ private Long timeCost;
+ }
+
+ @Data
+ @ToString
+ private class RequestErrorInfo {
+ private String ip;
+ private String url;
+ private String httpMethod;
+ private String classMethod;
+ private Object requestParams;
+ private RuntimeException exception;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java index 54ef1e0..8923a1c 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManager.java @@ -1,44 +1,44 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager; - -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.beans.nsmf.*; - -public interface NssmfManager { - - RestResponse allocateNssi(NssmfAdapterNBIRequest nssmfRequest) throws ApplicationException; - - RestResponse deAllocateNssi(NssmfAdapterNBIRequest nssmfRequest, String sliceId) throws ApplicationException; - - RestResponse activateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException; - - RestResponse deActivateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException; - - RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException; - - RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException; -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.beans.nsmf.*;
+
+public interface NssmfManager {
+
+ RestResponse allocateNssi(NssmfAdapterNBIRequest nssmfRequest) throws ApplicationException;
+
+ RestResponse deAllocateNssi(NssmfAdapterNBIRequest nssmfRequest, String sliceId) throws ApplicationException;
+
+ RestResponse activateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException;
+
+ RestResponse deActivateNssi(NssmfAdapterNBIRequest nssmfRequest, String snssai) throws ApplicationException;
+
+ RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException;
+
+ RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException;
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java index e397201..096d548 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/NssmfManagerBuilder.java @@ -1,131 +1,131 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager; - -import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; -import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.enums.ExecutorType; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.impl.external.ExternalAnNssmfManager; -import org.onap.so.adapters.nssmf.manager.impl.external.ExternalCnNssmfManager; -import org.onap.so.adapters.nssmf.manager.impl.internal.InternalAnNssmfManager; -import org.onap.so.adapters.nssmf.manager.impl.internal.InternalCnNssmfManager; -import org.onap.so.adapters.nssmf.manager.impl.internal.InternalTnNssmfManager; -import org.onap.so.adapters.nssmf.manager.impl.*; -import org.onap.so.adapters.nssmf.util.RestUtil; -import org.onap.so.beans.nsmf.EsrInfo; -import org.onap.so.beans.nsmf.NetworkType; -import org.onap.so.beans.nsmf.ServiceInfo; -import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; - -public class NssmfManagerBuilder { - - private BaseNssmfManager nssmfManger; - - private RestUtil restUtil; - - private ActionType actionType; - - private ResourceOperationStatusRepository repository; - - private ServiceInfo serviceInfo; - - private NssmfAdapterConfig adapterConfig; - - public NssmfManagerBuilder(EsrInfo esrInfo) throws ApplicationException { - - ExecutorType executorType = getExecutorType(esrInfo); - NetworkType networkType = esrInfo.getNetworkType(); - - if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) { - this.nssmfManger = new InternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType); - return; - } - - if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) { - this.nssmfManger = new InternalTnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType); - return; - } - - if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) { - this.nssmfManger = new InternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType); - return; - } - - if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) { - this.nssmfManger = new ExternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) - .setInitStatus("deactivated"); - return; - } - - if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) { - this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) - .setInitStatus("activated"); - return; - } - - if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) { - this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType) - .setInitStatus("activated"); - return; - } - - throw new ApplicationException(404, "invalid domain and simulator"); - } - - private ExecutorType getExecutorType(EsrInfo esrInfo) { - if (NssmfAdapterConsts.ONAP_INTERNAL_TAG.equals(esrInfo.getVendor())) { - return ExecutorType.INTERNAL; - } - return ExecutorType.EXTERNAL; - } - - public NssmfManagerBuilder setRestUtil(RestUtil restUtil) { - this.restUtil = restUtil; - return this; - } - - public NssmfManagerBuilder setActionType(ActionType actionType) { - this.actionType = actionType; - return this; - } - - public NssmfManagerBuilder setRepository(ResourceOperationStatusRepository repository) { - this.repository = repository; - return this; - } - - public NssmfManagerBuilder setServiceInfo(ServiceInfo serviceInfo) { - this.serviceInfo = serviceInfo; - return this; - } - - public NssmfManagerBuilder setAdapterConfig(NssmfAdapterConfig adapterConfig) { - this.adapterConfig = adapterConfig; - return this; - } - - public NssmfManager build() { - return this.nssmfManger.setRestUtil(restUtil).setAdapterConfig(adapterConfig).setRepository(repository) - .setActionType(actionType).setServiceInfo(serviceInfo); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager;
+
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.ExecutorType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.external.ExternalAnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.external.ExternalCnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.internal.InternalAnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.internal.InternalCnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.internal.InternalTnNssmfManager;
+import org.onap.so.adapters.nssmf.manager.impl.*;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.NetworkType;
+import org.onap.so.beans.nsmf.ServiceInfo;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+
+public class NssmfManagerBuilder {
+
+ private BaseNssmfManager nssmfManger;
+
+ private RestUtil restUtil;
+
+ private ActionType actionType;
+
+ private ResourceOperationStatusRepository repository;
+
+ private ServiceInfo serviceInfo;
+
+ private NssmfAdapterConfig adapterConfig;
+
+ public NssmfManagerBuilder(EsrInfo esrInfo) throws ApplicationException {
+
+ ExecutorType executorType = getExecutorType(esrInfo);
+ NetworkType networkType = esrInfo.getNetworkType();
+
+ if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) {
+ this.nssmfManger = new InternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType);
+ return;
+ }
+
+ if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) {
+ this.nssmfManger = new InternalTnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType);
+ return;
+ }
+
+ if (ExecutorType.INTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) {
+ this.nssmfManger = new InternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType);
+ return;
+ }
+
+ if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.CORE.equals(networkType)) {
+ this.nssmfManger = new ExternalCnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
+ .setInitStatus("deactivated");
+ return;
+ }
+
+ if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.TRANSPORT.equals(networkType)) {
+ this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
+ .setInitStatus("activated");
+ return;
+ }
+
+ if (ExecutorType.EXTERNAL.equals(executorType) && NetworkType.ACCESS.equals(networkType)) {
+ this.nssmfManger = new ExternalAnNssmfManager().setEsrInfo(esrInfo).setExecutorType(executorType)
+ .setInitStatus("activated");
+ return;
+ }
+
+ throw new ApplicationException(404, "invalid domain and simulator");
+ }
+
+ private ExecutorType getExecutorType(EsrInfo esrInfo) {
+ if (NssmfAdapterConsts.ONAP_INTERNAL_TAG.equals(esrInfo.getVendor())) {
+ return ExecutorType.INTERNAL;
+ }
+ return ExecutorType.EXTERNAL;
+ }
+
+ public NssmfManagerBuilder setRestUtil(RestUtil restUtil) {
+ this.restUtil = restUtil;
+ return this;
+ }
+
+ public NssmfManagerBuilder setActionType(ActionType actionType) {
+ this.actionType = actionType;
+ return this;
+ }
+
+ public NssmfManagerBuilder setRepository(ResourceOperationStatusRepository repository) {
+ this.repository = repository;
+ return this;
+ }
+
+ public NssmfManagerBuilder setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ return this;
+ }
+
+ public NssmfManagerBuilder setAdapterConfig(NssmfAdapterConfig adapterConfig) {
+ this.adapterConfig = adapterConfig;
+ return this;
+ }
+
+ public NssmfManager build() {
+ return this.nssmfManger.setRestUtil(restUtil).setAdapterConfig(adapterConfig).setRepository(repository)
+ .setActionType(actionType).setServiceInfo(serviceInfo);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java index 0456c90..52da027 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -1,282 +1,282 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl; - -import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; -import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; -import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo; -import org.onap.so.adapters.nssmf.enums.*; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.adapters.nssmf.manager.NssmfManager; -import org.onap.so.adapters.nssmf.util.RestUtil; -import org.onap.so.beans.nsmf.*; -import org.onap.so.db.request.beans.ResourceOperationStatus; -import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.domain.Example; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - -public abstract class BaseNssmfManager implements NssmfManager { - - private static final Logger logger = LoggerFactory.getLogger(BaseNssmfManager.class); - - protected RestUtil restUtil; - - protected ResourceOperationStatusRepository repository; - - protected NssmfAdapterConfig adapterConfig; - - protected ActionType actionType; - - protected EsrInfo esrInfo; - - protected String nssmfUrl; - - protected HttpMethod httpMethod; - - protected String initStatus; - - protected ServiceInfo serviceInfo; - - protected RestResponse restResponse; - - private ExecutorType executorType = ExecutorType.INTERNAL; - - private Map<String, String> params = new HashMap<>(); // request params - - @Override - public RestResponse allocateNssi(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - - this.params.clear(); - this.urlHandler(); - String requestBody = wrapAllocateReqBody(nbiRequest); - - this.restResponse = sendRequest(requestBody); - - this.afterRequest(); - - return restResponse; - } - - protected abstract String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - @Override - public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException { - this.params.clear(); - this.urlHandler(); - String requestBody = wrapModifyReqBody(modifyRequest); - - this.restResponse = sendRequest(requestBody); - - this.afterRequest(); - - return restResponse; - } - - protected abstract String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - @Override - public RestResponse deAllocateNssi(NssmfAdapterNBIRequest nbiRequest, String sliceId) throws ApplicationException { - this.params.clear(); - this.params.put("sliceProfileId", sliceId); - - this.urlHandler(); - - String reqBody = wrapDeAllocateReqBody(nbiRequest.getDeAllocateNssi()); - - this.restResponse = sendRequest(reqBody); - - this.afterRequest(); - - return restResponse; - } - - protected abstract String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException; - - protected abstract String wrapReqBody(Object object) throws ApplicationException; - - @Override - public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { - this.params.clear(); - this.params.put("snssai", snssai); - - this.urlHandler(); - - String reqBody = wrapActDeActReqBody(nbiRequest.getActDeActNssi()); - - this.restResponse = sendRequest(reqBody); - - this.afterRequest(); - - return restResponse; - } - - @Override - public RestResponse deActivateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { - return activateNssi(nbiRequest, snssai); - } - - protected abstract String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException; - - @Override - public RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException { - this.params.clear(); - this.params.put("jobId", jobId); - if (jobReq.getResponseId() != null) { - this.params.put("responseId", jobReq.getResponseId()); - } - this.urlHandler(); - - /** - * find by jobId and nsiId jobId -> OperationId nsiId -> ServiceId serviceUuid -> resourceTemplateUUID - */ - ResourceOperationStatus status = - getOperationStatus(serviceInfo.getNsiId(), jobId, serviceInfo.getServiceUuid()); - - logger.info("ResourceOperationStatus = {}", status); - this.restResponse = doQueryJobStatus(status); - - afterQueryJobStatus(status); - return restResponse; - } - - protected abstract RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException; - - - protected abstract void afterQueryJobStatus(ResourceOperationStatus status); - - private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) { - - logger.info("Query operations: nsiId = [{}], jobId = [{}], serviceUuid = [{}]", nsiId, jobId, serviceUuid); - - List<ResourceOperationStatus> resourceOperationStatuses = - repository.findByServiceIdAndOperationId(nsiId, jobId); - - logger.info("resourceOperationStatuses = {}", resourceOperationStatuses); - if (resourceOperationStatuses.size() == 0) { - return null; - } - return resourceOperationStatuses.get(0); - } - - @Override - public RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - SelectionType res = doQueryNSSISelectionCapability(); - HashMap<String, String> hashMap = new HashMap<>(); - hashMap.put("selection", res.name()); - RestResponse restResponse = new RestResponse(); - restResponse.setStatus(200); - restResponse.setResponseContent(marshal(hashMap)); - return restResponse; - } - - protected abstract SelectionType doQueryNSSISelectionCapability(); - - @Override - public RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - this.params.clear(); - this.urlHandler(); - - return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery()); - } - - protected abstract RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException; - - /** - * send request to nssmf - * - * @param content request body - * @return response - * @throws ApplicationException - */ - protected abstract RestResponse sendRequest(String content) throws ApplicationException; - - /** - * handle the url before request to nssmf, include get the nssmf request url, replace the path variable - */ - private void urlHandler() { - NssmfUrlInfo nssmfUrlInfo = - NssmfAdapterConsts.getNssmfUrlInfo(this.executorType, this.esrInfo.getNetworkType(), actionType); - if (nssmfUrlInfo != null) { - this.nssmfUrl = nssmfUrlInfo.getUrl(); - this.httpMethod = nssmfUrlInfo.getHttpMethod(); - this.nssmfUrl = nssmfUrl.replaceAll("\\{apiVersion}", getApiVersion()); - this.params.forEach((k, v) -> this.nssmfUrl = this.nssmfUrl.replaceAll("\\{" + k + "}", v)); - } - } - - /** - * after request - */ - protected abstract void afterRequest() throws ApplicationException; - - protected abstract String getApiVersion(); - - public RestUtil getRestUtil() { - return restUtil; - } - - public BaseNssmfManager setEsrInfo(EsrInfo esrInfo) { - this.esrInfo = esrInfo; - return this; - } - - public BaseNssmfManager setExecutorType(ExecutorType executorType) { - this.executorType = executorType; - return this; - } - - public BaseNssmfManager setRestUtil(RestUtil restUtil) { - this.restUtil = restUtil; - return this; - } - - public BaseNssmfManager setActionType(ActionType actionType) { - this.actionType = actionType; - return this; - } - - public BaseNssmfManager setRepository(ResourceOperationStatusRepository repository) { - this.repository = repository; - return this; - } - - public BaseNssmfManager setServiceInfo(ServiceInfo serviceInfo) { - this.serviceInfo = serviceInfo; - return this; - } - - public BaseNssmfManager setInitStatus(String initStatus) { - this.initStatus = initStatus; - return this; - } - - public BaseNssmfManager setAdapterConfig(NssmfAdapterConfig adapterConfig) { - this.adapterConfig = adapterConfig; - return this; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl;
+
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.entity.NssmfUrlInfo;
+import org.onap.so.adapters.nssmf.enums.*;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.manager.NssmfManager;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.domain.Example;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public abstract class BaseNssmfManager implements NssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(BaseNssmfManager.class);
+
+ protected RestUtil restUtil;
+
+ protected ResourceOperationStatusRepository repository;
+
+ protected NssmfAdapterConfig adapterConfig;
+
+ protected ActionType actionType;
+
+ protected EsrInfo esrInfo;
+
+ protected String nssmfUrl;
+
+ protected HttpMethod httpMethod;
+
+ protected String initStatus;
+
+ protected ServiceInfo serviceInfo;
+
+ protected RestResponse restResponse;
+
+ private ExecutorType executorType = ExecutorType.INTERNAL;
+
+ private Map<String, String> params = new HashMap<>(); // request params
+
+ @Override
+ public RestResponse allocateNssi(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+
+ this.params.clear();
+ this.urlHandler();
+ String requestBody = wrapAllocateReqBody(nbiRequest);
+
+ this.restResponse = sendRequest(requestBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ protected abstract String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException {
+ this.params.clear();
+ this.urlHandler();
+ String requestBody = wrapModifyReqBody(modifyRequest);
+
+ this.restResponse = sendRequest(requestBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ protected abstract String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ public RestResponse deAllocateNssi(NssmfAdapterNBIRequest nbiRequest, String sliceId) throws ApplicationException {
+ this.params.clear();
+ this.params.put("sliceProfileId", sliceId);
+
+ this.urlHandler();
+
+ String reqBody = wrapDeAllocateReqBody(nbiRequest.getDeAllocateNssi());
+
+ this.restResponse = sendRequest(reqBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ protected abstract String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException;
+
+ protected abstract String wrapReqBody(Object object) throws ApplicationException;
+
+ @Override
+ public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException {
+ this.params.clear();
+ this.params.put("snssai", snssai);
+
+ this.urlHandler();
+
+ String reqBody = wrapActDeActReqBody(nbiRequest.getActDeActNssi());
+
+ this.restResponse = sendRequest(reqBody);
+
+ this.afterRequest();
+
+ return restResponse;
+ }
+
+ @Override
+ public RestResponse deActivateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException {
+ return activateNssi(nbiRequest, snssai);
+ }
+
+ protected abstract String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException;
+
+ @Override
+ public RestResponse queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) throws ApplicationException {
+ this.params.clear();
+ this.params.put("jobId", jobId);
+ if (jobReq.getResponseId() != null) {
+ this.params.put("responseId", jobReq.getResponseId());
+ }
+ this.urlHandler();
+
+ /**
+ * find by jobId and nsiId jobId -> OperationId nsiId -> ServiceId serviceUuid -> resourceTemplateUUID
+ */
+ ResourceOperationStatus status =
+ getOperationStatus(serviceInfo.getNsiId(), jobId, serviceInfo.getServiceUuid());
+
+ logger.info("ResourceOperationStatus = {}", status);
+ this.restResponse = doQueryJobStatus(status);
+
+ afterQueryJobStatus(status);
+ return restResponse;
+ }
+
+ protected abstract RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException;
+
+
+ protected abstract void afterQueryJobStatus(ResourceOperationStatus status);
+
+ private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) {
+
+ logger.info("Query operations: nsiId = [{}], jobId = [{}], serviceUuid = [{}]", nsiId, jobId, serviceUuid);
+
+ List<ResourceOperationStatus> resourceOperationStatuses =
+ repository.findByServiceIdAndOperationId(nsiId, jobId);
+
+ logger.info("resourceOperationStatuses = {}", resourceOperationStatuses);
+ if (resourceOperationStatuses.size() == 0) {
+ return null;
+ }
+ return resourceOperationStatuses.get(0);
+ }
+
+ @Override
+ public RestResponse queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ SelectionType res = doQueryNSSISelectionCapability();
+ HashMap<String, String> hashMap = new HashMap<>();
+ hashMap.put("selection", res.name());
+ RestResponse restResponse = new RestResponse();
+ restResponse.setStatus(200);
+ restResponse.setResponseContent(marshal(hashMap));
+ return restResponse;
+ }
+
+ protected abstract SelectionType doQueryNSSISelectionCapability();
+
+ @Override
+ public RestResponse querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ this.params.clear();
+ this.urlHandler();
+
+ return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery());
+ }
+
+ protected abstract RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException;
+
+ /**
+ * send request to nssmf
+ *
+ * @param content request body
+ * @return response
+ * @throws ApplicationException
+ */
+ protected abstract RestResponse sendRequest(String content) throws ApplicationException;
+
+ /**
+ * handle the url before request to nssmf, include get the nssmf request url, replace the path variable
+ */
+ private void urlHandler() {
+ NssmfUrlInfo nssmfUrlInfo =
+ NssmfAdapterConsts.getNssmfUrlInfo(this.executorType, this.esrInfo.getNetworkType(), actionType);
+ if (nssmfUrlInfo != null) {
+ this.nssmfUrl = nssmfUrlInfo.getUrl();
+ this.httpMethod = nssmfUrlInfo.getHttpMethod();
+ this.nssmfUrl = nssmfUrl.replaceAll("\\{apiVersion}", getApiVersion());
+ this.params.forEach((k, v) -> this.nssmfUrl = this.nssmfUrl.replaceAll("\\{" + k + "}", v));
+ }
+ }
+
+ /**
+ * after request
+ */
+ protected abstract void afterRequest() throws ApplicationException;
+
+ protected abstract String getApiVersion();
+
+ public RestUtil getRestUtil() {
+ return restUtil;
+ }
+
+ public BaseNssmfManager setEsrInfo(EsrInfo esrInfo) {
+ this.esrInfo = esrInfo;
+ return this;
+ }
+
+ public BaseNssmfManager setExecutorType(ExecutorType executorType) {
+ this.executorType = executorType;
+ return this;
+ }
+
+ public BaseNssmfManager setRestUtil(RestUtil restUtil) {
+ this.restUtil = restUtil;
+ return this;
+ }
+
+ public BaseNssmfManager setActionType(ActionType actionType) {
+ this.actionType = actionType;
+ return this;
+ }
+
+ public BaseNssmfManager setRepository(ResourceOperationStatusRepository repository) {
+ this.repository = repository;
+ return this;
+ }
+
+ public BaseNssmfManager setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ return this;
+ }
+
+ public BaseNssmfManager setInitStatus(String initStatus) {
+ this.initStatus = initStatus;
+ return this;
+ }
+
+ public BaseNssmfManager setAdapterConfig(NssmfAdapterConfig adapterConfig) {
+ this.adapterConfig = adapterConfig;
+ return this;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index 7c4bd50..2c51cef 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -1,243 +1,243 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.Header; -import org.apache.http.HttpStatus; -import org.apache.http.message.BasicHeader; -import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.so.adapters.nssmf.entity.NssmfInfo; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.enums.JobStatus; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; -import org.onap.so.beans.nsmf.*; -import org.onap.so.db.request.beans.ResourceOperationStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import static java.lang.String.valueOf; -import static org.onap.so.adapters.nssmf.enums.JobStatus.*; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_FAILED; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_SUCCESS; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; - -public abstract class ExternalNssmfManager extends BaseNssmfManager { - - private static final Logger logger = LoggerFactory.getLogger(ExternalNssmfManager.class); - - @Override - protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return doWrapExtAllocateReqBody(nbiRequest); - } - - protected abstract String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - @Override - protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return doWrapModifyReqBody(nbiRequest); - } - - protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - @Override - protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { - return doWrapDeAllocateReqBody(deAllocateNssi); - } - - protected abstract String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException; - - @Override - protected void afterQueryJobStatus(ResourceOperationStatus status) { - logger.info("afterQueryJobStatus = " + status); - if (Integer.parseInt(status.getProgress()) == 100) { - logger.info("after query finished = " + status); - ActionType jobOperType = ActionType.valueOf(status.getOperType()); - - if (ActionType.ALLOCATE.equals(jobOperType)) { - ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo); - if (nssiInstance == null) { - nssiInstance = new ServiceInstance(); - } - - nssiInstance.setServiceInstanceId(serviceInfo.getNssiId()); - nssiInstance.setServiceInstanceName(serviceInfo.getNssiName()); - nssiInstance.setServiceType(serviceInfo.getSST()); - - nssiInstance.setOrchestrationStatus(initStatus); - nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid()); - nssiInstance.setModelVersionId(serviceInfo.getServiceUuid()); - nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList()); - nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType()); - nssiInstance.setServiceRole("nssi"); - - restUtil.createServiceInstance(nssiInstance, serviceInfo); - } else if (ActionType.DEALLOCATE.equals(jobOperType)) { - // TODO - restUtil.deleteServiceInstance(serviceInfo); - } - } - } - - @Override - protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException { - return marshal(actDeActNssi); - } - - @Override - protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException { - return doResponseStatus(status); - } - - private RestResponse doResponseStatus(ResourceOperationStatus status) throws ApplicationException { - RestResponse restResponse = sendRequest(null); - JobStatusResponse jobStatusResponse = unMarshal(restResponse.getResponseContent(), JobStatusResponse.class); - - ResponseDescriptor rspDesc = jobStatusResponse.getResponseDescriptor(); - - logger.info("status = {}", status); - rspDesc.setNssiId(status.getResourceInstanceID()); - - jobStatusResponse.setResponseDescriptor(rspDesc); - restResponse.setResponseContent(marshal(jobStatusResponse)); - updateRequestDbJobStatus(rspDesc, status, restResponse); - return restResponse; - } - - @Override - protected String wrapReqBody(Object object) throws ApplicationException { - return marshal(object); - } - - @Override - protected RestResponse sendRequest(String content) throws ApplicationException { - return sendExternalRequest(content); - } - - @Override - protected String getApiVersion() { - return "v1"; - } - - - // external - protected RestResponse sendExternalRequest(String content) throws ApplicationException { - NssmfInfo nssmfInfo = restUtil.getNssmfHost(esrInfo); - Header header = new BasicHeader("X-Auth-Token", restUtil.getToken(nssmfInfo)); - String nssmfUrl = nssmfInfo.getUrl() + this.nssmfUrl; - return restUtil.send(nssmfUrl, this.httpMethod, content, header); - } - - protected void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, - RestResponse rsp) throws ApplicationException { - status.setProgress(Integer.toString(rspDesc.getProgress())); - switch (fromString(rspDesc.getStatus())) { - case STARTED: - updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS); - break; - case PROCESSING: - updateDbStatus(status, rsp.getStatus(), PROCESSING, QUERY_JOB_STATUS_SUCCESS); - break; - case FINISHED: - if (rspDesc.getProgress() == 100) { - updateDbStatus(status, rsp.getStatus(), FINISHED, QUERY_JOB_STATUS_SUCCESS); - } - break; - case ERROR: - updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED); - throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); - default: - throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); - } - } - - protected void updateDbStatus(ResourceOperationStatus status, int rspStatus, JobStatus jobStatus, - String description) { - status.setErrorCode(valueOf(rspStatus)); - status.setStatus(jobStatus.toString()); - status.setStatusDescription(description); - repository.save(status); - } - - @Override - protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException { - - ObjectMapper oMapper = new ObjectMapper(); - InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json"); - Map subnetCapability = new HashMap<>(); - try { - subnetCapability = oMapper.readValue(inputStream, Map.class); - } catch (Exception e) { - logger.debug("Exception while reading subnet capability value from json", e); - } - Map<String, Object> responseMap = new HashMap<>(); - List<String> subnetTypes = req.getSubnetTypes(); - for (String value : subnetTypes) { - if (subnetCapability.containsKey(value)) { - responseMap.put(value, subnetCapability.get(value)); - } - } - String response = null; - try { - response = oMapper.writeValueAsString(responseMap); - } catch (JsonProcessingException e) { - logger.debug("Exception while converting subnet capability object to String {}", e.getMessage()); - } - - RestResponse rsp = new RestResponse(); - rsp.setStatus(HttpStatus.SC_OK); - rsp.setResponseContent(response); - return rsp; - } - - /** - * after request, if response code is 2XX, continue handle, else return - */ - @Override - protected void afterRequest() throws ApplicationException { - if (valueOf(restResponse.getStatus()).startsWith("2")) { - doAfterRequest(); - } - } - - - protected void doAfterRequest() throws ApplicationException { - // - NssiResponse response = unMarshal(restResponse.getResponseContent(), NssiResponse.class); - ResourceOperationStatus status = - new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(), serviceInfo.getServiceUuid()); - status.setResourceInstanceID(response.getNssiId()); - status.setOperType(actionType.toString()); - status.setProgress("0"); - - response.setStatus(STARTED.toString()); - restResponse.setResponseContent(marshal(response)); - updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType)); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.Header;
+import org.apache.http.HttpStatus;
+import org.apache.http.message.BasicHeader;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.JobStatus;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static java.lang.String.valueOf;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.*;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_FAILED;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_SUCCESS;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+
+public abstract class ExternalNssmfManager extends BaseNssmfManager {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExternalNssmfManager.class);
+
+ @Override
+ protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapExtAllocateReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapModifyReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ return doWrapDeAllocateReqBody(deAllocateNssi);
+ }
+
+ protected abstract String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException;
+
+ @Override
+ protected void afterQueryJobStatus(ResourceOperationStatus status) {
+ logger.info("afterQueryJobStatus = " + status);
+ if (Integer.parseInt(status.getProgress()) == 100) {
+ logger.info("after query finished = " + status);
+ ActionType jobOperType = ActionType.valueOf(status.getOperType());
+
+ if (ActionType.ALLOCATE.equals(jobOperType)) {
+ ServiceInstance nssiInstance = restUtil.getServiceInstance(serviceInfo);
+ if (nssiInstance == null) {
+ nssiInstance = new ServiceInstance();
+ }
+
+ nssiInstance.setServiceInstanceId(serviceInfo.getNssiId());
+ nssiInstance.setServiceInstanceName(serviceInfo.getNssiName());
+ nssiInstance.setServiceType(serviceInfo.getSST());
+
+ nssiInstance.setOrchestrationStatus(initStatus);
+ nssiInstance.setModelInvariantId(serviceInfo.getServiceInvariantUuid());
+ nssiInstance.setModelVersionId(serviceInfo.getServiceUuid());
+ nssiInstance.setServiceInstanceLocationId(serviceInfo.getPLMNIdList());
+ nssiInstance.setEnvironmentContext(esrInfo.getNetworkType().getNetworkType());
+ nssiInstance.setServiceRole("nssi");
+
+ restUtil.createServiceInstance(nssiInstance, serviceInfo);
+ } else if (ActionType.DEALLOCATE.equals(jobOperType)) {
+ // TODO
+ restUtil.deleteServiceInstance(serviceInfo);
+ }
+ }
+ }
+
+ @Override
+ protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException {
+ return marshal(actDeActNssi);
+ }
+
+ @Override
+ protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException {
+ return doResponseStatus(status);
+ }
+
+ private RestResponse doResponseStatus(ResourceOperationStatus status) throws ApplicationException {
+ RestResponse restResponse = sendRequest(null);
+ JobStatusResponse jobStatusResponse = unMarshal(restResponse.getResponseContent(), JobStatusResponse.class);
+
+ ResponseDescriptor rspDesc = jobStatusResponse.getResponseDescriptor();
+
+ logger.info("status = {}", status);
+ rspDesc.setNssiId(status.getResourceInstanceID());
+
+ jobStatusResponse.setResponseDescriptor(rspDesc);
+ restResponse.setResponseContent(marshal(jobStatusResponse));
+ updateRequestDbJobStatus(rspDesc, status, restResponse);
+ return restResponse;
+ }
+
+ @Override
+ protected String wrapReqBody(Object object) throws ApplicationException {
+ return marshal(object);
+ }
+
+ @Override
+ protected RestResponse sendRequest(String content) throws ApplicationException {
+ return sendExternalRequest(content);
+ }
+
+ @Override
+ protected String getApiVersion() {
+ return "v1";
+ }
+
+
+ // external
+ protected RestResponse sendExternalRequest(String content) throws ApplicationException {
+ NssmfInfo nssmfInfo = restUtil.getNssmfHost(esrInfo);
+ Header header = new BasicHeader("X-Auth-Token", restUtil.getToken(nssmfInfo));
+ String nssmfUrl = nssmfInfo.getUrl() + this.nssmfUrl;
+ return restUtil.send(nssmfUrl, this.httpMethod, content, header);
+ }
+
+ protected void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status,
+ RestResponse rsp) throws ApplicationException {
+ status.setProgress(Integer.toString(rspDesc.getProgress()));
+ switch (fromString(rspDesc.getStatus())) {
+ case STARTED:
+ updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS);
+ break;
+ case PROCESSING:
+ updateDbStatus(status, rsp.getStatus(), PROCESSING, QUERY_JOB_STATUS_SUCCESS);
+ break;
+ case FINISHED:
+ if (rspDesc.getProgress() == 100) {
+ updateDbStatus(status, rsp.getStatus(), FINISHED, QUERY_JOB_STATUS_SUCCESS);
+ }
+ break;
+ case ERROR:
+ updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED);
+ throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED);
+ default:
+ throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED);
+ }
+ }
+
+ protected void updateDbStatus(ResourceOperationStatus status, int rspStatus, JobStatus jobStatus,
+ String description) {
+ status.setErrorCode(valueOf(rspStatus));
+ status.setStatus(jobStatus.toString());
+ status.setStatusDescription(description);
+ repository.save(status);
+ }
+
+ @Override
+ protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
+
+ ObjectMapper oMapper = new ObjectMapper();
+ InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json");
+ Map subnetCapability = new HashMap<>();
+ try {
+ subnetCapability = oMapper.readValue(inputStream, Map.class);
+ } catch (Exception e) {
+ logger.debug("Exception while reading subnet capability value from json", e);
+ }
+ Map<String, Object> responseMap = new HashMap<>();
+ List<String> subnetTypes = req.getSubnetTypes();
+ for (String value : subnetTypes) {
+ if (subnetCapability.containsKey(value)) {
+ responseMap.put(value, subnetCapability.get(value));
+ }
+ }
+ String response = null;
+ try {
+ response = oMapper.writeValueAsString(responseMap);
+ } catch (JsonProcessingException e) {
+ logger.debug("Exception while converting subnet capability object to String {}", e.getMessage());
+ }
+
+ RestResponse rsp = new RestResponse();
+ rsp.setStatus(HttpStatus.SC_OK);
+ rsp.setResponseContent(response);
+ return rsp;
+ }
+
+ /**
+ * after request, if response code is 2XX, continue handle, else return
+ */
+ @Override
+ protected void afterRequest() throws ApplicationException {
+ if (valueOf(restResponse.getStatus()).startsWith("2")) {
+ doAfterRequest();
+ }
+ }
+
+
+ protected void doAfterRequest() throws ApplicationException {
+ //
+ NssiResponse response = unMarshal(restResponse.getResponseContent(), NssiResponse.class);
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(), serviceInfo.getServiceUuid());
+ status.setResourceInstanceID(response.getNssiId());
+ status.setOperType(actionType.toString());
+ status.setProgress("0");
+
+ response.setStatus(STARTED.toString());
+ restResponse.setResponseContent(marshal(response));
+ updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType));
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java index 64ab199..49f1306 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java @@ -1,130 +1,130 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl; - -import org.apache.http.Header; -import org.apache.http.message.BasicHeader; -import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.adapters.nssmf.enums.SelectionType; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.beans.nsmf.*; -import org.onap.so.db.request.beans.ResourceOperationStatus; -import static org.onap.so.adapters.nssmf.enums.JobStatus.PROCESSING; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - -public abstract class InternalNssmfManager extends BaseNssmfManager { - - @Override - protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return doWrapAllocateReqBody(nbiRequest); - } - - protected abstract String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - @Override - protected String wrapReqBody(Object object) throws ApplicationException { - NssmfRequest nssmfRequest = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), object); - return marshal(nssmfRequest); - } - - - @Override - protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException { - - return wrapReqBody(actDeActNssi); - } - - - @Override - protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { - return wrapReqBody(deAllocateNssi); - } - - - @Override - protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException { - return responseDBStatus(status); - } - - private RestResponse responseDBStatus(ResourceOperationStatus status) throws ApplicationException { - JobStatusResponse statusResponse = new JobStatusResponse(); - ResponseDescriptor descriptor = new ResponseDescriptor(); - if (status == null) { - descriptor.setProgress(0); - descriptor.setStatus(PROCESSING.name()); - descriptor.setStatusDescription("Initiating Nssi Instance"); - } else { - descriptor.setStatus(status.getStatus()); - descriptor.setStatusDescription(status.getStatusDescription()); - descriptor.setProgress(Integer.parseInt(status.getProgress())); - descriptor.setNssiId(status.getResourceInstanceID()); - } - statusResponse.setResponseDescriptor(descriptor); - return restUtil.createResponse(200, marshal(statusResponse)); - } - - @Override - protected RestResponse sendRequest(String content) { - return sendInternalRequest(content); - } - - @Override - protected void afterRequest() { - // - } - - @Override - protected void afterQueryJobStatus(ResourceOperationStatus status) { - // internal - } - - // internal - private RestResponse sendInternalRequest(String content) { - Header header = new BasicHeader("Authorization", adapterConfig.getInfraAuth()); - this.nssmfUrl = adapterConfig.getInfraEndpoint() + this.nssmfUrl; - return restUtil.send(this.nssmfUrl, this.httpMethod, content, header); - } - - @Override - protected String getApiVersion() { - return NssmfAdapterConsts.CURRENT_INTERNAL_NSSMF_API_VERSION; - } - - - @Override - protected SelectionType doQueryNSSISelectionCapability() { - return SelectionType.NSSMF; - } - - @Override - protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return doWrapModifyReqBody(nbiRequest); - } - - protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException; - - @Override - protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException { - // handler - return sendRequest(marshal(req)); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl;
+
+import org.apache.http.Header;
+import org.apache.http.message.BasicHeader;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.SelectionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import static org.onap.so.adapters.nssmf.enums.JobStatus.PROCESSING;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public abstract class InternalNssmfManager extends BaseNssmfManager {
+
+ @Override
+ protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapAllocateReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected String wrapReqBody(Object object) throws ApplicationException {
+ NssmfRequest nssmfRequest = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), object);
+ return marshal(nssmfRequest);
+ }
+
+
+ @Override
+ protected String wrapActDeActReqBody(ActDeActNssi actDeActNssi) throws ApplicationException {
+
+ return wrapReqBody(actDeActNssi);
+ }
+
+
+ @Override
+ protected String wrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ return wrapReqBody(deAllocateNssi);
+ }
+
+
+ @Override
+ protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException {
+ return responseDBStatus(status);
+ }
+
+ private RestResponse responseDBStatus(ResourceOperationStatus status) throws ApplicationException {
+ JobStatusResponse statusResponse = new JobStatusResponse();
+ ResponseDescriptor descriptor = new ResponseDescriptor();
+ if (status == null) {
+ descriptor.setProgress(0);
+ descriptor.setStatus(PROCESSING.name());
+ descriptor.setStatusDescription("Initiating Nssi Instance");
+ } else {
+ descriptor.setStatus(status.getStatus());
+ descriptor.setStatusDescription(status.getStatusDescription());
+ descriptor.setProgress(Integer.parseInt(status.getProgress()));
+ descriptor.setNssiId(status.getResourceInstanceID());
+ }
+ statusResponse.setResponseDescriptor(descriptor);
+ return restUtil.createResponse(200, marshal(statusResponse));
+ }
+
+ @Override
+ protected RestResponse sendRequest(String content) {
+ return sendInternalRequest(content);
+ }
+
+ @Override
+ protected void afterRequest() {
+ //
+ }
+
+ @Override
+ protected void afterQueryJobStatus(ResourceOperationStatus status) {
+ // internal
+ }
+
+ // internal
+ private RestResponse sendInternalRequest(String content) {
+ Header header = new BasicHeader("Authorization", adapterConfig.getInfraAuth());
+ this.nssmfUrl = adapterConfig.getInfraEndpoint() + this.nssmfUrl;
+ return restUtil.send(this.nssmfUrl, this.httpMethod, content, header);
+ }
+
+ @Override
+ protected String getApiVersion() {
+ return NssmfAdapterConsts.CURRENT_INTERNAL_NSSMF_API_VERSION;
+ }
+
+
+ @Override
+ protected SelectionType doQueryNSSISelectionCapability() {
+ return SelectionType.NSSMF;
+ }
+
+ @Override
+ protected String wrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return doWrapModifyReqBody(nbiRequest);
+ }
+
+ protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
+
+ @Override
+ protected RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
+ // handler
+ return sendRequest(marshal(req));
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index 0f4352d..cd4d637 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -1,171 +1,171 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl.external; - -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.enums.JobStatus; -import org.onap.so.adapters.nssmf.enums.SelectionType; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager; -import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; -import org.onap.so.beans.nsmf.AnSliceProfile; -import org.onap.so.beans.nsmf.DeAllocateNssi; -import org.onap.so.beans.nsmf.NssiResponse; -import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; -import org.onap.so.beans.nsmf.ResponseDescriptor; -import org.onap.so.beans.nsmf.JobStatusResponse; -import org.onap.so.db.request.beans.ResourceOperationStatus; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; - - -public class ExternalAnNssmfManager extends ExternalNssmfManager { - - private Map<String, String> bodyParams = new HashMap<>(); // request body params - - @Override - protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - Map<String, Object> request = new HashMap<>(); - - AnSliceProfile anSliceProfile = nbiRequest.getAllocateAnNssi().getSliceProfile(); - - RanSliceProfile ranSliceProfile = new RanSliceProfile(); - ranSliceProfile.setSliceProfileId(anSliceProfile.getSliceProfileId()); - ranSliceProfile.setSNSSAIList(anSliceProfile.getSNSSAIList()); - ranSliceProfile.setPLMNIdList(anSliceProfile.getPLMNIdList()); - ranSliceProfile.setPerfReq(anSliceProfile.getPerfReq()); - ranSliceProfile.setMaxNumberofUEs(anSliceProfile.getMaxNumberOfUEs()); - ranSliceProfile.setCoverageAreaTAList(anSliceProfile.getCoverageAreaTAList()); - ranSliceProfile.setLatency(anSliceProfile.getLatency()); - ranSliceProfile.setUEMobilityLevel(anSliceProfile.getUeMobilityLevel()); - ranSliceProfile.setResourceSharingLevel(anSliceProfile.getResourceSharingLevel()); - - request.put("attributeListIn", ranSliceProfile); - return marshal(request); - } - - @Override - protected void doAfterRequest() throws ApplicationException { - if (ActionType.ALLOCATE.equals(actionType) || ActionType.DEALLOCATE.equals(actionType)) { - String nssiId; - if (ActionType.ALLOCATE.equals(actionType)) { - @SuppressWarnings("unchecked") - Map<String, String> response = unMarshal(restResponse.getResponseContent(), Map.class); - nssiId = response.get("href"); - } else { - nssiId = this.bodyParams.get("nssiId"); - } - - NssiResponse resp = new NssiResponse(); - resp.setJobId(UUID.randomUUID().toString()); - resp.setNssiId(nssiId); - - RestResponse returnRsp = new RestResponse(); - - returnRsp.setStatus(202); - returnRsp.setResponseContent(marshal(resp)); - restResponse = returnRsp; - - ResourceOperationStatus status = - new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid()); - status.setResourceInstanceID(nssiId); - status.setOperType(actionType.toString()); - - updateDbStatus(status, restResponse.getStatus(), JobStatus.STARTED, - NssmfAdapterUtil.getStatusDesc(actionType)); - } - // todo - } - - @Override - protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - // TODO - return null; - } - - @Override - protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { - this.bodyParams.clear(); - this.bodyParams.put("nssiId", deAllocateNssi.getNssiId()); - - Map<String, String> request = new HashMap<>(); - request.put("nSSId", deAllocateNssi.getNssiId()); - return marshal(request); - } - - - @Override - public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException { - // TODO - return null; - } - - @Override - public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException { - NssiResponse resp = new NssiResponse(); - String nssiId = nbiRequest.getActDeActNssi().getNssiId(); - resp.setJobId(UUID.randomUUID().toString()); - resp.setNssiId(nssiId); - - RestResponse returnRsp = new RestResponse(); - - returnRsp.setStatus(202); - returnRsp.setResponseContent(marshal(resp)); - - ResourceOperationStatus status = - new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid()); - status.setResourceInstanceID(nssiId); - status.setOperType(actionType.toString()); - - updateDbStatus(status, returnRsp.getStatus(), JobStatus.FINISHED, NssmfAdapterUtil.getStatusDesc(actionType)); - return returnRsp; - } - - @Override - protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException { - ResponseDescriptor responseDescriptor = new ResponseDescriptor(); - responseDescriptor.setStatus(JobStatus.FINISHED.toString()); - responseDescriptor.setProgress(100); - responseDescriptor.setStatusDescription("Finished"); - - JobStatusResponse jobStatusResponse = new JobStatusResponse(); - jobStatusResponse.setResponseDescriptor(responseDescriptor); - - RestResponse restResponse = new RestResponse(); - restResponse.setStatus(200); - restResponse.setResponseContent(marshal(jobStatusResponse)); - - updateRequestDbJobStatus(responseDescriptor, status, restResponse); - - status.setProgress(Integer.toString(responseDescriptor.getProgress())); - - return restResponse; - } - - @Override - protected SelectionType doQueryNSSISelectionCapability() { - return SelectionType.NSSMF; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl.external;
+
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.JobStatus;
+import org.onap.so.adapters.nssmf.enums.SelectionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager;
+import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil;
+import org.onap.so.beans.nsmf.AnSliceProfile;
+import org.onap.so.beans.nsmf.DeAllocateNssi;
+import org.onap.so.beans.nsmf.NssiResponse;
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest;
+import org.onap.so.beans.nsmf.ResponseDescriptor;
+import org.onap.so.beans.nsmf.JobStatusResponse;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+
+
+public class ExternalAnNssmfManager extends ExternalNssmfManager {
+
+ private Map<String, String> bodyParams = new HashMap<>(); // request body params
+
+ @Override
+ protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ Map<String, Object> request = new HashMap<>();
+
+ AnSliceProfile anSliceProfile = nbiRequest.getAllocateAnNssi().getSliceProfile();
+
+ RanSliceProfile ranSliceProfile = new RanSliceProfile();
+ ranSliceProfile.setSliceProfileId(anSliceProfile.getSliceProfileId());
+ ranSliceProfile.setSNSSAIList(anSliceProfile.getSNSSAIList());
+ ranSliceProfile.setPLMNIdList(anSliceProfile.getPLMNIdList());
+ ranSliceProfile.setPerfReq(anSliceProfile.getPerfReq());
+ ranSliceProfile.setMaxNumberofUEs(anSliceProfile.getMaxNumberOfUEs());
+ ranSliceProfile.setCoverageAreaTAList(anSliceProfile.getCoverageAreaTAList());
+ ranSliceProfile.setLatency(anSliceProfile.getLatency());
+ ranSliceProfile.setUEMobilityLevel(anSliceProfile.getUeMobilityLevel());
+ ranSliceProfile.setResourceSharingLevel(anSliceProfile.getResourceSharingLevel());
+
+ request.put("attributeListIn", ranSliceProfile);
+ return marshal(request);
+ }
+
+ @Override
+ protected void doAfterRequest() throws ApplicationException {
+ if (ActionType.ALLOCATE.equals(actionType) || ActionType.DEALLOCATE.equals(actionType)) {
+ String nssiId;
+ if (ActionType.ALLOCATE.equals(actionType)) {
+ @SuppressWarnings("unchecked")
+ Map<String, String> response = unMarshal(restResponse.getResponseContent(), Map.class);
+ nssiId = response.get("href");
+ } else {
+ nssiId = this.bodyParams.get("nssiId");
+ }
+
+ NssiResponse resp = new NssiResponse();
+ resp.setJobId(UUID.randomUUID().toString());
+ resp.setNssiId(nssiId);
+
+ RestResponse returnRsp = new RestResponse();
+
+ returnRsp.setStatus(202);
+ returnRsp.setResponseContent(marshal(resp));
+ restResponse = returnRsp;
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid());
+ status.setResourceInstanceID(nssiId);
+ status.setOperType(actionType.toString());
+
+ updateDbStatus(status, restResponse.getStatus(), JobStatus.STARTED,
+ NssmfAdapterUtil.getStatusDesc(actionType));
+ }
+ // todo
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ // TODO
+ return null;
+ }
+
+ @Override
+ protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ this.bodyParams.clear();
+ this.bodyParams.put("nssiId", deAllocateNssi.getNssiId());
+
+ Map<String, String> request = new HashMap<>();
+ request.put("nSSId", deAllocateNssi.getNssiId());
+ return marshal(request);
+ }
+
+
+ @Override
+ public RestResponse modifyNssi(NssmfAdapterNBIRequest modifyRequest) throws ApplicationException {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public RestResponse activateNssi(NssmfAdapterNBIRequest nbiRequest, String snssai) throws ApplicationException {
+ NssiResponse resp = new NssiResponse();
+ String nssiId = nbiRequest.getActDeActNssi().getNssiId();
+ resp.setJobId(UUID.randomUUID().toString());
+ resp.setNssiId(nssiId);
+
+ RestResponse returnRsp = new RestResponse();
+
+ returnRsp.setStatus(202);
+ returnRsp.setResponseContent(marshal(resp));
+
+ ResourceOperationStatus status =
+ new ResourceOperationStatus(serviceInfo.getNsiId(), resp.getJobId(), serviceInfo.getServiceUuid());
+ status.setResourceInstanceID(nssiId);
+ status.setOperType(actionType.toString());
+
+ updateDbStatus(status, returnRsp.getStatus(), JobStatus.FINISHED, NssmfAdapterUtil.getStatusDesc(actionType));
+ return returnRsp;
+ }
+
+ @Override
+ protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException {
+ ResponseDescriptor responseDescriptor = new ResponseDescriptor();
+ responseDescriptor.setStatus(JobStatus.FINISHED.toString());
+ responseDescriptor.setProgress(100);
+ responseDescriptor.setStatusDescription("Finished");
+
+ JobStatusResponse jobStatusResponse = new JobStatusResponse();
+ jobStatusResponse.setResponseDescriptor(responseDescriptor);
+
+ RestResponse restResponse = new RestResponse();
+ restResponse.setStatus(200);
+ restResponse.setResponseContent(marshal(jobStatusResponse));
+
+ updateRequestDbJobStatus(responseDescriptor, status, restResponse);
+
+ status.setProgress(Integer.toString(responseDescriptor.getProgress()));
+
+ return restResponse;
+ }
+
+ @Override
+ protected SelectionType doQueryNSSISelectionCapability() {
+ return SelectionType.NSSMF;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java index fb76adc..f38bc62 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalCnNssmfManager.java @@ -1,53 +1,53 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl.external; - -import org.onap.so.adapters.nssmf.enums.SelectionType; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager; -import org.onap.so.beans.nsmf.DeAllocateNssi; -import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - -public class ExternalCnNssmfManager extends ExternalNssmfManager { - - @Override - protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return marshal(nbiRequest.getAllocateCnNssi()); - } - - @Override - protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - return marshal(nbiRequest.getAllocateCnNssi()); - } - - @Override - protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException { - return marshal(deAllocateNssi); - } - - @Override - protected SelectionType doQueryNSSISelectionCapability() { - - return SelectionType.NSMF; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl.external;
+
+import org.onap.so.adapters.nssmf.enums.SelectionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager;
+import org.onap.so.beans.nsmf.DeAllocateNssi;
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class ExternalCnNssmfManager extends ExternalNssmfManager {
+
+ @Override
+ protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return marshal(nbiRequest.getAllocateCnNssi());
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ return marshal(nbiRequest.getAllocateCnNssi());
+ }
+
+ @Override
+ protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ return marshal(deAllocateNssi);
+ }
+
+ @Override
+ protected SelectionType doQueryNSSISelectionCapability() {
+
+ return SelectionType.NSMF;
+ }
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java index 7035456..baf9019 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java @@ -1,70 +1,70 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl.external; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import java.io.Serializable; -import java.util.List; -import org.onap.so.beans.nsmf.PerfReq; -import org.onap.so.beans.nsmf.UeMobilityLevel; -import org.onap.so.beans.nsmf.ResourceSharingLevel; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@Data -public class RanSliceProfile implements Serializable { - /* - * Reference 3GPP TS 28.541 V16.5.0, Section 6.3.4. - */ - - private static final long serialVersionUID = 172447042469370448L; - - @JsonProperty(value = "sliceProfileId", required = true) - private String sliceProfileId; - - @JsonProperty(value = "sNSSAIList", required = true) - private List<String> sNSSAIList; - - @JsonProperty(value = "pLMNIdList", required = true) - private List<String> pLMNIdList; - - @JsonProperty(value = "perfReq", required = true) - private PerfReq perfReq; - - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - @JsonProperty(value = "maxNumberofUEs") - private long maxNumberofUEs; - - @JsonProperty(value = "coverageAreaTAList") - private List<Integer> coverageAreaTAList; - - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - @JsonProperty(value = "latency") - private int latency; - - @JsonProperty(value = "uEMobilityLevel") - private UeMobilityLevel uEMobilityLevel; - - @JsonProperty(value = "resourceSharingLevel") - private ResourceSharingLevel resourceSharingLevel; - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl.external;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.List;
+import org.onap.so.beans.nsmf.PerfReq;
+import org.onap.so.beans.nsmf.UeMobilityLevel;
+import org.onap.so.beans.nsmf.ResourceSharingLevel;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Data
+public class RanSliceProfile implements Serializable {
+ /*
+ * Reference 3GPP TS 28.541 V16.5.0, Section 6.3.4.
+ */
+
+ private static final long serialVersionUID = 172447042469370448L;
+
+ @JsonProperty(value = "sliceProfileId", required = true)
+ private String sliceProfileId;
+
+ @JsonProperty(value = "sNSSAIList", required = true)
+ private List<String> sNSSAIList;
+
+ @JsonProperty(value = "pLMNIdList", required = true)
+ private List<String> pLMNIdList;
+
+ @JsonProperty(value = "perfReq", required = true)
+ private PerfReq perfReq;
+
+ @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "maxNumberofUEs")
+ private long maxNumberofUEs;
+
+ @JsonProperty(value = "coverageAreaTAList")
+ private List<Integer> coverageAreaTAList;
+
+ @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "latency")
+ private int latency;
+
+ @JsonProperty(value = "uEMobilityLevel")
+ private UeMobilityLevel uEMobilityLevel;
+
+ @JsonProperty(value = "resourceSharingLevel")
+ private ResourceSharingLevel resourceSharingLevel;
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java index dc65283..de0f1c7 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalAnNssmfManager.java @@ -1,54 +1,54 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl.internal; - -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager; -import org.onap.so.beans.nsmf.*; -import java.util.HashMap; -import java.util.Map; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - - -public class InternalAnNssmfManager extends InternalNssmfManager { - - @Override - protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - NssmfRequest request = - new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateAnNssi()); - request.setName(nbiRequest.getAllocateAnNssi().getNssiName()); - return marshal(request); - } - - @Override - protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - AllocateAnNssi allocateAnNssi = nbiRequest.getAllocateAnNssi(); - AnSliceProfile sliceProfile = allocateAnNssi.getSliceProfile(); - Map<String, Object> additional = new HashMap<>(); - additional.put("modifyAction", "allocate"); - additional.put("snssaiList", sliceProfile.getSNSSAIList()); - additional.put("sliceProfileId", sliceProfile.getSliceProfileId()); - additional.put("nsiInfo", allocateAnNssi.getNsiInfo()); - additional.put("scriptName", allocateAnNssi.getScriptName()); - NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional); - return marshal(request); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl.internal;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager;
+import org.onap.so.beans.nsmf.*;
+import java.util.HashMap;
+import java.util.Map;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+
+public class InternalAnNssmfManager extends InternalNssmfManager {
+
+ @Override
+ protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ NssmfRequest request =
+ new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateAnNssi());
+ request.setName(nbiRequest.getAllocateAnNssi().getNssiName());
+ return marshal(request);
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ AllocateAnNssi allocateAnNssi = nbiRequest.getAllocateAnNssi();
+ AnSliceProfile sliceProfile = allocateAnNssi.getSliceProfile();
+ Map<String, Object> additional = new HashMap<>();
+ additional.put("modifyAction", "allocate");
+ additional.put("snssaiList", sliceProfile.getSNSSAIList());
+ additional.put("sliceProfileId", sliceProfile.getSliceProfileId());
+ additional.put("nsiInfo", allocateAnNssi.getNsiInfo());
+ additional.put("scriptName", allocateAnNssi.getScriptName());
+ NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional);
+ return marshal(request);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java index 4a93b30..3f594cc 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalCnNssmfManager.java @@ -1,56 +1,56 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl.internal; - -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager; -import org.onap.so.beans.nsmf.*; -import java.util.HashMap; -import java.util.Map; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - -public class InternalCnNssmfManager extends InternalNssmfManager { - - @Override - protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - - NssmfRequest request = - new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateCnNssi()); - request.setName(nbiRequest.getAllocateCnNssi().getNssiName()); - return marshal(request); - } - - @Override - protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - AllocateCnNssi allocateCnNssi = nbiRequest.getAllocateCnNssi(); - CnSliceProfile cnSliceProfile = allocateCnNssi.getSliceProfile(); - Map<String, Object> additional = new HashMap<>(); - additional.put("modifyAction", "allocate"); - additional.put("nsiInfo", allocateCnNssi.getNsiInfo()); - additional.put("scriptName", allocateCnNssi.getScriptName()); - additional.put("snssaiList", cnSliceProfile.getSnssaiList()); - additional.put("sliceProfileId", cnSliceProfile.getSliceProfileId()); - - NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional); - return marshal(request); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl.internal;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager;
+import org.onap.so.beans.nsmf.*;
+import java.util.HashMap;
+import java.util.Map;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class InternalCnNssmfManager extends InternalNssmfManager {
+
+ @Override
+ protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+
+ NssmfRequest request =
+ new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), nbiRequest.getAllocateCnNssi());
+ request.setName(nbiRequest.getAllocateCnNssi().getNssiName());
+ return marshal(request);
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ AllocateCnNssi allocateCnNssi = nbiRequest.getAllocateCnNssi();
+ CnSliceProfile cnSliceProfile = allocateCnNssi.getSliceProfile();
+ Map<String, Object> additional = new HashMap<>();
+ additional.put("modifyAction", "allocate");
+ additional.put("nsiInfo", allocateCnNssi.getNsiInfo());
+ additional.put("scriptName", allocateCnNssi.getScriptName());
+ additional.put("snssaiList", cnSliceProfile.getSnssaiList());
+ additional.put("sliceProfileId", cnSliceProfile.getSliceProfileId());
+
+ NssmfRequest request = new NssmfRequest(serviceInfo, esrInfo.getNetworkType(), additional);
+ return marshal(request);
+ }
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java index 1b4a9e9..c915684 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/manager/impl/internal/InternalTnNssmfManager.java @@ -1,42 +1,42 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.manager.impl.internal; - -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager; -import org.onap.so.beans.nsmf.*; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; - -public class InternalTnNssmfManager extends InternalNssmfManager { - - @Override - protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - - return marshal(new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(), - nbiRequest.getAllocateTnNssi())); - } - - @Override - protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { - // TODO - return doWrapAllocateReqBody(nbiRequest); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.manager.impl.internal;
+
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.impl.InternalNssmfManager;
+import org.onap.so.beans.nsmf.*;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+
+public class InternalTnNssmfManager extends InternalNssmfManager {
+
+ @Override
+ protected String doWrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+
+ return marshal(new NssmfRequest(serviceInfo, nbiRequest.getEsrInfo().getNetworkType(),
+ nbiRequest.getAllocateTnNssi()));
+ }
+
+ @Override
+ protected String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
+ // TODO
+ return doWrapAllocateReqBody(nbiRequest);
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java index 92fe557..8355fcf 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/service/NssmfManagerService.java @@ -1,45 +1,45 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.service; - -import org.onap.so.adapters.nssmf.annotation.ServiceLogger; -import org.onap.so.beans.nsmf.*; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; - -@Service -@ServiceLogger -public interface NssmfManagerService { - ResponseEntity allocateNssi(NssmfAdapterNBIRequest allocateRequest); - - ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest allocateRequest, String sliceProfileId); - - ResponseEntity activateNssi(NssmfAdapterNBIRequest deActRequest, String snssai); - - ResponseEntity deActivateNssi(NssmfAdapterNBIRequest nssiDeActivate, String snssai); - - ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId); - - ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest); - - ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest); - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.service;
+
+import org.onap.so.adapters.nssmf.annotation.ServiceLogger;
+import org.onap.so.beans.nsmf.*;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+@Service
+@ServiceLogger
+public interface NssmfManagerService {
+ ResponseEntity allocateNssi(NssmfAdapterNBIRequest allocateRequest);
+
+ ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest allocateRequest, String sliceProfileId);
+
+ ResponseEntity activateNssi(NssmfAdapterNBIRequest deActRequest, String snssai);
+
+ ResponseEntity deActivateNssi(NssmfAdapterNBIRequest nssiDeActivate, String snssai);
+
+ ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId);
+
+ ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest);
+
+ ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest);
+
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java index 5b53856..960632a 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImpl.java @@ -1,143 +1,143 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.service.impl; - -import org.apache.commons.lang3.StringUtils; -import org.onap.so.adapters.nssmf.annotation.ServiceLogger; -import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.manager.NssmfManagerBuilder; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.adapters.nssmf.manager.NssmfManager; -import org.onap.so.adapters.nssmf.service.NssmfManagerService; -import org.onap.so.adapters.nssmf.util.RestUtil; -import org.onap.so.beans.nsmf.*; -import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; - - -@Service -@ServiceLogger -public class NssmfManagerServiceImpl implements NssmfManagerService { - - @Autowired - private RestUtil restUtil; - - @Autowired - private ResourceOperationStatusRepository repository; - - @Autowired - private NssmfAdapterConfig nssmfAdapterConfig; - - @Override - public ResponseEntity allocateNssi(NssmfAdapterNBIRequest request) { - try { - - if (StringUtils.isNotBlank(request.getServiceInfo().getNssiId())) { - return buildResponse(buildNssmfManager(request, ActionType.MODIFY).modifyNssi(request)); - } - - return buildResponse(buildNssmfManager(request, ActionType.ALLOCATE).allocateNssi(request)); - - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @Override - public ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest request, String sliceProfileId) { - try { - return buildResponse( - buildNssmfManager(request, ActionType.DEALLOCATE).deAllocateNssi(request, sliceProfileId)); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @Override - public ResponseEntity activateNssi(NssmfAdapterNBIRequest request, String snssai) { - try { - return buildResponse(buildNssmfManager(request, ActionType.ACTIVATE).activateNssi(request, snssai)); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @Override - public ResponseEntity deActivateNssi(NssmfAdapterNBIRequest request, String snssai) { - try { - return buildResponse(buildNssmfManager(request, ActionType.DEACTIVATE).deActivateNssi(request, snssai)); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @Override - public ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) { - try { - return buildResponse(buildNssmfManager(jobReq, ActionType.QUERY_JOB_STATUS).queryJobStatus(jobReq, jobId)); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @Override - public ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) { - EsrInfo esrInfo = nbiRequest.getEsrInfo(); - try { - return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_NSSI_SELECTION_CAPABILITY, null) - .queryNSSISelectionCapability(nbiRequest)); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - @Override - public ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) { - EsrInfo esrInfo = nbiRequest.getEsrInfo(); - try { - return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_SUB_NET_CAPABILITY, null) - .querySubnetCapability(nbiRequest)); - } catch (ApplicationException e) { - return e.buildErrorResponse(); - } - } - - private ResponseEntity buildResponse(RestResponse rsp) { - return ResponseEntity.status(rsp.getStatus()).body(rsp.getResponseContent()); - } - - - private NssmfManager buildNssmfManager(NssmfAdapterNBIRequest request, ActionType actionType) - throws ApplicationException { - return buildNssmfManager(request.getEsrInfo(), actionType, request.getServiceInfo()); - } - - private NssmfManager buildNssmfManager(EsrInfo esrInfo, ActionType actionType, ServiceInfo serviceInfo) - throws ApplicationException { - - return new NssmfManagerBuilder(esrInfo).setActionType(actionType).setRepository(repository) - .setRestUtil(restUtil).setAdapterConfig(nssmfAdapterConfig).setServiceInfo(serviceInfo).build(); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.service.impl;
+
+import org.apache.commons.lang3.StringUtils;
+import org.onap.so.adapters.nssmf.annotation.ServiceLogger;
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.manager.NssmfManagerBuilder;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.manager.NssmfManager;
+import org.onap.so.adapters.nssmf.service.NssmfManagerService;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+
+@Service
+@ServiceLogger
+public class NssmfManagerServiceImpl implements NssmfManagerService {
+
+ @Autowired
+ private RestUtil restUtil;
+
+ @Autowired
+ private ResourceOperationStatusRepository repository;
+
+ @Autowired
+ private NssmfAdapterConfig nssmfAdapterConfig;
+
+ @Override
+ public ResponseEntity allocateNssi(NssmfAdapterNBIRequest request) {
+ try {
+
+ if (StringUtils.isNotBlank(request.getServiceInfo().getNssiId())) {
+ return buildResponse(buildNssmfManager(request, ActionType.MODIFY).modifyNssi(request));
+ }
+
+ return buildResponse(buildNssmfManager(request, ActionType.ALLOCATE).allocateNssi(request));
+
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity deAllocateNssi(NssmfAdapterNBIRequest request, String sliceProfileId) {
+ try {
+ return buildResponse(
+ buildNssmfManager(request, ActionType.DEALLOCATE).deAllocateNssi(request, sliceProfileId));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity activateNssi(NssmfAdapterNBIRequest request, String snssai) {
+ try {
+ return buildResponse(buildNssmfManager(request, ActionType.ACTIVATE).activateNssi(request, snssai));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity deActivateNssi(NssmfAdapterNBIRequest request, String snssai) {
+ try {
+ return buildResponse(buildNssmfManager(request, ActionType.DEACTIVATE).deActivateNssi(request, snssai));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity queryJobStatus(NssmfAdapterNBIRequest jobReq, String jobId) {
+ try {
+ return buildResponse(buildNssmfManager(jobReq, ActionType.QUERY_JOB_STATUS).queryJobStatus(jobReq, jobId));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity queryNSSISelectionCapability(NssmfAdapterNBIRequest nbiRequest) {
+ EsrInfo esrInfo = nbiRequest.getEsrInfo();
+ try {
+ return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_NSSI_SELECTION_CAPABILITY, null)
+ .queryNSSISelectionCapability(nbiRequest));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ @Override
+ public ResponseEntity querySubnetCapability(NssmfAdapterNBIRequest nbiRequest) {
+ EsrInfo esrInfo = nbiRequest.getEsrInfo();
+ try {
+ return buildResponse(buildNssmfManager(esrInfo, ActionType.QUERY_SUB_NET_CAPABILITY, null)
+ .querySubnetCapability(nbiRequest));
+ } catch (ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
+
+ private ResponseEntity buildResponse(RestResponse rsp) {
+ return ResponseEntity.status(rsp.getStatus()).body(rsp.getResponseContent());
+ }
+
+
+ private NssmfManager buildNssmfManager(NssmfAdapterNBIRequest request, ActionType actionType)
+ throws ApplicationException {
+ return buildNssmfManager(request.getEsrInfo(), actionType, request.getServiceInfo());
+ }
+
+ private NssmfManager buildNssmfManager(EsrInfo esrInfo, ActionType actionType, ServiceInfo serviceInfo)
+ throws ApplicationException {
+
+ return new NssmfManagerBuilder(esrInfo).setActionType(actionType).setRepository(repository)
+ .setRestUtil(restUtil).setAdapterConfig(nssmfAdapterConfig).setServiceInfo(serviceInfo).build();
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java index 090417d..d45aac4 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/util/NssmfAdapterUtil.java @@ -1,123 +1,123 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.onap.logging.filter.base.ErrorCode; -import org.springframework.stereotype.Component; -import static org.onap.so.logger.LoggingAnchor.THREE; -import static org.onap.so.logger.MessageEnum.RA_NS_EXC; - -public class NssmfAdapterUtil { - - private static final Logger LOGGER = LoggerFactory.getLogger(NssmfAdapterUtil.class); - - public static final int BAD_REQUEST = 400; - - private static final String UNMARSHAL_FAIL_MSG = "Failed to unmarshal json"; - - private static final String MARSHAL_FAIL_MSG = "Failed to marshal object"; - - private static final ObjectMapper MAPPER = new ObjectMapper(); - - public static class StatusDesc { - - public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful"; - - public static final String MODIFY_NSS_SUCCESS = "Modify nss is " + "successful"; - - public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful"; - - public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful"; - - public static final String ACTIVATE_NSS_SUCCESS = "Activate nss " + "is successful"; - - public static final String DEACTIVATE_NSS_SUCCESS = "Deactivate nss " + "is successful"; - - public static final String QUERY_JOB_STATUS_FAILED = "Query job " + "status failed"; - - public static final String QUERY_JOB_STATUS_SUCCESS = "Query job " + "status is successful"; - - private StatusDesc() { - - } - } - - private NssmfAdapterUtil() { - - } - - public static void assertObjectNotNull(Object object) throws ApplicationException { - if (null == object) { - LOGGER.error("Object is null."); - throw new ApplicationException(BAD_REQUEST, "An object is null."); - } - } - - public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException { - try { - return MAPPER.readValue(jsonstr, type); - } catch (IOException e) { - LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e); - throw new ApplicationException(BAD_REQUEST, UNMARSHAL_FAIL_MSG); - } - } - - public static String marshal(Object srcObj) throws ApplicationException { - try { - return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(srcObj); - } catch (IOException e) { - LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), MARSHAL_FAIL_MSG, e); - throw new ApplicationException(BAD_REQUEST, MARSHAL_FAIL_MSG); - } - } - - - public static String getStatusDesc(ActionType actionType) { - String desc = ""; - switch (actionType) { - case ALLOCATE: - desc = StatusDesc.ALLOCATE_NSS_SUCCESS; - break; - case DEALLOCATE: - desc = StatusDesc.DEALLOCATE_NSS_SUCCESS; - break; - case ACTIVATE: - desc = StatusDesc.ACTIVATE_NSS_SUCCESS; - break; - case DEACTIVATE: - desc = StatusDesc.DEACTIVATE_NSS_SUCCESS; - break; - case MODIFY: - desc = StatusDesc.MODIFY_NSS_SUCCESS; - break; - default: - break; - } - - return desc; - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.onap.logging.filter.base.ErrorCode;
+import org.springframework.stereotype.Component;
+import static org.onap.so.logger.LoggingAnchor.THREE;
+import static org.onap.so.logger.MessageEnum.RA_NS_EXC;
+
+public class NssmfAdapterUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NssmfAdapterUtil.class);
+
+ public static final int BAD_REQUEST = 400;
+
+ private static final String UNMARSHAL_FAIL_MSG = "Failed to unmarshal json";
+
+ private static final String MARSHAL_FAIL_MSG = "Failed to marshal object";
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ public static class StatusDesc {
+
+ public static final String ALLOCATE_NSS_SUCCESS = "Allocating nss is " + "successful";
+
+ public static final String MODIFY_NSS_SUCCESS = "Modify nss is " + "successful";
+
+ public static final String CREATE_NSS_SUCCESS = "Creating nss is " + "successful";
+
+ public static final String DEALLOCATE_NSS_SUCCESS = "Deallocate nss " + "is successful";
+
+ public static final String ACTIVATE_NSS_SUCCESS = "Activate nss " + "is successful";
+
+ public static final String DEACTIVATE_NSS_SUCCESS = "Deactivate nss " + "is successful";
+
+ public static final String QUERY_JOB_STATUS_FAILED = "Query job " + "status failed";
+
+ public static final String QUERY_JOB_STATUS_SUCCESS = "Query job " + "status is successful";
+
+ private StatusDesc() {
+
+ }
+ }
+
+ private NssmfAdapterUtil() {
+
+ }
+
+ public static void assertObjectNotNull(Object object) throws ApplicationException {
+ if (null == object) {
+ LOGGER.error("Object is null.");
+ throw new ApplicationException(BAD_REQUEST, "An object is null.");
+ }
+ }
+
+ public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException {
+ try {
+ return MAPPER.readValue(jsonstr, type);
+ } catch (IOException e) {
+ LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(BAD_REQUEST, UNMARSHAL_FAIL_MSG);
+ }
+ }
+
+ public static String marshal(Object srcObj) throws ApplicationException {
+ try {
+ return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(srcObj);
+ } catch (IOException e) {
+ LOGGER.error(THREE, RA_NS_EXC.toString(), ErrorCode.BusinessProcessError.getValue(), MARSHAL_FAIL_MSG, e);
+ throw new ApplicationException(BAD_REQUEST, MARSHAL_FAIL_MSG);
+ }
+ }
+
+
+ public static String getStatusDesc(ActionType actionType) {
+ String desc = "";
+ switch (actionType) {
+ case ALLOCATE:
+ desc = StatusDesc.ALLOCATE_NSS_SUCCESS;
+ break;
+ case DEALLOCATE:
+ desc = StatusDesc.DEALLOCATE_NSS_SUCCESS;
+ break;
+ case ACTIVATE:
+ desc = StatusDesc.ACTIVATE_NSS_SUCCESS;
+ break;
+ case DEACTIVATE:
+ desc = StatusDesc.DEACTIVATE_NSS_SUCCESS;
+ break;
+ case MODIFY:
+ desc = StatusDesc.MODIFY_NSS_SUCCESS;
+ break;
+ default:
+ break;
+ }
+
+ return desc;
+ }
+}
diff --git a/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java index 7a86c5b..9a23978 100644 --- a/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java +++ b/so-nssmf-adapter-application/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java @@ -1,353 +1,353 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.util; - -import javax.net.ssl.*; -import javax.ws.rs.core.UriBuilder; -import java.net.SocketTimeoutException; -import java.net.URI; -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.*; -import org.apache.http.conn.ConnectTimeoutException; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicHeader; -import org.apache.http.util.EntityUtils; -import org.onap.aai.domain.yang.*; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.nssmf.entity.TokenRequest; -import org.onap.so.adapters.nssmf.entity.TokenResponse; -import org.onap.so.adapters.nssmf.enums.HttpMethod; -import org.onap.so.adapters.nssmf.entity.NssmfInfo; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.beans.nsmf.EsrInfo; -import org.onap.so.beans.nsmf.ServiceInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import static org.apache.http.entity.ContentType.APPLICATION_JSON; -import static org.onap.so.adapters.nssmf.enums.HttpMethod.POST; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; -import static org.onap.logging.filter.base.ErrorCode.AvailabilityError; -import static org.onap.so.logger.LoggingAnchor.FOUR; -import static org.onap.so.logger.MessageEnum.RA_NS_EXC; - -@Component -public class RestUtil { - - private static final Logger logger = LoggerFactory.getLogger(RestUtil.class); - - private static final int DEFAULT_TIME_OUT = 60000; - - private static final String NSSMI_ADAPTER = "NSSMI Adapter"; - - private static final String TOKEN_URL = "/api/rest/securityManagement/v1" + "/oauth/token"; - - @Autowired - private AaiServiceProvider aaiSvcProv; - - public void createServiceInstance(ServiceInstance serviceInstance, ServiceInfo serviceInfo) { - aaiSvcProv.invokeCreateServiceInstance(serviceInstance, serviceInfo.getGlobalSubscriberId(), - serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); - } - - public ServiceInstance getServiceInstance(ServiceInfo serviceInfo) { - return aaiSvcProv.invokeGetServiceInstance(serviceInfo.getGlobalSubscriberId(), - serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); - } - - public void deleteServiceInstance(ServiceInfo serviceInfo) { - aaiSvcProv.invokeDeleteServiceInstance(serviceInfo.getGlobalSubscriberId(), - serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId()); - } - - public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException { - EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList(); - if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) { - for (EsrThirdpartySdnc sdncEsr : sdncList.getEsrThirdpartySdnc()) { - - EsrSystemInfoList sysInfoList = - aaiSvcProv.invokeGetThirdPartySdncEsrSystemInfo(sdncEsr.getThirdpartySdncId()); - - if (sysInfoList != null && sysInfoList.getEsrSystemInfo() != null) { - for (EsrSystemInfo esr : sysInfoList.getEsrSystemInfo()) { - if (esr != null && esr.getType().equals(esrInfo.getNetworkType().getNetworkType()) - && esr.getVendor().equals(esrInfo.getVendor())) { - logger.info("Found an entry with vendor name " + esrInfo.getVendor() + " and network type " - + esrInfo.getNetworkType() + " in ESR."); - NssmfInfo nssmfInfo = new NssmfInfo(); - nssmfInfo.setIpAddress(esr.getIpAddress()); - nssmfInfo.setPort(esr.getPort()); - nssmfInfo.setCacert(esr.getSslCacert()); - nssmfInfo.setUserName(esr.getUserName()); - nssmfInfo.setPassword(esr.getPassword()); - String endPoint = UriBuilder.fromPath("").host(esr.getIpAddress()) - .port(Integer.valueOf(esr.getPort())).scheme("https").build().toString(); - nssmfInfo.setUrl(endPoint); - return nssmfInfo; - } - } - } - - } - } - - throw new ApplicationException(BAD_REQUEST, "ESR information is improper"); - } - - - public String getToken(NssmfInfo nssmfInfo) throws ApplicationException { - - - TokenRequest req = new TokenRequest(); - req.setGrantType("password"); - req.setUserName(nssmfInfo.getUserName()); - req.setValue(nssmfInfo.getPassword()); - - String tokenReq = marshal(req); - - logger.info("Sending token request to NSSMF: " + tokenReq); - RestResponse tokenRes = send(nssmfInfo.getUrl() + TOKEN_URL, POST, tokenReq, null); - - TokenResponse res = unMarshal(tokenRes.getResponseContent(), TokenResponse.class); - - return res.getAccessToken(); - } - - - public RestResponse send(String url, HttpMethod methodType, String content, Header header) { - - HttpRequestBase req = null; - HttpResponse res = null; - - logger.debug("Beginning to send message {}: {}", methodType, url); - - try { - int timeout = DEFAULT_TIME_OUT; - - RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) - .setConnectionRequestTimeout(timeout).build(); - logger.debug("Sending request to NSSMF: " + content); - req = getHttpReq(url, methodType, header, config, content); - res = getHttpsClient().execute(req); - - String resContent = null; - if (res.getEntity() != null) { - resContent = EntityUtils.toString(res.getEntity(), "UTF-8"); - } - - int statusCode = res.getStatusLine().getStatusCode(); - String statusMessage = res.getStatusLine().getReasonPhrase(); - logger.info("NSSMF Response: {} {}", statusCode, - statusMessage + (resContent == null ? "" : System.lineSeparator() + resContent)); - - if (res.getStatusLine().getStatusCode() >= 300) { - String errMsg = "{\n \"errorCode\": " + res.getStatusLine().getStatusCode() - + "\n \"errorDescription\": " + statusMessage + "\n}"; - logError(errMsg); - return createResponse(statusCode, errMsg); - } - if (null != req) { - req.reset(); - } - req = null; - - return createResponse(statusCode, resContent); - - } catch (SocketTimeoutException | ConnectTimeoutException e) { - String errMsg = "Request to NSSMF timed out"; - logError(errMsg, e); - return createResponse(408, errMsg); - } catch (Exception e) { - String errMsg = "Error processing request to NSSMF"; - logError(errMsg, e); - return createResponse(500, errMsg); - } finally { - if (res != null) { - try { - EntityUtils.consume(res.getEntity()); - } catch (Exception e) { - logger.debug("Exception :", e); - } - } - if (req != null) { - try { - req.reset(); - } catch (Exception e) { - logger.debug("Exception :", e); - } - } - } - } - - public RestResponse createResponse(int statusCode, String errMsg) { - RestResponse restResponse = new RestResponse(); - restResponse.setStatus(statusCode); - restResponse.setResponseContent(errMsg); - return restResponse; - } - - private HttpRequestBase getHttpReq(String url, HttpMethod method, Header header, RequestConfig config, - String content) throws ApplicationException { - HttpRequestBase base; - switch (method) { - case POST: - HttpPost post = new HttpPost(url); - post.setEntity(new StringEntity(content, APPLICATION_JSON)); - base = post; - break; - - case GET: - HttpGetWithBody get = new HttpGetWithBody(url); - if (content != null) { - get.setEntity(new StringEntity(content, APPLICATION_JSON)); - } - base = get; - break; - - case PUT: - HttpPut put = new HttpPut(url); - put.setEntity(new StringEntity(content, APPLICATION_JSON)); - base = put; - break; - - case PATCH: - base = new HttpPatch(url); - break; - - case DELETE: - HttpDeleteWithBody delete = new HttpDeleteWithBody(url); - if (content != null) { - delete.setEntity(new StringEntity(content, APPLICATION_JSON)); - } - base = delete; - break; - default: - throw new ApplicationException(404, "invalid method: " + method); - - } - base.setConfig(config); - if (header != null) { - base.setHeader(header); - } - return base; - } - - public RestResponse sendRequest(String allocateUrl, HttpMethod post, String allocateReq, EsrInfo esrInfo) - throws ApplicationException { - NssmfInfo nssmfInfo = getNssmfHost(esrInfo); - Header header = new BasicHeader("X-Auth-Token", getToken(nssmfInfo)); - String nssmfUrl = nssmfInfo.getUrl() + allocateUrl; - return send(nssmfUrl, post, allocateReq, header); - } - - class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { - public static final String METHOD_NAME = "DELETE"; - - @Override - public String getMethod() { - return METHOD_NAME; - } - - public HttpDeleteWithBody(final String uri) { - super(); - setURI(URI.create(uri)); - } - - public HttpDeleteWithBody(final URI uri) { - super(); - setURI(uri); - } - - public HttpDeleteWithBody() { - super(); - } - } - - class HttpGetWithBody extends HttpEntityEnclosingRequestBase { - public static final String METHOD_NAME = "GET"; - - public HttpGetWithBody() { - super(); - } - - public HttpGetWithBody(final String uri) { - super(); - setURI(URI.create(uri)); - } - - public HttpGetWithBody(final URI uri) { - super(); - setURI(uri); - } - - @Override - public String getMethod() { - return METHOD_NAME; - } - } - - - public HttpClient getHttpsClient() { - - TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {} - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {} - }}; - - // Install the all-trusting trust manager - try { - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sc, - new String[] {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}, null, (s, sslSession) -> true); - return HttpClients.custom().setSSLSocketFactory(sslsf).build(); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } - } - - private static void logError(String errMsg, Throwable t) { - logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.getValue(), errMsg, t); - } - - private static void logError(String errMsg) { - logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.toString(), errMsg); - } -} - +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.util;
+
+import javax.net.ssl.*;
+import javax.ws.rs.core.UriBuilder;
+import java.net.SocketTimeoutException;
+import java.net.URI;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.*;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.util.EntityUtils;
+import org.onap.aai.domain.yang.*;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider;
+import org.onap.so.adapters.nssmf.entity.TokenRequest;
+import org.onap.so.adapters.nssmf.entity.TokenResponse;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.ServiceInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import static org.apache.http.entity.ContentType.APPLICATION_JSON;
+import static org.onap.so.adapters.nssmf.enums.HttpMethod.POST;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.BAD_REQUEST;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+import static org.onap.logging.filter.base.ErrorCode.AvailabilityError;
+import static org.onap.so.logger.LoggingAnchor.FOUR;
+import static org.onap.so.logger.MessageEnum.RA_NS_EXC;
+
+@Component
+public class RestUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(RestUtil.class);
+
+ private static final int DEFAULT_TIME_OUT = 60000;
+
+ private static final String NSSMI_ADAPTER = "NSSMI Adapter";
+
+ private static final String TOKEN_URL = "/api/rest/securityManagement/v1" + "/oauth/token";
+
+ @Autowired
+ private AaiServiceProvider aaiSvcProv;
+
+ public void createServiceInstance(ServiceInstance serviceInstance, ServiceInfo serviceInfo) {
+ aaiSvcProv.invokeCreateServiceInstance(serviceInstance, serviceInfo.getGlobalSubscriberId(),
+ serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId());
+ }
+
+ public ServiceInstance getServiceInstance(ServiceInfo serviceInfo) {
+ return aaiSvcProv.invokeGetServiceInstance(serviceInfo.getGlobalSubscriberId(),
+ serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId());
+ }
+
+ public void deleteServiceInstance(ServiceInfo serviceInfo) {
+ aaiSvcProv.invokeDeleteServiceInstance(serviceInfo.getGlobalSubscriberId(),
+ serviceInfo.getSubscriptionServiceType(), serviceInfo.getNssiId());
+ }
+
+ public NssmfInfo getNssmfHost(EsrInfo esrInfo) throws ApplicationException {
+ EsrThirdpartySdncList sdncList = aaiSvcProv.invokeGetThirdPartySdncList();
+ if (sdncList != null && sdncList.getEsrThirdpartySdnc() != null) {
+ for (EsrThirdpartySdnc sdncEsr : sdncList.getEsrThirdpartySdnc()) {
+
+ EsrSystemInfoList sysInfoList =
+ aaiSvcProv.invokeGetThirdPartySdncEsrSystemInfo(sdncEsr.getThirdpartySdncId());
+
+ if (sysInfoList != null && sysInfoList.getEsrSystemInfo() != null) {
+ for (EsrSystemInfo esr : sysInfoList.getEsrSystemInfo()) {
+ if (esr != null && esr.getType().equals(esrInfo.getNetworkType().getNetworkType())
+ && esr.getVendor().equals(esrInfo.getVendor())) {
+ logger.info("Found an entry with vendor name " + esrInfo.getVendor() + " and network type "
+ + esrInfo.getNetworkType() + " in ESR.");
+ NssmfInfo nssmfInfo = new NssmfInfo();
+ nssmfInfo.setIpAddress(esr.getIpAddress());
+ nssmfInfo.setPort(esr.getPort());
+ nssmfInfo.setCacert(esr.getSslCacert());
+ nssmfInfo.setUserName(esr.getUserName());
+ nssmfInfo.setPassword(esr.getPassword());
+ String endPoint = UriBuilder.fromPath("").host(esr.getIpAddress())
+ .port(Integer.valueOf(esr.getPort())).scheme("https").build().toString();
+ nssmfInfo.setUrl(endPoint);
+ return nssmfInfo;
+ }
+ }
+ }
+
+ }
+ }
+
+ throw new ApplicationException(BAD_REQUEST, "ESR information is improper");
+ }
+
+
+ public String getToken(NssmfInfo nssmfInfo) throws ApplicationException {
+
+
+ TokenRequest req = new TokenRequest();
+ req.setGrantType("password");
+ req.setUserName(nssmfInfo.getUserName());
+ req.setValue(nssmfInfo.getPassword());
+
+ String tokenReq = marshal(req);
+
+ logger.info("Sending token request to NSSMF: " + tokenReq);
+ RestResponse tokenRes = send(nssmfInfo.getUrl() + TOKEN_URL, POST, tokenReq, null);
+
+ TokenResponse res = unMarshal(tokenRes.getResponseContent(), TokenResponse.class);
+
+ return res.getAccessToken();
+ }
+
+
+ public RestResponse send(String url, HttpMethod methodType, String content, Header header) {
+
+ HttpRequestBase req = null;
+ HttpResponse res = null;
+
+ logger.debug("Beginning to send message {}: {}", methodType, url);
+
+ try {
+ int timeout = DEFAULT_TIME_OUT;
+
+ RequestConfig config = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout)
+ .setConnectionRequestTimeout(timeout).build();
+ logger.debug("Sending request to NSSMF: " + content);
+ req = getHttpReq(url, methodType, header, config, content);
+ res = getHttpsClient().execute(req);
+
+ String resContent = null;
+ if (res.getEntity() != null) {
+ resContent = EntityUtils.toString(res.getEntity(), "UTF-8");
+ }
+
+ int statusCode = res.getStatusLine().getStatusCode();
+ String statusMessage = res.getStatusLine().getReasonPhrase();
+ logger.info("NSSMF Response: {} {}", statusCode,
+ statusMessage + (resContent == null ? "" : System.lineSeparator() + resContent));
+
+ if (res.getStatusLine().getStatusCode() >= 300) {
+ String errMsg = "{\n \"errorCode\": " + res.getStatusLine().getStatusCode()
+ + "\n \"errorDescription\": " + statusMessage + "\n}";
+ logError(errMsg);
+ return createResponse(statusCode, errMsg);
+ }
+ if (null != req) {
+ req.reset();
+ }
+ req = null;
+
+ return createResponse(statusCode, resContent);
+
+ } catch (SocketTimeoutException | ConnectTimeoutException e) {
+ String errMsg = "Request to NSSMF timed out";
+ logError(errMsg, e);
+ return createResponse(408, errMsg);
+ } catch (Exception e) {
+ String errMsg = "Error processing request to NSSMF";
+ logError(errMsg, e);
+ return createResponse(500, errMsg);
+ } finally {
+ if (res != null) {
+ try {
+ EntityUtils.consume(res.getEntity());
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ }
+ }
+ if (req != null) {
+ try {
+ req.reset();
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ }
+ }
+ }
+ }
+
+ public RestResponse createResponse(int statusCode, String errMsg) {
+ RestResponse restResponse = new RestResponse();
+ restResponse.setStatus(statusCode);
+ restResponse.setResponseContent(errMsg);
+ return restResponse;
+ }
+
+ private HttpRequestBase getHttpReq(String url, HttpMethod method, Header header, RequestConfig config,
+ String content) throws ApplicationException {
+ HttpRequestBase base;
+ switch (method) {
+ case POST:
+ HttpPost post = new HttpPost(url);
+ post.setEntity(new StringEntity(content, APPLICATION_JSON));
+ base = post;
+ break;
+
+ case GET:
+ HttpGetWithBody get = new HttpGetWithBody(url);
+ if (content != null) {
+ get.setEntity(new StringEntity(content, APPLICATION_JSON));
+ }
+ base = get;
+ break;
+
+ case PUT:
+ HttpPut put = new HttpPut(url);
+ put.setEntity(new StringEntity(content, APPLICATION_JSON));
+ base = put;
+ break;
+
+ case PATCH:
+ base = new HttpPatch(url);
+ break;
+
+ case DELETE:
+ HttpDeleteWithBody delete = new HttpDeleteWithBody(url);
+ if (content != null) {
+ delete.setEntity(new StringEntity(content, APPLICATION_JSON));
+ }
+ base = delete;
+ break;
+ default:
+ throw new ApplicationException(404, "invalid method: " + method);
+
+ }
+ base.setConfig(config);
+ if (header != null) {
+ base.setHeader(header);
+ }
+ return base;
+ }
+
+ public RestResponse sendRequest(String allocateUrl, HttpMethod post, String allocateReq, EsrInfo esrInfo)
+ throws ApplicationException {
+ NssmfInfo nssmfInfo = getNssmfHost(esrInfo);
+ Header header = new BasicHeader("X-Auth-Token", getToken(nssmfInfo));
+ String nssmfUrl = nssmfInfo.getUrl() + allocateUrl;
+ return send(nssmfUrl, post, allocateReq, header);
+ }
+
+ class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
+ public static final String METHOD_NAME = "DELETE";
+
+ @Override
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+
+ public HttpDeleteWithBody(final String uri) {
+ super();
+ setURI(URI.create(uri));
+ }
+
+ public HttpDeleteWithBody(final URI uri) {
+ super();
+ setURI(uri);
+ }
+
+ public HttpDeleteWithBody() {
+ super();
+ }
+ }
+
+ class HttpGetWithBody extends HttpEntityEnclosingRequestBase {
+ public static final String METHOD_NAME = "GET";
+
+ public HttpGetWithBody() {
+ super();
+ }
+
+ public HttpGetWithBody(final String uri) {
+ super();
+ setURI(URI.create(uri));
+ }
+
+ public HttpGetWithBody(final URI uri) {
+ super();
+ setURI(uri);
+ }
+
+ @Override
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+ }
+
+
+ public HttpClient getHttpsClient() {
+
+ TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ @Override
+ public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
+
+ @Override
+ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
+ }};
+
+ // Install the all-trusting trust manager
+ try {
+ SSLContext sc = SSLContext.getInstance("SSL");
+ sc.init(null, trustAllCerts, new java.security.SecureRandom());
+
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sc,
+ new String[] {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}, null, (s, sslSession) -> true);
+ return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private static void logError(String errMsg, Throwable t) {
+ logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.getValue(), errMsg, t);
+ }
+
+ private static void logError(String errMsg) {
+ logger.error(FOUR, RA_NS_EXC.toString(), NSSMI_ADAPTER, AvailabilityError.toString(), errMsg);
+ }
+}
+
diff --git a/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/so-nssmf-adapter-application/src/main/resources/META-INF/services/org.onap.so.client.RestProperties index f93ec63..f93ec63 100644 --- a/src/main/resources/META-INF/services/org.onap.so.client.RestProperties +++ b/so-nssmf-adapter-application/src/main/resources/META-INF/services/org.onap.so.client.RestProperties diff --git a/src/main/resources/application-aaf.yaml b/so-nssmf-adapter-application/src/main/resources/application-aaf.yaml index e69de29..e69de29 100644 --- a/src/main/resources/application-aaf.yaml +++ b/so-nssmf-adapter-application/src/main/resources/application-aaf.yaml diff --git a/src/main/resources/application-basic.yaml b/so-nssmf-adapter-application/src/main/resources/application-basic.yaml index e69de29..e69de29 100644 --- a/src/main/resources/application-basic.yaml +++ b/so-nssmf-adapter-application/src/main/resources/application-basic.yaml diff --git a/src/main/resources/application-test.yaml b/so-nssmf-adapter-application/src/main/resources/application-test.yaml index 8e10dfb..ecb015e 100644 --- a/src/main/resources/application-test.yaml +++ b/so-nssmf-adapter-application/src/main/resources/application-test.yaml @@ -1,60 +1,60 @@ - -aai: - auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 - endpoint: https://aai.onap:30233 -logging: - path: logs - -spring: - datasource: - jdbcUrl: jdbc:mariadb://49.232.146.162:8989/requestdb - username: root - password: 123456 - driver-class-name: org.mariadb.jdbc.Driver - initialization-mode: always - jpa: - generate-ddl: false - show-sql: false - hibernate: - ddl-auto: none - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable-lazy-load-no-trans: true - database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - security: - usercredentials: - - username: bpel - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - - username: mso_admin - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: ACTUATOR -server: - port: 8080 - tomcat: - max-threads: 50 - -mso: - key: 07a7159d3bf51a0e53be7a8f89699be7 - site-name: localSite - logPath: ./logs/nssmf - adapters: - requestDb: - endpoint: https://so-request-db-adapter.onap:8083 - auth: Basic YnBlbDpwYXNzd29yZDEk - infra: - endpoint: https://so.onap:8080 - auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== - -#Actuator -management: - endpoints: - web: - base-path: /manage - exposure: - include: "*" - metrics: - se-global-registry: false - export: - prometheus: - enabled: true # Whether exporting of metrics to Prometheus is enabled. +
+aai:
+ auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586
+ endpoint: https://aai.onap:30233
+logging:
+ path: logs
+
+spring:
+ datasource:
+ jdbcUrl: jdbc:mariadb://49.232.146.162:8989/requestdb
+ username: root
+ password: 123456
+ driver-class-name: org.mariadb.jdbc.Driver
+ initialization-mode: always
+ jpa:
+ generate-ddl: false
+ show-sql: false
+ hibernate:
+ ddl-auto: none
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ security:
+ usercredentials:
+ - username: bpel
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ - username: mso_admin
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: ACTUATOR
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+ site-name: localSite
+ logPath: ./logs/nssmf
+ adapters:
+ requestDb:
+ endpoint: https://so-request-db-adapter.onap:8083
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+ infra:
+ endpoint: https://so.onap:8080
+ auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
+
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
+ metrics:
+ se-global-registry: false
+ export:
+ prometheus:
+ enabled: true # Whether exporting of metrics to Prometheus is enabled.
step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/src/main/resources/application.yaml b/so-nssmf-adapter-application/src/main/resources/application.yaml index 5501fba..8a8dc7c 100644 --- a/src/main/resources/application.yaml +++ b/so-nssmf-adapter-application/src/main/resources/application.yaml @@ -1,77 +1,77 @@ -# -# ============LICENSE_START======================================================= -# ONAP - SO -# ================================================================================ -# Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -#/ -aai: - auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 - endpoint: https://aai.onap:30233 -logging: - path: logs - -spring: - datasource: - jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb - username: ${DB_USERNAME} - password: ${DB_PASSWORD} - driver-class-name: org.mariadb.jdbc.Driver - jpa: - show-sql: false - hibernate: - dialect: org.hibernate.dialect.MySQL5Dialect - ddl-auto: validate - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable-lazy-load-no-trans: true - security: - usercredentials: - - username: bpel - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - - username: mso_admin - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: ACTUATOR - -server: - port: 8080 - tomcat: - max-threads: 50 - -mso: - key: 07a7159d3bf51a0e53be7a8f89699be7 - site-name: localSite - logPath: ./logs/nssmf - adapters: - requestDb: - endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083 - auth: Basic YnBlbDpwYXNzd29yZDEk - infra: - endpoint: http://so.onap:8080 - auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== - -#Actuator -management: - endpoints: - web: - base-path: /manage - exposure: - include: "*" - metrics: - se-global-registry: false - export: - prometheus: - enabled: true # Whether exporting of metrics to Prometheus is enabled. - step: 1m # Step size (i.e. reporting frequency) to use. +#
+# ============LICENSE_START=======================================================
+# ONAP - SO
+# ================================================================================
+# Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#/
+aai:
+ auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586
+ endpoint: https://aai.onap:30233
+logging:
+ path: logs
+
+spring:
+ datasource:
+ jdbc-url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/requestdb
+ username: ${DB_USERNAME}
+ password: ${DB_PASSWORD}
+ driver-class-name: org.mariadb.jdbc.Driver
+ jpa:
+ show-sql: false
+ hibernate:
+ dialect: org.hibernate.dialect.MySQL5Dialect
+ ddl-auto: validate
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ security:
+ usercredentials:
+ - username: bpel
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ - username: mso_admin
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: ACTUATOR
+
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+ site-name: localSite
+ logPath: ./logs/nssmf
+ adapters:
+ requestDb:
+ endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+ infra:
+ endpoint: http://so.onap:8080
+ auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
+
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
+ metrics:
+ se-global-registry: false
+ export:
+ prometheus:
+ enabled: true # Whether exporting of metrics to Prometheus is enabled.
+ step: 1m # Step size (i.e. reporting frequency) to use.
diff --git a/src/main/resources/org.onap.so.p12 b/so-nssmf-adapter-application/src/main/resources/org.onap.so.p12 Binary files differindex 79631bf..79631bf 100644 --- a/src/main/resources/org.onap.so.p12 +++ b/so-nssmf-adapter-application/src/main/resources/org.onap.so.p12 diff --git a/src/main/resources/org.onap.so.trust.jks b/so-nssmf-adapter-application/src/main/resources/org.onap.so.trust.jks Binary files differindex 6f8168d..6f8168d 100644 --- a/src/main/resources/org.onap.so.trust.jks +++ b/so-nssmf-adapter-application/src/main/resources/org.onap.so.trust.jks diff --git a/src/main/resources/subnetCapability.json b/so-nssmf-adapter-application/src/main/resources/subnetCapability.json index 8753e85..ff5ee65 100644 --- a/src/main/resources/subnetCapability.json +++ b/so-nssmf-adapter-application/src/main/resources/subnetCapability.json @@ -1,10 +1,10 @@ -{ - "AN": { - "latency": 5, - "maxNumberofUEs": "100" - }, - "CN": { - "latency": 5, - "maxNumberofConns": "100" - } -} +{
+ "AN": {
+ "latency": 5,
+ "maxNumberofUEs": "100"
+ },
+ "CN": {
+ "latency": 5,
+ "maxNumberofConns": "100"
+ }
+}
diff --git a/src/test/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterControllerTest.java b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterControllerTest.java index 20f4c95..3a57938 100644 --- a/src/test/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterControllerTest.java +++ b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/controller/NssmfAdapterControllerTest.java @@ -1,132 +1,132 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.adapters.nssmf.controller; - -import org.junit.Before; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.onap.so.adapters.nssmf.controller.NssmfAdapterController; -import org.onap.so.adapters.nssmf.service.NssmfManagerService; -import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; -import org.junit.Test; -import java.lang.reflect.Field; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.onap.so.beans.nsmf.NetworkType.CORE; - -@RunWith(SpringRunner.class) -public class NssmfAdapterControllerTest { - - @Mock - private NssmfManagerService nssmfManagerService; - - private NssmfAdapterController controller; - - @Mock - private ResponseEntity entity; - - @Before - public void setUp() throws Exception { - initMocks(this); - controller = new NssmfAdapterController(); - - Field nssmfManagerService = controller.getClass().getDeclaredField("nssmfManagerService"); - nssmfManagerService.setAccessible(true); - nssmfManagerService.set(controller, this.nssmfManagerService); - } - - - @Test - public void allocateNssiTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - ResponseEntity entity = controller.allocateNssi(request); - assertNotNull(entity); - } - - @Test - public void deAllocateNssiTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - String profileId = "7516eb33-e8d3-4805-b91a-96de1bb6d8bb"; - ResponseEntity entity = controller.deAllocateNssi(request, profileId); - assertNotNull(entity); - - } - - @Test - public void activateNssiTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - String snssai = "01-772523CD"; - ResponseEntity entity = controller.activateNssi(request, snssai); - assertNotNull(entity); - } - - @Test - public void deactivateNssiTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - String snssai = "01-772523CD"; - ResponseEntity entity = controller.deactivateNssi(request, snssai); - assertNotNull(entity); - } - - @Test - public void queryJobStatusTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - String jobId = "b86aa515-b285-487b-8a1e-01f3cc871b88"; - ResponseEntity entity = controller.queryJobStatus(request, jobId); - assertNotNull(entity); - } - - @Test - public void queryNSSISelectionCapabilityTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - ResponseEntity entity = controller.queryNSSISelectionCapability(request); - assertNotNull(entity); - } - - @Test - public void querySubnetCapabilityTest() throws Exception { - commonMock(); - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - ResponseEntity entity = controller.querySubnetCapability(request); - assertNotNull(entity); - } - - private void commonMock() { - NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest(); - when(nssmfManagerService.allocateNssi(any())).thenReturn(entity); - when(nssmfManagerService.deAllocateNssi(any(), anyString())).thenReturn(entity); - when(nssmfManagerService.deActivateNssi(any(), anyString())).thenReturn(entity); - when(nssmfManagerService.activateNssi(any(), anyString())).thenReturn(entity); - when(nssmfManagerService.queryJobStatus(any(), anyString())).thenReturn(entity); - when(nssmfManagerService.querySubnetCapability(any())).thenReturn(entity); - when(nssmfManagerService.queryNSSISelectionCapability(any())).thenReturn(entity); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.nssmf.controller;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.onap.so.adapters.nssmf.controller.NssmfAdapterController;
+import org.onap.so.adapters.nssmf.service.NssmfManagerService;
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.junit.Test;
+import java.lang.reflect.Field;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.so.beans.nsmf.NetworkType.CORE;
+
+@RunWith(SpringRunner.class)
+public class NssmfAdapterControllerTest {
+
+ @Mock
+ private NssmfManagerService nssmfManagerService;
+
+ private NssmfAdapterController controller;
+
+ @Mock
+ private ResponseEntity entity;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ controller = new NssmfAdapterController();
+
+ Field nssmfManagerService = controller.getClass().getDeclaredField("nssmfManagerService");
+ nssmfManagerService.setAccessible(true);
+ nssmfManagerService.set(controller, this.nssmfManagerService);
+ }
+
+
+ @Test
+ public void allocateNssiTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ ResponseEntity entity = controller.allocateNssi(request);
+ assertNotNull(entity);
+ }
+
+ @Test
+ public void deAllocateNssiTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ String profileId = "7516eb33-e8d3-4805-b91a-96de1bb6d8bb";
+ ResponseEntity entity = controller.deAllocateNssi(request, profileId);
+ assertNotNull(entity);
+
+ }
+
+ @Test
+ public void activateNssiTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ String snssai = "01-772523CD";
+ ResponseEntity entity = controller.activateNssi(request, snssai);
+ assertNotNull(entity);
+ }
+
+ @Test
+ public void deactivateNssiTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ String snssai = "01-772523CD";
+ ResponseEntity entity = controller.deactivateNssi(request, snssai);
+ assertNotNull(entity);
+ }
+
+ @Test
+ public void queryJobStatusTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ String jobId = "b86aa515-b285-487b-8a1e-01f3cc871b88";
+ ResponseEntity entity = controller.queryJobStatus(request, jobId);
+ assertNotNull(entity);
+ }
+
+ @Test
+ public void queryNSSISelectionCapabilityTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ ResponseEntity entity = controller.queryNSSISelectionCapability(request);
+ assertNotNull(entity);
+ }
+
+ @Test
+ public void querySubnetCapabilityTest() throws Exception {
+ commonMock();
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ ResponseEntity entity = controller.querySubnetCapability(request);
+ assertNotNull(entity);
+ }
+
+ private void commonMock() {
+ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest();
+ when(nssmfManagerService.allocateNssi(any())).thenReturn(entity);
+ when(nssmfManagerService.deAllocateNssi(any(), anyString())).thenReturn(entity);
+ when(nssmfManagerService.deActivateNssi(any(), anyString())).thenReturn(entity);
+ when(nssmfManagerService.activateNssi(any(), anyString())).thenReturn(entity);
+ when(nssmfManagerService.queryJobStatus(any(), anyString())).thenReturn(entity);
+ when(nssmfManagerService.querySubnetCapability(any())).thenReturn(entity);
+ when(nssmfManagerService.queryNSSISelectionCapability(any())).thenReturn(entity);
+ }
+}
diff --git a/src/test/java/org/onap/so/adapters/nssmf/entity/RestResponseTest.java b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/entity/RestResponseTest.java index ab2c212..d80359d 100644 --- a/src/test/java/org/onap/so/adapters/nssmf/entity/RestResponseTest.java +++ b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/entity/RestResponseTest.java @@ -1,59 +1,59 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.adapters.nssmf.entity; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.junit4.SpringRunner; -import java.util.HashMap; -import java.util.Map; -import static org.junit.Assert.*; - -@RunWith(SpringRunner.class) -public class RestResponseTest { - - @Test - public void testRestResponse() { - RestResponse restResponse = new RestResponse(); - Map<String, String> header = new HashMap<>(); - header.put("X-RequestID", "05a63ae2-249a-49b9-bc52-0c70a3bca487"); - header.put("X-InvocationID", "bb7f7fc5-52ba-4937-a7af-55036694fe19"); - header.put("testlong", "55036694"); - header.put("testint", "55"); - restResponse.setRespHeaderMap(header); - - String headerStr = restResponse.getRespHeaderStr("X-RequestID"); - assertEquals(headerStr, "05a63ae2-249a-49b9-bc52-0c70a3bca487"); - - long headerLong = restResponse.getRespHeaderLong("testlong"); - long headerLongNull = restResponse.getRespHeaderLong("testlong1"); - assertNotNull(headerLong); - assertEquals(headerLongNull, -1L); - - int headerInt = restResponse.getRespHeaderInt("testint"); - int headerIntNull = restResponse.getRespHeaderInt("testint1"); - assertNotNull(headerInt); - assertEquals(headerIntNull, -1); - - Map headerMap = restResponse.getRespHeaderMap(); - assertNotNull(headerMap); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.nssmf.entity;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.junit4.SpringRunner;
+import java.util.HashMap;
+import java.util.Map;
+import static org.junit.Assert.*;
+
+@RunWith(SpringRunner.class)
+public class RestResponseTest {
+
+ @Test
+ public void testRestResponse() {
+ RestResponse restResponse = new RestResponse();
+ Map<String, String> header = new HashMap<>();
+ header.put("X-RequestID", "05a63ae2-249a-49b9-bc52-0c70a3bca487");
+ header.put("X-InvocationID", "bb7f7fc5-52ba-4937-a7af-55036694fe19");
+ header.put("testlong", "55036694");
+ header.put("testint", "55");
+ restResponse.setRespHeaderMap(header);
+
+ String headerStr = restResponse.getRespHeaderStr("X-RequestID");
+ assertEquals(headerStr, "05a63ae2-249a-49b9-bc52-0c70a3bca487");
+
+ long headerLong = restResponse.getRespHeaderLong("testlong");
+ long headerLongNull = restResponse.getRespHeaderLong("testlong1");
+ assertNotNull(headerLong);
+ assertEquals(headerLongNull, -1L);
+
+ int headerInt = restResponse.getRespHeaderInt("testint");
+ int headerIntNull = restResponse.getRespHeaderInt("testint1");
+ assertNotNull(headerInt);
+ assertEquals(headerIntNull, -1);
+
+ Map headerMap = restResponse.getRespHeaderMap();
+ assertNotNull(headerMap);
+ }
+
+}
diff --git a/src/test/java/org/onap/so/adapters/nssmf/exceptions/ApplicationExceptionTest.java b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/exceptions/ApplicationExceptionTest.java index e4b1cc9..27043bb 100644 --- a/src/test/java/org/onap/so/adapters/nssmf/exceptions/ApplicationExceptionTest.java +++ b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/exceptions/ApplicationExceptionTest.java @@ -1,40 +1,40 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.adapters.nssmf.exceptions; - - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.Assert.*; - -@RunWith(SpringRunner.class) -public class ApplicationExceptionTest { - - @Test - public void buildErrorResponseTest() { - ApplicationException appException = new ApplicationException(500, "system internal error"); - ResponseEntity entity = appException.buildErrorResponse(); - assertNotNull(entity); - assertEquals(entity.getStatusCodeValue(), 500); - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.nssmf.exceptions;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import static org.junit.Assert.*;
+
+@RunWith(SpringRunner.class)
+public class ApplicationExceptionTest {
+
+ @Test
+ public void buildErrorResponseTest() {
+ ApplicationException appException = new ApplicationException(500, "system internal error");
+ ResponseEntity entity = appException.buildErrorResponse();
+ assertNotNull(entity);
+ assertEquals(entity.getStatusCodeValue(), 500);
+ }
+
+}
diff --git a/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java index b64f581..6bb70ea 100644 --- a/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java +++ b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java @@ -1,645 +1,645 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.nssmf.service.impl; - - -import org.apache.http.Header; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.StatusLine; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.conn.util.DomainType; -import org.ehcache.config.ResourceType; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.stubbing.Answer; -import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig; -import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts; -import org.onap.so.adapters.nssmf.entity.NssmfInfo; -import org.onap.so.adapters.nssmf.entity.TokenResponse; -import org.onap.so.adapters.nssmf.enums.ActionType; -import org.onap.so.adapters.nssmf.enums.HttpMethod; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.util.RestUtil; -import org.onap.so.beans.nsmf.*; -import org.onap.so.db.request.beans.ResourceOperationStatus; -import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; -import javax.persistence.Access; -import javax.persistence.ManyToOne; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.util.*; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; -import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal; -import static org.onap.so.beans.nsmf.NetworkType.*; -import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED; - -@RunWith(SpringRunner.class) -public class NssmfManagerServiceImplTest { - - @Mock - private RestUtil restUtil; - - - private NssmfManagerServiceImpl nssiManagerService; - - @Mock - private HttpResponse tokenResponse; - - @Mock - private HttpEntity tokenEntity; - - @Mock - private HttpResponse commonResponse; - - @Mock - private HttpEntity commonEntity; - - @Mock - private StatusLine statusLine; - - @Mock - private HttpClient httpClient; - - private InputStream postStream; - - private InputStream tokenStream; - - @Mock - private NssmfAdapterConfig adapterConfig; - - @Mock - private ResourceOperationStatusRepository repository; - - @Before - public void setUp() throws Exception { - initMocks(this); - - nssiManagerService = new NssmfManagerServiceImpl(); - - Field restUtil = nssiManagerService.getClass().getDeclaredField("restUtil"); - restUtil.setAccessible(true); - restUtil.set(nssiManagerService, this.restUtil); - - Field adapterConfig = nssiManagerService.getClass().getDeclaredField("nssmfAdapterConfig"); - adapterConfig.setAccessible(true); - adapterConfig.set(nssiManagerService, this.adapterConfig); - - Field repository = nssiManagerService.getClass().getDeclaredField("repository"); - repository.setAccessible(true); - repository.set(nssiManagerService, this.repository); - // nssiManagerService.setRestUtil(this.restUtil); - - when(this.restUtil.send(any(String.class), any(HttpMethod.class), any(), any(Header.class))) - .thenCallRealMethod(); - when(this.restUtil.createResponse(any(Integer.class), any(String.class))).thenCallRealMethod(); - } - - private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception { - when(restUtil.getToken(any(NssmfInfo.class))).thenReturn("7512eb3feb5249eca5ddd742fedddd39"); - when(restUtil.getHttpsClient()).thenReturn(httpClient); - when(restUtil.getServiceInstance(any())).thenReturn(new ServiceInstance()); - - when(statusLine.getStatusCode()).thenReturn(statusCode); - when(restUtil.getNssmfHost(any(EsrInfo.class))).thenReturn(nssmf); - - when(tokenResponse.getEntity()).thenReturn(tokenEntity); - when(tokenResponse.getStatusLine()).thenReturn(statusLine); - when(tokenEntity.getContent()).thenReturn(tokenStream); - - when(commonResponse.getEntity()).thenReturn(commonEntity); - when(commonResponse.getStatusLine()).thenReturn(statusLine); - when(commonEntity.getContent()).thenReturn(postStream); - - when(adapterConfig.getInfraAuth()).thenReturn("SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="); - - Answer<HttpResponse> answer = invocation -> { - Object[] arguments = invocation.getArguments(); - if (arguments != null && arguments.length == 1 && arguments[0] != null) { - - HttpRequestBase base = (HttpRequestBase) arguments[0]; - if (base.getURI().toString().endsWith("/oauth/token")) { - return tokenResponse; - } else { - return commonResponse; - } - } - return commonResponse; - }; - - doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class)); - - } - - @Test - public void allocateCnNssiTest() throws Exception { - allocateNssi(CORE); - - } - - @Test - public void allocateTnNssiTest() throws Exception { - allocateNssi(TRANSPORT); - } - - @Test - public void allocateAnNssiTest() throws Exception { - allocateNssi(ACCESS); - } - - - public void allocateNssi(NetworkType domainType) throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - nssmf.setUrl("http://127.0.0.1:8080"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - createCommonMock(200, nssmf); - NssmfAdapterNBIRequest nbiRequest = null; - - switch (domainType) { - case CORE: - nbiRequest = createCnAllocateNssi(); - break; - case TRANSPORT: - nbiRequest = createTnAllocateNssi(); - break; - case ACCESS: - nbiRequest = createAnAllocateNssi(); - break; - } - - assertNotNull(nbiRequest); - System.out.println(marshal(nbiRequest)); - ResponseEntity res = nssiManagerService.allocateNssi(nbiRequest); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - if (!domainType.equals(ACCESS)) { - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - } - - System.out.println(res); - } - - - - private NssmfAdapterNBIRequest createCnAllocateNssi() { - CnSliceProfile sP = new CnSliceProfile(); - List<String> sns = new LinkedList<>(); - sns.add("001-100001"); - List<String> plmn = new LinkedList<>(); - plmn.add("460-00"); - plmn.add("460-01"); - PerfReqEmbb embb = new PerfReqEmbb(); - embb.setActivityFactor(50); - List<PerfReqEmbb> embbList = new LinkedList<>(); - embbList.add(embb); - PerfReq perfReq = new PerfReq(); - perfReq.setPerfReqEmbbList(embbList); - List<String> taList = new LinkedList<>(); - taList.add("1"); - taList.add("2"); - taList.add("3"); - sP.setSnssaiList(sns); - sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); - sP.setPLMNIdList(plmn); - sP.setPerfReq(perfReq); - sP.setMaxNumberOfUEs(200); - sP.setCoverageAreaTAList(taList); - sP.setLatency(6); - sP.setResourceSharingLevel(NON_SHARED); - NsiInfo nsiInfo = new NsiInfo(); - nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - nsiInfo.setNsiName("eMBB-001"); - AllocateCnNssi cnNssi = new AllocateCnNssi(); - cnNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX"); - cnNssi.setNssiName("eMBB-001"); - cnNssi.setScriptName("CN1"); - cnNssi.setSliceProfile(sP); - cnNssi.setNsiInfo(nsiInfo); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE); - nbiRequest.setAllocateCnNssi(cnNssi); - return nbiRequest; - } - - private NssmfAdapterNBIRequest createAnAllocateNssi() { - - AnSliceProfile sP = new AnSliceProfile(); - List<String> sns = new LinkedList<>(); - sns.add("001-100001"); - List<String> plmn = new LinkedList<>(); - plmn.add("460-00"); - plmn.add("460-01"); - PerfReqEmbb embb = new PerfReqEmbb(); - embb.setActivityFactor(50); - List<PerfReqEmbb> embbList = new LinkedList<>(); - embbList.add(embb); - PerfReq perfReq = new PerfReq(); - perfReq.setPerfReqEmbbList(embbList); - List<Integer> taList = new LinkedList<>(); - taList.add(1); - taList.add(2); - taList.add(3); - sP.setSNSSAIList(sns); - sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); - sP.setPLMNIdList(plmn); - sP.setPerfReq(perfReq); - sP.setMaxNumberOfUEs(200); - sP.setCoverageAreaTAList(taList); - sP.setLatency(6); - sP.setResourceSharingLevel(NON_SHARED); - sP.setUeMobilityLevel(UeMobilityLevel.STATIONARY); - sP.setResourceSharingLevel(NON_SHARED); - NsiInfo nsiInfo = new NsiInfo(); - nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - nsiInfo.setNsiName("eMBB-001"); - AllocateAnNssi anNssi = new AllocateAnNssi(); - anNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX"); - anNssi.setNssiName("eMBB-001"); - anNssi.setScriptName("CN1"); - anNssi.setSliceProfile(sP); - anNssi.setNsiInfo(nsiInfo); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(ACCESS); - nbiRequest.setAllocateAnNssi(anNssi); - return nbiRequest; - } - - - private NssmfAdapterNBIRequest createTnAllocateNssi() { - TnSliceProfile sP = new TnSliceProfile(); - List<String> sns = new LinkedList<>(); - sns.add("01-1EB5BA40"); - List<String> plmn = new LinkedList<>(); - plmn.add("460-00"); - PerfReqEmbb embb = new PerfReqEmbb(); - embb.setActivityFactor(50); - List<PerfReqEmbb> embbList = new LinkedList<>(); - embbList.add(embb); - - sP.setSNSSAIList(sns); - sP.setSliceProfileId("fec94836-87a0-41dc-a199-0ad9aa3890d1"); - sP.setPLMNIdList(plmn); - sP.setLatency(10); - sP.setMaxBandwidth(1000); - sP.setJitter(10); - - List<TransportSliceNetwork> networks = new LinkedList<>(); - TransportSliceNetwork network = new TransportSliceNetwork(); - List<ConnectionLink> connectionLinks = new LinkedList<>(); - ConnectionLink connectionLink = new ConnectionLink(); - connectionLink.setTransportEndpointA("a47c76e3-c010-4eaf-adbb-0ba264118cab"); - connectionLink.setTransportEndpointB("c0c83e33-80d2-43da-b6cb-17b930420d74"); - connectionLinks.add(connectionLink); - network.setConnectionLinks(connectionLinks); - networks.add(network); - - NsiInfo nsiInfo = new NsiInfo(); - nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - nsiInfo.setNsiName("eMBB-001"); - AllocateTnNssi tnNssi = new AllocateTnNssi(); - tnNssi.setTransportSliceNetworks(networks); - tnNssi.setScriptName("TN"); - tnNssi.setSliceProfile(sP); - tnNssi.setNsiInfo(nsiInfo); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(TRANSPORT); - nbiRequest.setAllocateTnNssi(tnNssi); - return nbiRequest; - } - - @Test - public void deAllocateCnNssi() throws Exception { - deAllocateNssi(CORE); - } - - @Test - public void deAllocateAnNssi() throws Exception { - deAllocateNssi(ACCESS); - } - - @Test - public void deAllocateTnNssi() throws Exception { - deAllocateNssi(TRANSPORT); - } - - public void deAllocateNssi(NetworkType domainType) throws Exception { - DeAllocateNssi deAllocateNssi = new DeAllocateNssi(); - deAllocateNssi.setTerminateNssiOption(0); - List<String> snssai = new LinkedList<>(); - snssai.add("001-100001"); - deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - deAllocateNssi.setScriptName("CN1"); - deAllocateNssi.setSnssaiList(snssai); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(domainType); - nbiRequest.setDeAllocateNssi(deAllocateNssi); - - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - createCommonMock(202, nssmf); - ResponseEntity res = nssiManagerService.deAllocateNssi(nbiRequest, "ab9af40f13f721b5f13539d87484098"); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - if (!domainType.equals(ACCESS)) { - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - } - } - - @Test - public void activateAnNssi() throws Exception { - activateNssi(ACCESS); - } - - - @Test - public void activateCnNssi() throws Exception { - activateNssi(CORE); - } - - - @Test - public void activateTnNssi() throws Exception { - activateNssi(TRANSPORT); - } - - - private void activateNssi(NetworkType domainType) throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - ActDeActNssi act = new ActDeActNssi(); - act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(domainType); - nbiRequest.setActDeActNssi(act); - - createCommonMock(200, nssmf); - ResponseEntity res = nssiManagerService.activateNssi(nbiRequest, "001-100001"); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - if (!domainType.equals(ACCESS)) { - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - } - } - - @Test - public void deActivateNssi() throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - NssiResponse nssiRes = new NssiResponse(); - nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067"); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - ActDeActNssi act = new ActDeActNssi(); - act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX"); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE); - nbiRequest.setActDeActNssi(act); - - createCommonMock(200, nssmf); - ResponseEntity res = nssiManagerService.deActivateNssi(nbiRequest, "001-100001"); - assertNotNull(res); - assertNotNull(res.getBody()); - NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class); - assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067"); - } - - @Test - public void testNssmfRequest() throws ApplicationException { - NssmfRequest nssmfRequest = new NssmfRequest(); - String sst = marshal(nssmfRequest); - System.out.println(sst); - } - - @Test - public void queryCnAllocateJobStatus() throws Exception { - queryJobStatus(CORE, ActionType.ALLOCATE.toString()); - } - - @Test - public void queryCnActivateJobStatus() throws Exception { - queryJobStatus(CORE, ActionType.ACTIVATE.toString()); - } - - @Test - public void queryCnDeActivateJobStatus() throws Exception { - queryJobStatus(CORE, ActionType.DEACTIVATE.toString()); - } - - @Test - public void queryAnJobStatus() throws Exception { - queryJobStatus(ACCESS, ActionType.ALLOCATE.toString()); - } - - public void queryJobStatus(NetworkType domainType, String action) throws Exception { - NssmfInfo nssmf = new NssmfInfo(); - nssmf.setUserName("nssmf-user"); - nssmf.setPassword("nssmf-pass"); - nssmf.setPort("8080"); - nssmf.setIpAddress("127.0.0.1"); - - JobStatusResponse jobStatusResponse = new JobStatusResponse(); - ResponseDescriptor descriptor = new ResponseDescriptor(); - descriptor.setResponseId("7512eb3feb5249eca5ddd742fedddd39"); - descriptor.setProgress(100); - descriptor.setStatusDescription("Initiating VNF Instance"); - descriptor.setStatus("FINISHED"); - jobStatusResponse.setResponseDescriptor(descriptor); - - TokenResponse token = new TokenResponse(); - token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39"); - token.setExpires(1800); - - postStream = new ByteArrayInputStream(marshal(jobStatusResponse).getBytes(UTF_8)); - tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8)); - - ResourceOperationStatus operationStatus = new ResourceOperationStatus(); - operationStatus.setOperationId("4b45d919816ccaa2b762df5120f72067"); - operationStatus.setResourceTemplateUUID("8ee5926d-720b-4bb2-86f9-d20e921c143b"); - operationStatus.setServiceId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - operationStatus.setOperType(action); - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(domainType); - nbiRequest.setResponseId("7512eb3feb5249eca5ddd742fedddd39"); - List<ResourceOperationStatus> optional = new ArrayList<>(); - optional.add(operationStatus); - - doAnswer(invocation -> optional).when(repository).findByServiceIdAndOperationId(any(), any()); - - createCommonMock(200, nssmf); - - ResponseEntity res = nssiManagerService.queryJobStatus(nbiRequest, "4b45d919816ccaa2b762df5120f72067"); - assertNotNull(res); - assertNotNull(res.getBody()); - JobStatusResponse allRes = unMarshal(res.getBody().toString(), JobStatusResponse.class); - assertEquals(allRes.getResponseDescriptor().getProgress(), 100); - assertEquals(allRes.getResponseDescriptor().getStatus(), "FINISHED"); - if (!domainType.equals(ACCESS)) { - assertEquals(allRes.getResponseDescriptor().getResponseId(), "7512eb3feb5249eca5ddd742fedddd39"); - } - - } - - @Test - public void queryNSSISelectionCapability() throws Exception { - - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE); - ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); - assertNotNull(res); - assertNotNull(res.getBody()); - Map allRes = unMarshal(res.getBody().toString(), Map.class); - assertEquals(allRes.get("selection"), "NSMF"); - - System.out.println(res); - - nbiRequest.getEsrInfo().setVendor(NssmfAdapterConsts.ONAP_INTERNAL_TAG); - res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); - assertNotNull(res); - assertNotNull(res.getBody()); - allRes = unMarshal(res.getBody().toString(), Map.class); - assertEquals(allRes.get("selection"), "NSSMF"); - - System.out.println(res); - - nbiRequest.getEsrInfo().setNetworkType(NetworkType.ACCESS); - res = nssiManagerService.queryNSSISelectionCapability(nbiRequest); - assertNotNull(res); - assertNotNull(res.getBody()); - allRes = unMarshal(res.getBody().toString(), Map.class); - assertEquals(allRes.get("selection"), "NSSMF"); - - System.out.println(res); - } - - private NssmfAdapterNBIRequest createNbiRequest(NetworkType networkType) { - NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest(); - EsrInfo esrInfo = new EsrInfo(); - switch (networkType) { - case CORE: - esrInfo.setVendor("huawei"); - esrInfo.setNetworkType(CORE); - break; - case TRANSPORT: - esrInfo.setVendor("ONAP_internal"); - esrInfo.setNetworkType(TRANSPORT); - break; - case ACCESS: - esrInfo.setVendor("huawei"); - esrInfo.setNetworkType(ACCESS); - break; - } - ServiceInfo serviceInfo = new ServiceInfo(); - serviceInfo.setServiceUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b"); - serviceInfo.setServiceInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51"); - serviceInfo.setGlobalSubscriberId("5GCustomer"); - serviceInfo.setServiceType("5G"); - serviceInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - nbiRequest.setEsrInfo(esrInfo); - nbiRequest.setServiceInfo(serviceInfo); - return nbiRequest; - } - - @Test - public void querySubnetCapability() { - NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE); - - QuerySubnetCapability subnetCapabilityQuery = new QuerySubnetCapability(); - List<String> subnetTypes = Arrays.asList("CN"); - subnetCapabilityQuery.setSubnetTypes(subnetTypes); - nbiRequest.setSubnetCapabilityQuery(subnetCapabilityQuery); - ResponseEntity res = nssiManagerService.querySubnetCapability(nbiRequest); - assertNotNull(res); - assertNotNull(res.getBody()); - } -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.nssmf.service.impl;
+
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.conn.util.DomainType;
+import org.ehcache.config.ResourceType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.stubbing.Answer;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.so.adapters.nssmf.config.NssmfAdapterConfig;
+import org.onap.so.adapters.nssmf.consts.NssmfAdapterConsts;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.TokenResponse;
+import org.onap.so.adapters.nssmf.enums.ActionType;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.util.RestUtil;
+import org.onap.so.beans.nsmf.*;
+import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import javax.persistence.Access;
+import javax.persistence.ManyToOne;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.*;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
+import static org.onap.so.beans.nsmf.NetworkType.*;
+import static org.onap.so.beans.nsmf.ResourceSharingLevel.NON_SHARED;
+
+@RunWith(SpringRunner.class)
+public class NssmfManagerServiceImplTest {
+
+ @Mock
+ private RestUtil restUtil;
+
+
+ private NssmfManagerServiceImpl nssiManagerService;
+
+ @Mock
+ private HttpResponse tokenResponse;
+
+ @Mock
+ private HttpEntity tokenEntity;
+
+ @Mock
+ private HttpResponse commonResponse;
+
+ @Mock
+ private HttpEntity commonEntity;
+
+ @Mock
+ private StatusLine statusLine;
+
+ @Mock
+ private HttpClient httpClient;
+
+ private InputStream postStream;
+
+ private InputStream tokenStream;
+
+ @Mock
+ private NssmfAdapterConfig adapterConfig;
+
+ @Mock
+ private ResourceOperationStatusRepository repository;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+
+ nssiManagerService = new NssmfManagerServiceImpl();
+
+ Field restUtil = nssiManagerService.getClass().getDeclaredField("restUtil");
+ restUtil.setAccessible(true);
+ restUtil.set(nssiManagerService, this.restUtil);
+
+ Field adapterConfig = nssiManagerService.getClass().getDeclaredField("nssmfAdapterConfig");
+ adapterConfig.setAccessible(true);
+ adapterConfig.set(nssiManagerService, this.adapterConfig);
+
+ Field repository = nssiManagerService.getClass().getDeclaredField("repository");
+ repository.setAccessible(true);
+ repository.set(nssiManagerService, this.repository);
+ // nssiManagerService.setRestUtil(this.restUtil);
+
+ when(this.restUtil.send(any(String.class), any(HttpMethod.class), any(), any(Header.class)))
+ .thenCallRealMethod();
+ when(this.restUtil.createResponse(any(Integer.class), any(String.class))).thenCallRealMethod();
+ }
+
+ private void createCommonMock(int statusCode, NssmfInfo nssmf) throws Exception {
+ when(restUtil.getToken(any(NssmfInfo.class))).thenReturn("7512eb3feb5249eca5ddd742fedddd39");
+ when(restUtil.getHttpsClient()).thenReturn(httpClient);
+ when(restUtil.getServiceInstance(any())).thenReturn(new ServiceInstance());
+
+ when(statusLine.getStatusCode()).thenReturn(statusCode);
+ when(restUtil.getNssmfHost(any(EsrInfo.class))).thenReturn(nssmf);
+
+ when(tokenResponse.getEntity()).thenReturn(tokenEntity);
+ when(tokenResponse.getStatusLine()).thenReturn(statusLine);
+ when(tokenEntity.getContent()).thenReturn(tokenStream);
+
+ when(commonResponse.getEntity()).thenReturn(commonEntity);
+ when(commonResponse.getStatusLine()).thenReturn(statusLine);
+ when(commonEntity.getContent()).thenReturn(postStream);
+
+ when(adapterConfig.getInfraAuth()).thenReturn("SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==");
+
+ Answer<HttpResponse> answer = invocation -> {
+ Object[] arguments = invocation.getArguments();
+ if (arguments != null && arguments.length == 1 && arguments[0] != null) {
+
+ HttpRequestBase base = (HttpRequestBase) arguments[0];
+ if (base.getURI().toString().endsWith("/oauth/token")) {
+ return tokenResponse;
+ } else {
+ return commonResponse;
+ }
+ }
+ return commonResponse;
+ };
+
+ doAnswer(answer).when(httpClient).execute(any(HttpRequestBase.class));
+
+ }
+
+ @Test
+ public void allocateCnNssiTest() throws Exception {
+ allocateNssi(CORE);
+
+ }
+
+ @Test
+ public void allocateTnNssiTest() throws Exception {
+ allocateNssi(TRANSPORT);
+ }
+
+ @Test
+ public void allocateAnNssiTest() throws Exception {
+ allocateNssi(ACCESS);
+ }
+
+
+ public void allocateNssi(NetworkType domainType) throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+ nssmf.setUrl("http://127.0.0.1:8080");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+ nssiRes.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(200, nssmf);
+ NssmfAdapterNBIRequest nbiRequest = null;
+
+ switch (domainType) {
+ case CORE:
+ nbiRequest = createCnAllocateNssi();
+ break;
+ case TRANSPORT:
+ nbiRequest = createTnAllocateNssi();
+ break;
+ case ACCESS:
+ nbiRequest = createAnAllocateNssi();
+ break;
+ }
+
+ assertNotNull(nbiRequest);
+ System.out.println(marshal(nbiRequest));
+ ResponseEntity res = nssiManagerService.allocateNssi(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ if (!domainType.equals(ACCESS)) {
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ assertEquals(allRes.getNssiId(), "NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ }
+
+ System.out.println(res);
+ }
+
+
+
+ private NssmfAdapterNBIRequest createCnAllocateNssi() {
+ CnSliceProfile sP = new CnSliceProfile();
+ List<String> sns = new LinkedList<>();
+ sns.add("001-100001");
+ List<String> plmn = new LinkedList<>();
+ plmn.add("460-00");
+ plmn.add("460-01");
+ PerfReqEmbb embb = new PerfReqEmbb();
+ embb.setActivityFactor(50);
+ List<PerfReqEmbb> embbList = new LinkedList<>();
+ embbList.add(embb);
+ PerfReq perfReq = new PerfReq();
+ perfReq.setPerfReqEmbbList(embbList);
+ List<String> taList = new LinkedList<>();
+ taList.add("1");
+ taList.add("2");
+ taList.add("3");
+ sP.setSnssaiList(sns);
+ sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098");
+ sP.setPLMNIdList(plmn);
+ sP.setPerfReq(perfReq);
+ sP.setMaxNumberOfUEs(200);
+ sP.setCoverageAreaTAList(taList);
+ sP.setLatency(6);
+ sP.setResourceSharingLevel(NON_SHARED);
+ NsiInfo nsiInfo = new NsiInfo();
+ nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nsiInfo.setNsiName("eMBB-001");
+ AllocateCnNssi cnNssi = new AllocateCnNssi();
+ cnNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX");
+ cnNssi.setNssiName("eMBB-001");
+ cnNssi.setScriptName("CN1");
+ cnNssi.setSliceProfile(sP);
+ cnNssi.setNsiInfo(nsiInfo);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE);
+ nbiRequest.setAllocateCnNssi(cnNssi);
+ return nbiRequest;
+ }
+
+ private NssmfAdapterNBIRequest createAnAllocateNssi() {
+
+ AnSliceProfile sP = new AnSliceProfile();
+ List<String> sns = new LinkedList<>();
+ sns.add("001-100001");
+ List<String> plmn = new LinkedList<>();
+ plmn.add("460-00");
+ plmn.add("460-01");
+ PerfReqEmbb embb = new PerfReqEmbb();
+ embb.setActivityFactor(50);
+ List<PerfReqEmbb> embbList = new LinkedList<>();
+ embbList.add(embb);
+ PerfReq perfReq = new PerfReq();
+ perfReq.setPerfReqEmbbList(embbList);
+ List<Integer> taList = new LinkedList<>();
+ taList.add(1);
+ taList.add(2);
+ taList.add(3);
+ sP.setSNSSAIList(sns);
+ sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098");
+ sP.setPLMNIdList(plmn);
+ sP.setPerfReq(perfReq);
+ sP.setMaxNumberOfUEs(200);
+ sP.setCoverageAreaTAList(taList);
+ sP.setLatency(6);
+ sP.setResourceSharingLevel(NON_SHARED);
+ sP.setUeMobilityLevel(UeMobilityLevel.STATIONARY);
+ sP.setResourceSharingLevel(NON_SHARED);
+ NsiInfo nsiInfo = new NsiInfo();
+ nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nsiInfo.setNsiName("eMBB-001");
+ AllocateAnNssi anNssi = new AllocateAnNssi();
+ anNssi.setNssiId("NSST-C-001-HDBNJ-NSSMF-01-A-ZX");
+ anNssi.setNssiName("eMBB-001");
+ anNssi.setScriptName("CN1");
+ anNssi.setSliceProfile(sP);
+ anNssi.setNsiInfo(nsiInfo);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(ACCESS);
+ nbiRequest.setAllocateAnNssi(anNssi);
+ return nbiRequest;
+ }
+
+
+ private NssmfAdapterNBIRequest createTnAllocateNssi() {
+ TnSliceProfile sP = new TnSliceProfile();
+ List<String> sns = new LinkedList<>();
+ sns.add("01-1EB5BA40");
+ List<String> plmn = new LinkedList<>();
+ plmn.add("460-00");
+ PerfReqEmbb embb = new PerfReqEmbb();
+ embb.setActivityFactor(50);
+ List<PerfReqEmbb> embbList = new LinkedList<>();
+ embbList.add(embb);
+
+ sP.setSNSSAIList(sns);
+ sP.setSliceProfileId("fec94836-87a0-41dc-a199-0ad9aa3890d1");
+ sP.setPLMNIdList(plmn);
+ sP.setLatency(10);
+ sP.setMaxBandwidth(1000);
+ sP.setJitter(10);
+
+ List<TransportSliceNetwork> networks = new LinkedList<>();
+ TransportSliceNetwork network = new TransportSliceNetwork();
+ List<ConnectionLink> connectionLinks = new LinkedList<>();
+ ConnectionLink connectionLink = new ConnectionLink();
+ connectionLink.setTransportEndpointA("a47c76e3-c010-4eaf-adbb-0ba264118cab");
+ connectionLink.setTransportEndpointB("c0c83e33-80d2-43da-b6cb-17b930420d74");
+ connectionLinks.add(connectionLink);
+ network.setConnectionLinks(connectionLinks);
+ networks.add(network);
+
+ NsiInfo nsiInfo = new NsiInfo();
+ nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nsiInfo.setNsiName("eMBB-001");
+ AllocateTnNssi tnNssi = new AllocateTnNssi();
+ tnNssi.setTransportSliceNetworks(networks);
+ tnNssi.setScriptName("TN");
+ tnNssi.setSliceProfile(sP);
+ tnNssi.setNsiInfo(nsiInfo);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(TRANSPORT);
+ nbiRequest.setAllocateTnNssi(tnNssi);
+ return nbiRequest;
+ }
+
+ @Test
+ public void deAllocateCnNssi() throws Exception {
+ deAllocateNssi(CORE);
+ }
+
+ @Test
+ public void deAllocateAnNssi() throws Exception {
+ deAllocateNssi(ACCESS);
+ }
+
+ @Test
+ public void deAllocateTnNssi() throws Exception {
+ deAllocateNssi(TRANSPORT);
+ }
+
+ public void deAllocateNssi(NetworkType domainType) throws Exception {
+ DeAllocateNssi deAllocateNssi = new DeAllocateNssi();
+ deAllocateNssi.setTerminateNssiOption(0);
+ List<String> snssai = new LinkedList<>();
+ snssai.add("001-100001");
+ deAllocateNssi.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ deAllocateNssi.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+ deAllocateNssi.setScriptName("CN1");
+ deAllocateNssi.setSnssaiList(snssai);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(domainType);
+ nbiRequest.setDeAllocateNssi(deAllocateNssi);
+
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ createCommonMock(202, nssmf);
+ ResponseEntity res = nssiManagerService.deAllocateNssi(nbiRequest, "ab9af40f13f721b5f13539d87484098");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ if (!domainType.equals(ACCESS)) {
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+ }
+
+ @Test
+ public void activateAnNssi() throws Exception {
+ activateNssi(ACCESS);
+ }
+
+
+ @Test
+ public void activateCnNssi() throws Exception {
+ activateNssi(CORE);
+ }
+
+
+ @Test
+ public void activateTnNssi() throws Exception {
+ activateNssi(TRANSPORT);
+ }
+
+
+ private void activateNssi(NetworkType domainType) throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ ActDeActNssi act = new ActDeActNssi();
+ act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(domainType);
+ nbiRequest.setActDeActNssi(act);
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssiManagerService.activateNssi(nbiRequest, "001-100001");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ if (!domainType.equals(ACCESS)) {
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+ }
+
+ @Test
+ public void deActivateNssi() throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ NssiResponse nssiRes = new NssiResponse();
+ nssiRes.setJobId("4b45d919816ccaa2b762df5120f72067");
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(nssiRes).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ ActDeActNssi act = new ActDeActNssi();
+ act.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ act.setNssiId("NSSI-C-001-HDBNJ-NSSMF-01-A-ZX");
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE);
+ nbiRequest.setActDeActNssi(act);
+
+ createCommonMock(200, nssmf);
+ ResponseEntity res = nssiManagerService.deActivateNssi(nbiRequest, "001-100001");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ NssiResponse allRes = unMarshal(res.getBody().toString(), NssiResponse.class);
+ assertEquals(allRes.getJobId(), "4b45d919816ccaa2b762df5120f72067");
+ }
+
+ @Test
+ public void testNssmfRequest() throws ApplicationException {
+ NssmfRequest nssmfRequest = new NssmfRequest();
+ String sst = marshal(nssmfRequest);
+ System.out.println(sst);
+ }
+
+ @Test
+ public void queryCnAllocateJobStatus() throws Exception {
+ queryJobStatus(CORE, ActionType.ALLOCATE.toString());
+ }
+
+ @Test
+ public void queryCnActivateJobStatus() throws Exception {
+ queryJobStatus(CORE, ActionType.ACTIVATE.toString());
+ }
+
+ @Test
+ public void queryCnDeActivateJobStatus() throws Exception {
+ queryJobStatus(CORE, ActionType.DEACTIVATE.toString());
+ }
+
+ @Test
+ public void queryAnJobStatus() throws Exception {
+ queryJobStatus(ACCESS, ActionType.ALLOCATE.toString());
+ }
+
+ public void queryJobStatus(NetworkType domainType, String action) throws Exception {
+ NssmfInfo nssmf = new NssmfInfo();
+ nssmf.setUserName("nssmf-user");
+ nssmf.setPassword("nssmf-pass");
+ nssmf.setPort("8080");
+ nssmf.setIpAddress("127.0.0.1");
+
+ JobStatusResponse jobStatusResponse = new JobStatusResponse();
+ ResponseDescriptor descriptor = new ResponseDescriptor();
+ descriptor.setResponseId("7512eb3feb5249eca5ddd742fedddd39");
+ descriptor.setProgress(100);
+ descriptor.setStatusDescription("Initiating VNF Instance");
+ descriptor.setStatus("FINISHED");
+ jobStatusResponse.setResponseDescriptor(descriptor);
+
+ TokenResponse token = new TokenResponse();
+ token.setAccessToken("7512eb3feb5249eca5ddd742fedddd39");
+ token.setExpires(1800);
+
+ postStream = new ByteArrayInputStream(marshal(jobStatusResponse).getBytes(UTF_8));
+ tokenStream = new ByteArrayInputStream(marshal(token).getBytes(UTF_8));
+
+ ResourceOperationStatus operationStatus = new ResourceOperationStatus();
+ operationStatus.setOperationId("4b45d919816ccaa2b762df5120f72067");
+ operationStatus.setResourceTemplateUUID("8ee5926d-720b-4bb2-86f9-d20e921c143b");
+ operationStatus.setServiceId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ operationStatus.setOperType(action);
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(domainType);
+ nbiRequest.setResponseId("7512eb3feb5249eca5ddd742fedddd39");
+ List<ResourceOperationStatus> optional = new ArrayList<>();
+ optional.add(operationStatus);
+
+ doAnswer(invocation -> optional).when(repository).findByServiceIdAndOperationId(any(), any());
+
+ createCommonMock(200, nssmf);
+
+ ResponseEntity res = nssiManagerService.queryJobStatus(nbiRequest, "4b45d919816ccaa2b762df5120f72067");
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ JobStatusResponse allRes = unMarshal(res.getBody().toString(), JobStatusResponse.class);
+ assertEquals(allRes.getResponseDescriptor().getProgress(), 100);
+ assertEquals(allRes.getResponseDescriptor().getStatus(), "FINISHED");
+ if (!domainType.equals(ACCESS)) {
+ assertEquals(allRes.getResponseDescriptor().getResponseId(), "7512eb3feb5249eca5ddd742fedddd39");
+ }
+
+ }
+
+ @Test
+ public void queryNSSISelectionCapability() throws Exception {
+
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE);
+ ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ Map allRes = unMarshal(res.getBody().toString(), Map.class);
+ assertEquals(allRes.get("selection"), "NSMF");
+
+ System.out.println(res);
+
+ nbiRequest.getEsrInfo().setVendor(NssmfAdapterConsts.ONAP_INTERNAL_TAG);
+ res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ allRes = unMarshal(res.getBody().toString(), Map.class);
+ assertEquals(allRes.get("selection"), "NSSMF");
+
+ System.out.println(res);
+
+ nbiRequest.getEsrInfo().setNetworkType(NetworkType.ACCESS);
+ res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ allRes = unMarshal(res.getBody().toString(), Map.class);
+ assertEquals(allRes.get("selection"), "NSSMF");
+
+ System.out.println(res);
+ }
+
+ private NssmfAdapterNBIRequest createNbiRequest(NetworkType networkType) {
+ NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest();
+ EsrInfo esrInfo = new EsrInfo();
+ switch (networkType) {
+ case CORE:
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ break;
+ case TRANSPORT:
+ esrInfo.setVendor("ONAP_internal");
+ esrInfo.setNetworkType(TRANSPORT);
+ break;
+ case ACCESS:
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(ACCESS);
+ break;
+ }
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b");
+ serviceInfo.setServiceInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51");
+ serviceInfo.setGlobalSubscriberId("5GCustomer");
+ serviceInfo.setServiceType("5G");
+ serviceInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ nbiRequest.setEsrInfo(esrInfo);
+ nbiRequest.setServiceInfo(serviceInfo);
+ return nbiRequest;
+ }
+
+ @Test
+ public void querySubnetCapability() {
+ NssmfAdapterNBIRequest nbiRequest = createNbiRequest(CORE);
+
+ QuerySubnetCapability subnetCapabilityQuery = new QuerySubnetCapability();
+ List<String> subnetTypes = Arrays.asList("CN");
+ subnetCapabilityQuery.setSubnetTypes(subnetTypes);
+ nbiRequest.setSubnetCapabilityQuery(subnetCapabilityQuery);
+ ResponseEntity res = nssiManagerService.querySubnetCapability(nbiRequest);
+ assertNotNull(res);
+ assertNotNull(res.getBody());
+ }
+}
diff --git a/src/test/java/org/onap/so/adapters/nssmf/util/RestUtilTest.java b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/util/RestUtilTest.java index ddc9371..5d07c5e 100644 --- a/src/test/java/org/onap/so/adapters/nssmf/util/RestUtilTest.java +++ b/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/util/RestUtilTest.java @@ -1,161 +1,161 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - # Copyright (c) 2020, CMCC Technologies Co., Ltd. - # - # Licensed under the Apache License, Version 2.0 (the "License") - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.adapters.nssmf.util; - -import org.apache.commons.lang3.StringUtils; -import org.apache.http.Header; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.StatusLine; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpRequestBase; -import org.hibernate.jdbc.Expectations; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.Spy; -import org.mockito.stubbing.Answer; -import org.onap.aai.domain.yang.ServiceInstance; -import org.onap.so.adapters.nssmf.entity.NssmfInfo; -import org.onap.so.adapters.nssmf.entity.RestResponse; -import org.onap.so.adapters.nssmf.enums.HttpMethod; -import org.onap.so.adapters.nssmf.exceptions.ApplicationException; -import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider; -import org.onap.so.beans.nsmf.EsrInfo; -import org.onap.so.beans.nsmf.ServiceInfo; -import org.springframework.test.context.junit4.SpringRunner; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.util.Optional; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.onap.so.beans.nsmf.NetworkType.CORE; - -@RunWith(SpringRunner.class) -public class RestUtilTest { - - - @Mock - public HttpClient httpClient; - @Mock - private HttpResponse tokenResponse; - - @Mock - private HttpEntity tokenEntity; - - private InputStream tokenStream; - - @Mock - private StatusLine statusLine; - - @Mock - private AaiServiceProvider aaiSvcProv; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - // Field nssmfManagerService = controller.getClass().getDeclaredField("nssmfManagerService"); - // nssmfManagerService.setAccessible(true); - // nssmfManagerService.set(controller, this.nssmfManagerService); - } - - private void commonMock() throws IOException, ApplicationException { - - when(tokenResponse.getEntity()).thenReturn(tokenEntity); - when(tokenResponse.getStatusLine()).thenReturn(statusLine); - - when(tokenEntity.getContent()).thenReturn(tokenStream); - - when(httpClient.execute(any())).thenReturn(tokenResponse); - - // Mockito.doReturn(httpClient).when(restUtil).getHttpsClient(); - } - - @Test - public void sendTest() throws Exception { - String url = "http://127.0.0.1:8080"; - HttpMethod method = HttpMethod.PUT; - String content = "body content"; - commonMock(); - - RestUtil restUtil = new RestUtil(); - RestUtil util = Mockito.spy(restUtil); - doReturn(httpClient).when(util).getHttpsClient(); - - RestResponse restResponse = util.send(url, method, content, null); - assertNotNull(restResponse); - } - - @Test - public void serviceInstanceOperationTest() throws NoSuchFieldException, IllegalAccessException { - - RestUtil restUtil = new RestUtil(); - - Field aaiSvcProv = restUtil.getClass().getDeclaredField("aaiSvcProv"); - aaiSvcProv.setAccessible(true); - aaiSvcProv.set(restUtil, this.aaiSvcProv); - - ServiceInstance instance = new ServiceInstance(); - ServiceInfo info = getServiceInfo(); - restUtil.createServiceInstance(instance, info); - restUtil.getServiceInstance(info); - restUtil.deleteServiceInstance(info); - } - - @Test - public void getNssmfHostTest() throws NoSuchFieldException, IllegalAccessException { - RestUtil restUtil = new RestUtil(); - - Field aaiSvcProv = restUtil.getClass().getDeclaredField("aaiSvcProv"); - aaiSvcProv.setAccessible(true); - aaiSvcProv.set(restUtil, this.aaiSvcProv); - try { - restUtil.getNssmfHost(getEsrInfo()); - } catch (ApplicationException ex) { - System.out.println(ex.getErrorMsg()); - } - } - - - private EsrInfo getEsrInfo() { - EsrInfo esrInfo = new EsrInfo(); - esrInfo.setVendor("huawei"); - esrInfo.setNetworkType(CORE); - return esrInfo; - } - - private ServiceInfo getServiceInfo() { - ServiceInfo serviceInfo = new ServiceInfo(); - serviceInfo.setServiceUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b"); - serviceInfo.setServiceInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51"); - serviceInfo.setGlobalSubscriberId("5GCustomer"); - serviceInfo.setServiceType("5G"); - serviceInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); - return serviceInfo; - } - -} +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2020, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.nssmf.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.hibernate.jdbc.Expectations;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.mockito.stubbing.Answer;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.so.adapters.nssmf.entity.NssmfInfo;
+import org.onap.so.adapters.nssmf.entity.RestResponse;
+import org.onap.so.adapters.nssmf.enums.HttpMethod;
+import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
+import org.onap.so.adapters.nssmf.extclients.aai.AaiServiceProvider;
+import org.onap.so.beans.nsmf.EsrInfo;
+import org.onap.so.beans.nsmf.ServiceInfo;
+import org.springframework.test.context.junit4.SpringRunner;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.util.Optional;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+import static org.mockito.MockitoAnnotations.initMocks;
+import static org.onap.so.beans.nsmf.NetworkType.CORE;
+
+@RunWith(SpringRunner.class)
+public class RestUtilTest {
+
+
+ @Mock
+ public HttpClient httpClient;
+ @Mock
+ private HttpResponse tokenResponse;
+
+ @Mock
+ private HttpEntity tokenEntity;
+
+ private InputStream tokenStream;
+
+ @Mock
+ private StatusLine statusLine;
+
+ @Mock
+ private AaiServiceProvider aaiSvcProv;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ // Field nssmfManagerService = controller.getClass().getDeclaredField("nssmfManagerService");
+ // nssmfManagerService.setAccessible(true);
+ // nssmfManagerService.set(controller, this.nssmfManagerService);
+ }
+
+ private void commonMock() throws IOException, ApplicationException {
+
+ when(tokenResponse.getEntity()).thenReturn(tokenEntity);
+ when(tokenResponse.getStatusLine()).thenReturn(statusLine);
+
+ when(tokenEntity.getContent()).thenReturn(tokenStream);
+
+ when(httpClient.execute(any())).thenReturn(tokenResponse);
+
+ // Mockito.doReturn(httpClient).when(restUtil).getHttpsClient();
+ }
+
+ @Test
+ public void sendTest() throws Exception {
+ String url = "http://127.0.0.1:8080";
+ HttpMethod method = HttpMethod.PUT;
+ String content = "body content";
+ commonMock();
+
+ RestUtil restUtil = new RestUtil();
+ RestUtil util = Mockito.spy(restUtil);
+ doReturn(httpClient).when(util).getHttpsClient();
+
+ RestResponse restResponse = util.send(url, method, content, null);
+ assertNotNull(restResponse);
+ }
+
+ @Test
+ public void serviceInstanceOperationTest() throws NoSuchFieldException, IllegalAccessException {
+
+ RestUtil restUtil = new RestUtil();
+
+ Field aaiSvcProv = restUtil.getClass().getDeclaredField("aaiSvcProv");
+ aaiSvcProv.setAccessible(true);
+ aaiSvcProv.set(restUtil, this.aaiSvcProv);
+
+ ServiceInstance instance = new ServiceInstance();
+ ServiceInfo info = getServiceInfo();
+ restUtil.createServiceInstance(instance, info);
+ restUtil.getServiceInstance(info);
+ restUtil.deleteServiceInstance(info);
+ }
+
+ @Test
+ public void getNssmfHostTest() throws NoSuchFieldException, IllegalAccessException {
+ RestUtil restUtil = new RestUtil();
+
+ Field aaiSvcProv = restUtil.getClass().getDeclaredField("aaiSvcProv");
+ aaiSvcProv.setAccessible(true);
+ aaiSvcProv.set(restUtil, this.aaiSvcProv);
+ try {
+ restUtil.getNssmfHost(getEsrInfo());
+ } catch (ApplicationException ex) {
+ System.out.println(ex.getErrorMsg());
+ }
+ }
+
+
+ private EsrInfo getEsrInfo() {
+ EsrInfo esrInfo = new EsrInfo();
+ esrInfo.setVendor("huawei");
+ esrInfo.setNetworkType(CORE);
+ return esrInfo;
+ }
+
+ private ServiceInfo getServiceInfo() {
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setServiceUuid("8ee5926d-720b-4bb2-86f9-d20e921c143b");
+ serviceInfo.setServiceInvariantUuid("e75698d9-925a-4cdd-a6c0-edacbe6a0b51");
+ serviceInfo.setGlobalSubscriberId("5GCustomer");
+ serviceInfo.setServiceType("5G");
+ serviceInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX");
+ return serviceInfo;
+ }
+
+}
diff --git a/src/test/resources/application-test.yaml b/so-nssmf-adapter-application/src/test/resources/application-test.yaml index fa323e8..adb741e 100644 --- a/src/test/resources/application-test.yaml +++ b/so-nssmf-adapter-application/src/test/resources/application-test.yaml @@ -1,60 +1,60 @@ - -aai: - auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 - endpoint: https://aai.onap:30233 -logging: - path: logs - -spring: - datasource: - username: root - password: 123456 - driver-class-name: org.mariadb.jdbc.Driver - initialization-mode: always - url: jdbc:mariadb://49.232.146.162:8989/requestdb - jpa: - generate-ddl: false - show-sql: false - hibernate: - ddl-auto: none - naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy - enable-lazy-load-no-trans: true - database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - security: - usercredentials: - - username: bpel - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: BPEL-Client - - username: mso_admin - password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' - role: ACTUATOR -server: - port: 8080 - tomcat: - max-threads: 50 - -mso: - key: 07a7159d3bf51a0e53be7a8f89699be7 - site-name: localSite - logPath: ./logs/nssmf - adapters: - requestDb: - endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083 - auth: Basic YnBlbDpwYXNzd29yZDEk - infra: - endpoint: https://so.{{ include "common.namespace" . }}:8080 - auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA== - -#Actuator -management: - endpoints: - web: - base-path: /manage - exposure: - include: "*" - metrics: - se-global-registry: false - export: - prometheus: - enabled: true # Whether exporting of metrics to Prometheus is enabled. +
+aai:
+ auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586
+ endpoint: https://aai.onap:30233
+logging:
+ path: logs
+
+spring:
+ datasource:
+ username: root
+ password: 123456
+ driver-class-name: org.mariadb.jdbc.Driver
+ initialization-mode: always
+ url: jdbc:mariadb://49.232.146.162:8989/requestdb
+ jpa:
+ generate-ddl: false
+ show-sql: false
+ hibernate:
+ ddl-auto: none
+ naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
+ enable-lazy-load-no-trans: true
+ database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
+ security:
+ usercredentials:
+ - username: bpel
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ - username: mso_admin
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: ACTUATOR
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+ site-name: localSite
+ logPath: ./logs/nssmf
+ adapters:
+ requestDb:
+ endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083
+ auth: Basic YnBlbDpwYXNzd29yZDEk
+ infra:
+ endpoint: https://so.{{ include "common.namespace" . }}:8080
+ auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
+
+#Actuator
+management:
+ endpoints:
+ web:
+ base-path: /manage
+ exposure:
+ include: "*"
+ metrics:
+ se-global-registry: false
+ export:
+ prometheus:
+ enabled: true # Whether exporting of metrics to Prometheus is enabled.
step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/version.properties b/version.properties index 013f1ac..013f1ac 100644..100755 --- a/version.properties +++ b/version.properties |