diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..14826708af --- /dev/null +++ b/.editorconfig @@ -0,0 +1,1101 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 80 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = false +ij_smart_tabs = false +ij_visual_guides = 80,120 +ij_wrap_on_typing = false + +[] +indent_size = 2 +tab_width = 2 + +[*.bib] +ij_bibtex_keep_first_column_comment = true +ij_bibtex_keep_indents_on_empty_lines = false +ij_bibtex_wrap_long_lines = false + +[*.css] +ij_css_align_closing_brace_with_properties = false +ij_css_blank_lines_around_nested_selector = 1 +ij_css_blank_lines_between_blocks = 1 +ij_css_brace_placement = end_of_line +ij_css_enforce_quotes_on_format = false +ij_css_hex_color_long_format = false +ij_css_hex_color_lower_case = false +ij_css_hex_color_short_format = false +ij_css_hex_color_upper_case = false +ij_css_keep_blank_lines_in_code = 2 +ij_css_keep_indents_on_empty_lines = false +ij_css_keep_single_line_blocks = false +ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow +ij_css_space_after_colon = true +ij_css_space_before_opening_brace = true +ij_css_use_double_quotes = true +ij_css_value_alignment = do_not_align + +[*.java] +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = off +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_at_first_column = true +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = off +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = false +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 5 +ij_java_class_names_in_javadoc = 1 +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_while_brace_force = never +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_enum_constants_wrap = off +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_finally_on_new_line = false +ij_java_for_brace_force = never +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = never +ij_java_imports_layout = *,|,javax.**,java.**,|,$* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = true +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_at_first_column = true +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = off +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = off +ij_java_modifier_list_wrap = false +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_new_line_after_lparen_in_record_header = false +ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.* +ij_java_parameter_annotation_wrap = off +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = false +ij_java_record_components_wrap = normal +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_record_header = false +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = false +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_subclass_name_suffix = Impl +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + +[*.properties] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false + +[*.scala] +ij_continuation_indent_size = 2 +ij_scala_align_composite_pattern = true +ij_scala_align_extends_with = 0 +ij_scala_align_group_field_declarations = false +ij_scala_align_if_else = false +ij_scala_align_in_columns_case_branch = false +ij_scala_align_multiline_binary_operation = false +ij_scala_align_multiline_chained_methods = false +ij_scala_align_multiline_for = true +ij_scala_align_multiline_parameters = true +ij_scala_align_multiline_parameters_in_calls = false +ij_scala_align_multiline_parenthesized_expression = false +ij_scala_align_tuple_elements = false +ij_scala_align_types_in_multiline_declarations = false +ij_scala_alternate_continuation_indent_for_params = 4 +ij_scala_binary_operation_wrap = off +ij_scala_blank_lines_after_anonymous_class_header = 0 +ij_scala_blank_lines_after_class_header = 0 +ij_scala_blank_lines_after_imports = 1 +ij_scala_blank_lines_after_package = 1 +ij_scala_blank_lines_around_class = 1 +ij_scala_blank_lines_around_field = 0 +ij_scala_blank_lines_around_field_in_inner_scopes = 0 +ij_scala_blank_lines_around_field_in_interface = 0 +ij_scala_blank_lines_around_method = 1 +ij_scala_blank_lines_around_method_in_inner_scopes = 1 +ij_scala_blank_lines_around_method_in_interface = 1 +ij_scala_blank_lines_before_imports = 1 +ij_scala_blank_lines_before_method_body = 0 +ij_scala_blank_lines_before_package = 0 +ij_scala_block_brace_style = end_of_line +ij_scala_block_comment_at_first_column = true +ij_scala_call_parameters_new_line_after_lparen = 0 +ij_scala_call_parameters_right_paren_on_new_line = false +ij_scala_call_parameters_wrap = off +ij_scala_case_clause_brace_force = never +ij_scala_catch_on_new_line = false +ij_scala_class_annotation_wrap = split_into_lines +ij_scala_class_brace_style = end_of_line +ij_scala_closure_brace_force = never +ij_scala_do_not_align_block_expr_params = true +ij_scala_do_not_indent_case_clause_body = false +ij_scala_do_not_indent_tuples_close_brace = true +ij_scala_do_while_brace_force = never +ij_scala_else_on_new_line = false +ij_scala_enable_scaladoc_formatting = true +ij_scala_enforce_functional_syntax_for_unit = true +ij_scala_extends_keyword_wrap = off +ij_scala_extends_list_wrap = off +ij_scala_field_annotation_wrap = split_into_lines +ij_scala_finally_brace_force = never +ij_scala_finally_on_new_line = false +ij_scala_for_brace_force = never +ij_scala_for_statement_wrap = off +ij_scala_formatter = 0 +ij_scala_if_brace_force = never +ij_scala_implicit_value_class_suffix = Ops +ij_scala_indent_braced_function_args = true +ij_scala_indent_case_from_switch = true +ij_scala_indent_first_parameter = true +ij_scala_indent_first_parameter_clause = false +ij_scala_indent_type_arguments = true +ij_scala_indent_type_parameters = true +ij_scala_insert_whitespaces_in_simple_one_line_method = true +ij_scala_keep_blank_lines_before_right_brace = 2 +ij_scala_keep_blank_lines_in_code = 2 +ij_scala_keep_blank_lines_in_declarations = 2 +ij_scala_keep_comments_on_same_line = true +ij_scala_keep_first_column_comment = false +ij_scala_keep_indents_on_empty_lines = false +ij_scala_keep_line_breaks = true +ij_scala_keep_one_line_lambdas_in_arg_list = false +ij_scala_keep_simple_blocks_in_one_line = false +ij_scala_keep_simple_methods_in_one_line = false +ij_scala_keep_xml_formatting = false +ij_scala_line_comment_at_first_column = true +ij_scala_method_annotation_wrap = split_into_lines +ij_scala_method_brace_force = never +ij_scala_method_brace_style = end_of_line +ij_scala_method_call_chain_wrap = off +ij_scala_method_parameters_new_line_after_left_paren = false +ij_scala_method_parameters_right_paren_on_new_line = false +ij_scala_method_parameters_wrap = off +ij_scala_modifier_list_wrap = false +ij_scala_multiline_string_align_dangling_closing_quotes = false +ij_scala_multiline_string_closing_quotes_on_new_line = false +ij_scala_multiline_string_insert_margin_on_enter = true +ij_scala_multiline_string_margin_char = | +ij_scala_multiline_string_margin_indent = 2 +ij_scala_multiline_string_opening_quotes_on_new_line = true +ij_scala_multiline_string_process_margin_on_copy_paste = true +ij_scala_newline_after_annotations = false +ij_scala_not_continuation_indent_for_params = false +ij_scala_parameter_annotation_wrap = off +ij_scala_parentheses_expression_new_line_after_left_paren = false +ij_scala_parentheses_expression_right_paren_on_new_line = false +ij_scala_place_closure_parameters_on_new_line = false +ij_scala_place_self_type_on_new_line = true +ij_scala_prefer_parameters_wrap = false +ij_scala_preserve_space_after_method_declaration_name = false +ij_scala_reformat_on_compile = false +ij_scala_replace_case_arrow_with_unicode_char = false +ij_scala_replace_for_generator_arrow_with_unicode_char = false +ij_scala_replace_lambda_with_greek_letter = false +ij_scala_replace_map_arrow_with_unicode_char = false +ij_scala_scalafmt_reformat_on_files_save = false +ij_scala_scalafmt_show_invalid_code_warnings = true +ij_scala_scalafmt_use_intellij_formatter_for_range_format = true +ij_scala_sd_align_exception_comments = true +ij_scala_sd_align_other_tags_comments = true +ij_scala_sd_align_parameters_comments = true +ij_scala_sd_align_return_comments = true +ij_scala_sd_blank_line_after_parameters_comments = false +ij_scala_sd_blank_line_after_return_comments = false +ij_scala_sd_blank_line_before_parameters = false +ij_scala_sd_blank_line_before_tags = true +ij_scala_sd_blank_line_between_parameters = false +ij_scala_sd_keep_blank_lines_between_tags = false +ij_scala_sd_preserve_spaces_in_tags = false +ij_scala_space_after_comma = true +ij_scala_space_after_for_semicolon = true +ij_scala_space_after_modifiers_constructor = false +ij_scala_space_after_type_colon = true +ij_scala_space_before_brace_method_call = true +ij_scala_space_before_class_left_brace = true +ij_scala_space_before_infix_like_method_parentheses = false +ij_scala_space_before_infix_method_call_parentheses = false +ij_scala_space_before_infix_operator_like_method_call_parentheses = true +ij_scala_space_before_method_call_parentheses = false +ij_scala_space_before_method_left_brace = true +ij_scala_space_before_method_parentheses = false +ij_scala_space_before_type_colon = false +ij_scala_space_before_type_parameter_in_def_list = false +ij_scala_space_before_type_parameter_leading_context_bound_colon = false +ij_scala_space_before_type_parameter_leading_context_bound_colon_hk = true +ij_scala_space_before_type_parameter_list = false +ij_scala_space_before_type_parameter_rest_context_bound_colons = true +ij_scala_space_inside_closure_braces = true +ij_scala_space_inside_self_type_braces = true +ij_scala_space_within_empty_method_call_parentheses = false +ij_scala_spaces_around_at_in_patterns = false +ij_scala_spaces_in_imports = false +ij_scala_spaces_in_one_line_blocks = false +ij_scala_spaces_within_brackets = false +ij_scala_spaces_within_for_parentheses = false +ij_scala_spaces_within_if_parentheses = false +ij_scala_spaces_within_method_call_parentheses = false +ij_scala_spaces_within_method_parentheses = false +ij_scala_spaces_within_parentheses = false +ij_scala_spaces_within_while_parentheses = false +ij_scala_special_else_if_treatment = true +ij_scala_trailing_comma_arg_list_enabled = true +ij_scala_trailing_comma_import_selector_enabled = false +ij_scala_trailing_comma_mode = trailing_comma_keep +ij_scala_trailing_comma_params_enabled = true +ij_scala_trailing_comma_pattern_arg_list_enabled = false +ij_scala_trailing_comma_tuple_enabled = false +ij_scala_trailing_comma_tuple_type_enabled = false +ij_scala_trailing_comma_type_params_enabled = false +ij_scala_try_brace_force = never +ij_scala_type_annotation_exclude_constant = true +ij_scala_type_annotation_exclude_in_dialect_sources = true +ij_scala_type_annotation_exclude_in_test_sources = false +ij_scala_type_annotation_exclude_member_of_anonymous_class = false +ij_scala_type_annotation_exclude_member_of_private_class = false +ij_scala_type_annotation_exclude_when_type_is_stable = true +ij_scala_type_annotation_function_parameter = false +ij_scala_type_annotation_implicit_modifier = true +ij_scala_type_annotation_local_definition = false +ij_scala_type_annotation_private_member = false +ij_scala_type_annotation_protected_member = true +ij_scala_type_annotation_public_member = true +ij_scala_type_annotation_structural_type = true +ij_scala_type_annotation_underscore_parameter = false +ij_scala_type_annotation_unit_type = true +ij_scala_use_alternate_continuation_indent_for_params = false +ij_scala_use_scaladoc2_formatting = false +ij_scala_variable_annotation_wrap = off +ij_scala_while_brace_force = never +ij_scala_while_on_new_line = false +ij_scala_wrap_before_with_keyword = false +ij_scala_wrap_first_method_in_call_chain = false +ij_scala_wrap_long_lines = false + +[*.tikz] +ij_latex_keep_first_column_comment = true +ij_latex_keep_indents_on_empty_lines = false +ij_latex_line_comment_add_space = false +ij_latex_line_comment_at_first_column = true +ij_latex_wrap_long_lines = false + +[*.ttl] +ij_turtle_keep_indents_on_empty_lines = false +ij_turtle_keep_line_breaks = true +ij_turtle_space_after_comma = true +ij_turtle_space_after_for_semicolon = true +ij_turtle_space_before_comma = false +ij_turtle_space_before_for_semicolon = false +ij_turtle_wrap_long_lines = false + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,phpunit.xml.dist}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal + +[{*.ats,*.ts}] +ij_continuation_indent_size = 4 +ij_typescript_align_imports = false +ij_typescript_align_multiline_array_initializer_expression = false +ij_typescript_align_multiline_binary_operation = false +ij_typescript_align_multiline_chained_methods = false +ij_typescript_align_multiline_extends_list = false +ij_typescript_align_multiline_for = true +ij_typescript_align_multiline_parameters = true +ij_typescript_align_multiline_parameters_in_calls = false +ij_typescript_align_multiline_ternary_operation = false +ij_typescript_align_object_properties = 0 +ij_typescript_align_union_types = false +ij_typescript_align_var_statements = 0 +ij_typescript_array_initializer_new_line_after_left_brace = false +ij_typescript_array_initializer_right_brace_on_new_line = false +ij_typescript_array_initializer_wrap = off +ij_typescript_assignment_wrap = off +ij_typescript_binary_operation_sign_on_next_line = false +ij_typescript_binary_operation_wrap = off +ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_typescript_blank_lines_after_imports = 1 +ij_typescript_blank_lines_around_class = 1 +ij_typescript_blank_lines_around_field = 0 +ij_typescript_blank_lines_around_field_in_interface = 0 +ij_typescript_blank_lines_around_function = 1 +ij_typescript_blank_lines_around_method = 1 +ij_typescript_blank_lines_around_method_in_interface = 1 +ij_typescript_block_brace_style = end_of_line +ij_typescript_call_parameters_new_line_after_left_paren = false +ij_typescript_call_parameters_right_paren_on_new_line = false +ij_typescript_call_parameters_wrap = off +ij_typescript_catch_on_new_line = false +ij_typescript_chained_call_dot_on_new_line = true +ij_typescript_class_brace_style = end_of_line +ij_typescript_comma_on_new_line = false +ij_typescript_do_while_brace_force = never +ij_typescript_else_on_new_line = false +ij_typescript_enforce_trailing_comma = keep +ij_typescript_extends_keyword_wrap = off +ij_typescript_extends_list_wrap = off +ij_typescript_field_prefix = _ +ij_typescript_file_name_style = relaxed +ij_typescript_finally_on_new_line = false +ij_typescript_for_brace_force = never +ij_typescript_for_statement_new_line_after_left_paren = false +ij_typescript_for_statement_right_paren_on_new_line = false +ij_typescript_for_statement_wrap = off +ij_typescript_force_quote_style = false +ij_typescript_force_semicolon_style = false +ij_typescript_function_expression_brace_style = end_of_line +ij_typescript_if_brace_force = never +ij_typescript_import_merge_members = global +ij_typescript_import_prefer_absolute_path = global +ij_typescript_import_sort_members = true +ij_typescript_import_sort_module_name = false +ij_typescript_import_use_node_resolution = true +ij_typescript_imports_wrap = on_every_item +ij_typescript_indent_case_from_switch = true +ij_typescript_indent_chained_calls = true +ij_typescript_indent_package_children = 0 +ij_typescript_jsdoc_include_types = false +ij_typescript_jsx_attribute_value = braces +ij_typescript_keep_blank_lines_in_code = 2 +ij_typescript_keep_first_column_comment = true +ij_typescript_keep_indents_on_empty_lines = false +ij_typescript_keep_line_breaks = true +ij_typescript_keep_simple_blocks_in_one_line = false +ij_typescript_keep_simple_methods_in_one_line = false +ij_typescript_line_comment_add_space = true +ij_typescript_line_comment_at_first_column = false +ij_typescript_method_brace_style = end_of_line +ij_typescript_method_call_chain_wrap = off +ij_typescript_method_parameters_new_line_after_left_paren = false +ij_typescript_method_parameters_right_paren_on_new_line = false +ij_typescript_method_parameters_wrap = off +ij_typescript_object_literal_wrap = on_every_item +ij_typescript_parentheses_expression_new_line_after_left_paren = false +ij_typescript_parentheses_expression_right_paren_on_new_line = false +ij_typescript_place_assignment_sign_on_next_line = false +ij_typescript_prefer_as_type_cast = false +ij_typescript_prefer_explicit_types_function_expression_returns = false +ij_typescript_prefer_explicit_types_function_returns = false +ij_typescript_prefer_explicit_types_vars_fields = false +ij_typescript_prefer_parameters_wrap = false +ij_typescript_reformat_c_style_comments = false +ij_typescript_space_after_colon = true +ij_typescript_space_after_comma = true +ij_typescript_space_after_dots_in_rest_parameter = false +ij_typescript_space_after_generator_mult = true +ij_typescript_space_after_property_colon = true +ij_typescript_space_after_quest = true +ij_typescript_space_after_type_colon = true +ij_typescript_space_after_unary_not = false +ij_typescript_space_before_async_arrow_lparen = true +ij_typescript_space_before_catch_keyword = true +ij_typescript_space_before_catch_left_brace = true +ij_typescript_space_before_catch_parentheses = true +ij_typescript_space_before_class_lbrace = true +ij_typescript_space_before_class_left_brace = true +ij_typescript_space_before_colon = true +ij_typescript_space_before_comma = false +ij_typescript_space_before_do_left_brace = true +ij_typescript_space_before_else_keyword = true +ij_typescript_space_before_else_left_brace = true +ij_typescript_space_before_finally_keyword = true +ij_typescript_space_before_finally_left_brace = true +ij_typescript_space_before_for_left_brace = true +ij_typescript_space_before_for_parentheses = true +ij_typescript_space_before_for_semicolon = false +ij_typescript_space_before_function_left_parenth = true +ij_typescript_space_before_generator_mult = false +ij_typescript_space_before_if_left_brace = true +ij_typescript_space_before_if_parentheses = true +ij_typescript_space_before_method_call_parentheses = false +ij_typescript_space_before_method_left_brace = true +ij_typescript_space_before_method_parentheses = false +ij_typescript_space_before_property_colon = false +ij_typescript_space_before_quest = true +ij_typescript_space_before_switch_left_brace = true +ij_typescript_space_before_switch_parentheses = true +ij_typescript_space_before_try_left_brace = true +ij_typescript_space_before_type_colon = false +ij_typescript_space_before_unary_not = false +ij_typescript_space_before_while_keyword = true +ij_typescript_space_before_while_left_brace = true +ij_typescript_space_before_while_parentheses = true +ij_typescript_spaces_around_additive_operators = true +ij_typescript_spaces_around_arrow_function_operator = true +ij_typescript_spaces_around_assignment_operators = true +ij_typescript_spaces_around_bitwise_operators = true +ij_typescript_spaces_around_equality_operators = true +ij_typescript_spaces_around_logical_operators = true +ij_typescript_spaces_around_multiplicative_operators = true +ij_typescript_spaces_around_relational_operators = true +ij_typescript_spaces_around_shift_operators = true +ij_typescript_spaces_around_unary_operator = false +ij_typescript_spaces_within_array_initializer_brackets = false +ij_typescript_spaces_within_brackets = false +ij_typescript_spaces_within_catch_parentheses = false +ij_typescript_spaces_within_for_parentheses = false +ij_typescript_spaces_within_if_parentheses = false +ij_typescript_spaces_within_imports = false +ij_typescript_spaces_within_interpolation_expressions = false +ij_typescript_spaces_within_method_call_parentheses = false +ij_typescript_spaces_within_method_parentheses = false +ij_typescript_spaces_within_object_literal_braces = false +ij_typescript_spaces_within_object_type_braces = true +ij_typescript_spaces_within_parentheses = false +ij_typescript_spaces_within_switch_parentheses = false +ij_typescript_spaces_within_type_assertion = false +ij_typescript_spaces_within_union_types = true +ij_typescript_spaces_within_while_parentheses = false +ij_typescript_special_else_if_treatment = true +ij_typescript_ternary_operation_signs_on_next_line = false +ij_typescript_ternary_operation_wrap = off +ij_typescript_union_types_wrap = on_every_item +ij_typescript_use_chained_calls_group_indents = false +ij_typescript_use_double_quotes = true +ij_typescript_use_explicit_js_extension = global +ij_typescript_use_path_mapping = always +ij_typescript_use_public_modifier = false +ij_typescript_use_semicolon_after_statement = true +ij_typescript_var_declaration_wrap = normal +ij_typescript_while_brace_force = never +ij_typescript_while_on_new_line = false +ij_typescript_wrap_comments = false + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false + +[{*.cjs,*.js}] +ij_continuation_indent_size = 4 +ij_javascript_align_imports = false +ij_javascript_align_multiline_array_initializer_expression = false +ij_javascript_align_multiline_binary_operation = false +ij_javascript_align_multiline_chained_methods = false +ij_javascript_align_multiline_extends_list = false +ij_javascript_align_multiline_for = true +ij_javascript_align_multiline_parameters = true +ij_javascript_align_multiline_parameters_in_calls = false +ij_javascript_align_multiline_ternary_operation = false +ij_javascript_align_object_properties = 0 +ij_javascript_align_union_types = false +ij_javascript_align_var_statements = 0 +ij_javascript_array_initializer_new_line_after_left_brace = false +ij_javascript_array_initializer_right_brace_on_new_line = false +ij_javascript_array_initializer_wrap = off +ij_javascript_assignment_wrap = off +ij_javascript_binary_operation_sign_on_next_line = false +ij_javascript_binary_operation_wrap = off +ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_javascript_blank_lines_after_imports = 1 +ij_javascript_blank_lines_around_class = 1 +ij_javascript_blank_lines_around_field = 0 +ij_javascript_blank_lines_around_function = 1 +ij_javascript_blank_lines_around_method = 1 +ij_javascript_block_brace_style = end_of_line +ij_javascript_call_parameters_new_line_after_left_paren = false +ij_javascript_call_parameters_right_paren_on_new_line = false +ij_javascript_call_parameters_wrap = off +ij_javascript_catch_on_new_line = false +ij_javascript_chained_call_dot_on_new_line = true +ij_javascript_class_brace_style = end_of_line +ij_javascript_comma_on_new_line = false +ij_javascript_do_while_brace_force = never +ij_javascript_else_on_new_line = false +ij_javascript_enforce_trailing_comma = keep +ij_javascript_extends_keyword_wrap = off +ij_javascript_extends_list_wrap = off +ij_javascript_field_prefix = _ +ij_javascript_file_name_style = relaxed +ij_javascript_finally_on_new_line = false +ij_javascript_for_brace_force = never +ij_javascript_for_statement_new_line_after_left_paren = false +ij_javascript_for_statement_right_paren_on_new_line = false +ij_javascript_for_statement_wrap = off +ij_javascript_force_quote_style = false +ij_javascript_force_semicolon_style = false +ij_javascript_function_expression_brace_style = end_of_line +ij_javascript_if_brace_force = never +ij_javascript_import_merge_members = global +ij_javascript_import_prefer_absolute_path = global +ij_javascript_import_sort_members = true +ij_javascript_import_sort_module_name = false +ij_javascript_import_use_node_resolution = true +ij_javascript_imports_wrap = on_every_item +ij_javascript_indent_case_from_switch = true +ij_javascript_indent_chained_calls = true +ij_javascript_indent_package_children = 0 +ij_javascript_jsx_attribute_value = braces +ij_javascript_keep_blank_lines_in_code = 2 +ij_javascript_keep_first_column_comment = true +ij_javascript_keep_indents_on_empty_lines = false +ij_javascript_keep_line_breaks = true +ij_javascript_keep_simple_blocks_in_one_line = false +ij_javascript_keep_simple_methods_in_one_line = false +ij_javascript_line_comment_add_space = true +ij_javascript_line_comment_at_first_column = false +ij_javascript_method_brace_style = end_of_line +ij_javascript_method_call_chain_wrap = off +ij_javascript_method_parameters_new_line_after_left_paren = false +ij_javascript_method_parameters_right_paren_on_new_line = false +ij_javascript_method_parameters_wrap = off +ij_javascript_object_literal_wrap = on_every_item +ij_javascript_parentheses_expression_new_line_after_left_paren = false +ij_javascript_parentheses_expression_right_paren_on_new_line = false +ij_javascript_place_assignment_sign_on_next_line = false +ij_javascript_prefer_as_type_cast = false +ij_javascript_prefer_explicit_types_function_expression_returns = false +ij_javascript_prefer_explicit_types_function_returns = false +ij_javascript_prefer_explicit_types_vars_fields = false +ij_javascript_prefer_parameters_wrap = false +ij_javascript_reformat_c_style_comments = false +ij_javascript_space_after_colon = true +ij_javascript_space_after_comma = true +ij_javascript_space_after_dots_in_rest_parameter = false +ij_javascript_space_after_generator_mult = true +ij_javascript_space_after_property_colon = true +ij_javascript_space_after_quest = true +ij_javascript_space_after_type_colon = true +ij_javascript_space_after_unary_not = false +ij_javascript_space_before_async_arrow_lparen = true +ij_javascript_space_before_catch_keyword = true +ij_javascript_space_before_catch_left_brace = true +ij_javascript_space_before_catch_parentheses = true +ij_javascript_space_before_class_lbrace = true +ij_javascript_space_before_class_left_brace = true +ij_javascript_space_before_colon = true +ij_javascript_space_before_comma = false +ij_javascript_space_before_do_left_brace = true +ij_javascript_space_before_else_keyword = true +ij_javascript_space_before_else_left_brace = true +ij_javascript_space_before_finally_keyword = true +ij_javascript_space_before_finally_left_brace = true +ij_javascript_space_before_for_left_brace = true +ij_javascript_space_before_for_parentheses = true +ij_javascript_space_before_for_semicolon = false +ij_javascript_space_before_function_left_parenth = true +ij_javascript_space_before_generator_mult = false +ij_javascript_space_before_if_left_brace = true +ij_javascript_space_before_if_parentheses = true +ij_javascript_space_before_method_call_parentheses = false +ij_javascript_space_before_method_left_brace = true +ij_javascript_space_before_method_parentheses = false +ij_javascript_space_before_property_colon = false +ij_javascript_space_before_quest = true +ij_javascript_space_before_switch_left_brace = true +ij_javascript_space_before_switch_parentheses = true +ij_javascript_space_before_try_left_brace = true +ij_javascript_space_before_type_colon = false +ij_javascript_space_before_unary_not = false +ij_javascript_space_before_while_keyword = true +ij_javascript_space_before_while_left_brace = true +ij_javascript_space_before_while_parentheses = true +ij_javascript_spaces_around_additive_operators = true +ij_javascript_spaces_around_arrow_function_operator = true +ij_javascript_spaces_around_assignment_operators = true +ij_javascript_spaces_around_bitwise_operators = true +ij_javascript_spaces_around_equality_operators = true +ij_javascript_spaces_around_logical_operators = true +ij_javascript_spaces_around_multiplicative_operators = true +ij_javascript_spaces_around_relational_operators = true +ij_javascript_spaces_around_shift_operators = true +ij_javascript_spaces_around_unary_operator = false +ij_javascript_spaces_within_array_initializer_brackets = false +ij_javascript_spaces_within_brackets = false +ij_javascript_spaces_within_catch_parentheses = false +ij_javascript_spaces_within_for_parentheses = false +ij_javascript_spaces_within_if_parentheses = false +ij_javascript_spaces_within_imports = false +ij_javascript_spaces_within_interpolation_expressions = false +ij_javascript_spaces_within_method_call_parentheses = false +ij_javascript_spaces_within_method_parentheses = false +ij_javascript_spaces_within_object_literal_braces = false +ij_javascript_spaces_within_object_type_braces = true +ij_javascript_spaces_within_parentheses = false +ij_javascript_spaces_within_switch_parentheses = false +ij_javascript_spaces_within_type_assertion = false +ij_javascript_spaces_within_union_types = true +ij_javascript_spaces_within_while_parentheses = false +ij_javascript_special_else_if_treatment = true +ij_javascript_ternary_operation_signs_on_next_line = false +ij_javascript_ternary_operation_wrap = off +ij_javascript_union_types_wrap = on_every_item +ij_javascript_use_chained_calls_group_indents = false +ij_javascript_use_double_quotes = true +ij_javascript_use_explicit_js_extension = global +ij_javascript_use_path_mapping = always +ij_javascript_use_public_modifier = false +ij_javascript_use_semicolon_after_statement = true +ij_javascript_var_declaration_wrap = normal +ij_javascript_while_brace_force = never +ij_javascript_while_on_new_line = false +ij_javascript_wrap_comments = false + +[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}] +ij_continuation_indent_size = 4 +ij_php_align_assignments = false +ij_php_align_class_constants = false +ij_php_align_group_field_declarations = false +ij_php_align_inline_comments = false +ij_php_align_key_value_pairs = false +ij_php_align_multiline_array_initializer_expression = false +ij_php_align_multiline_binary_operation = false +ij_php_align_multiline_chained_methods = false +ij_php_align_multiline_extends_list = false +ij_php_align_multiline_for = true +ij_php_align_multiline_parameters = true +ij_php_align_multiline_parameters_in_calls = false +ij_php_align_multiline_ternary_operation = false +ij_php_align_phpdoc_comments = false +ij_php_align_phpdoc_param_names = false +ij_php_anonymous_brace_style = end_of_line +ij_php_api_weight = 28 +ij_php_array_initializer_new_line_after_left_brace = false +ij_php_array_initializer_right_brace_on_new_line = false +ij_php_array_initializer_wrap = off +ij_php_assignment_wrap = off +ij_php_author_weight = 28 +ij_php_binary_operation_sign_on_next_line = false +ij_php_binary_operation_wrap = off +ij_php_blank_lines_after_class_header = 0 +ij_php_blank_lines_after_function = 1 +ij_php_blank_lines_after_imports = 1 +ij_php_blank_lines_after_opening_tag = 0 +ij_php_blank_lines_after_package = 0 +ij_php_blank_lines_around_class = 1 +ij_php_blank_lines_around_constants = 0 +ij_php_blank_lines_around_field = 0 +ij_php_blank_lines_around_method = 1 +ij_php_blank_lines_before_class_end = 0 +ij_php_blank_lines_before_imports = 1 +ij_php_blank_lines_before_method_body = 0 +ij_php_blank_lines_before_package = 1 +ij_php_blank_lines_before_return_statement = 0 +ij_php_blank_lines_between_imports = 0 +ij_php_block_brace_style = end_of_line +ij_php_call_parameters_new_line_after_left_paren = false +ij_php_call_parameters_right_paren_on_new_line = false +ij_php_call_parameters_wrap = off +ij_php_catch_on_new_line = false +ij_php_category_weight = 28 +ij_php_class_brace_style = next_line +ij_php_comma_after_last_array_element = false +ij_php_concat_spaces = true +ij_php_copyright_weight = 28 +ij_php_deprecated_weight = 28 +ij_php_do_while_brace_force = never +ij_php_else_if_style = as_is +ij_php_else_on_new_line = false +ij_php_example_weight = 28 +ij_php_extends_keyword_wrap = off +ij_php_extends_list_wrap = off +ij_php_fields_default_visibility = private +ij_php_filesource_weight = 28 +ij_php_finally_on_new_line = false +ij_php_for_brace_force = never +ij_php_for_statement_new_line_after_left_paren = false +ij_php_for_statement_right_paren_on_new_line = false +ij_php_for_statement_wrap = off +ij_php_force_short_declaration_array_style = false +ij_php_global_weight = 28 +ij_php_group_use_wrap = on_every_item +ij_php_if_brace_force = never +ij_php_if_lparen_on_next_line = false +ij_php_if_rparen_on_next_line = false +ij_php_ignore_weight = 28 +ij_php_import_sorting = alphabetic +ij_php_indent_break_from_case = true +ij_php_indent_case_from_switch = true +ij_php_indent_code_in_php_tags = false +ij_php_internal_weight = 28 +ij_php_keep_blank_lines_after_lbrace = 2 +ij_php_keep_blank_lines_before_right_brace = 2 +ij_php_keep_blank_lines_in_code = 2 +ij_php_keep_blank_lines_in_declarations = 2 +ij_php_keep_control_statement_in_one_line = true +ij_php_keep_first_column_comment = true +ij_php_keep_indents_on_empty_lines = false +ij_php_keep_line_breaks = true +ij_php_keep_rparen_and_lbrace_on_one_line = false +ij_php_keep_simple_methods_in_one_line = false +ij_php_lambda_brace_style = end_of_line +ij_php_license_weight = 28 +ij_php_line_comment_add_space = false +ij_php_line_comment_at_first_column = true +ij_php_link_weight = 28 +ij_php_lower_case_boolean_const = false +ij_php_lower_case_keywords = true +ij_php_lower_case_null_const = false +ij_php_method_brace_style = next_line +ij_php_method_call_chain_wrap = off +ij_php_method_parameters_new_line_after_left_paren = false +ij_php_method_parameters_right_paren_on_new_line = false +ij_php_method_parameters_wrap = off +ij_php_method_weight = 28 +ij_php_modifier_list_wrap = false +ij_php_multiline_chained_calls_semicolon_on_new_line = false +ij_php_namespace_brace_style = 1 +ij_php_new_line_after_php_opening_tag = false +ij_php_null_type_position = in_the_end +ij_php_package_weight = 28 +ij_php_param_weight = 0 +ij_php_parentheses_expression_new_line_after_left_paren = false +ij_php_parentheses_expression_right_paren_on_new_line = false +ij_php_phpdoc_blank_line_before_tags = false +ij_php_phpdoc_blank_lines_around_parameters = false +ij_php_phpdoc_keep_blank_lines = true +ij_php_phpdoc_param_spaces_between_name_and_description = 1 +ij_php_phpdoc_param_spaces_between_tag_and_type = 1 +ij_php_phpdoc_param_spaces_between_type_and_name = 1 +ij_php_phpdoc_use_fqcn = false +ij_php_phpdoc_wrap_long_lines = false +ij_php_place_assignment_sign_on_next_line = false +ij_php_place_parens_for_constructor = 0 +ij_php_property_read_weight = 28 +ij_php_property_weight = 28 +ij_php_property_write_weight = 28 +ij_php_return_type_on_new_line = false +ij_php_return_weight = 1 +ij_php_see_weight = 28 +ij_php_since_weight = 28 +ij_php_sort_phpdoc_elements = true +ij_php_space_after_colon = true +ij_php_space_after_colon_in_return_type = true +ij_php_space_after_comma = true +ij_php_space_after_for_semicolon = true +ij_php_space_after_quest = true +ij_php_space_after_type_cast = false +ij_php_space_after_unary_not = false +ij_php_space_before_array_initializer_left_brace = false +ij_php_space_before_catch_keyword = true +ij_php_space_before_catch_left_brace = true +ij_php_space_before_catch_parentheses = true +ij_php_space_before_class_left_brace = true +ij_php_space_before_closure_left_parenthesis = true +ij_php_space_before_colon = true +ij_php_space_before_colon_in_return_type = false +ij_php_space_before_comma = false +ij_php_space_before_do_left_brace = true +ij_php_space_before_else_keyword = true +ij_php_space_before_else_left_brace = true +ij_php_space_before_finally_keyword = true +ij_php_space_before_finally_left_brace = true +ij_php_space_before_for_left_brace = true +ij_php_space_before_for_parentheses = true +ij_php_space_before_for_semicolon = false +ij_php_space_before_if_left_brace = true +ij_php_space_before_if_parentheses = true +ij_php_space_before_method_call_parentheses = false +ij_php_space_before_method_left_brace = true +ij_php_space_before_method_parentheses = false +ij_php_space_before_quest = true +ij_php_space_before_short_closure_left_parenthesis = false +ij_php_space_before_switch_left_brace = true +ij_php_space_before_switch_parentheses = true +ij_php_space_before_try_left_brace = true +ij_php_space_before_unary_not = false +ij_php_space_before_while_keyword = true +ij_php_space_before_while_left_brace = true +ij_php_space_before_while_parentheses = true +ij_php_space_between_ternary_quest_and_colon = false +ij_php_spaces_around_additive_operators = true +ij_php_spaces_around_arrow = false +ij_php_spaces_around_assignment_in_declare = false +ij_php_spaces_around_assignment_operators = true +ij_php_spaces_around_bitwise_operators = true +ij_php_spaces_around_equality_operators = true +ij_php_spaces_around_logical_operators = true +ij_php_spaces_around_multiplicative_operators = true +ij_php_spaces_around_null_coalesce_operator = true +ij_php_spaces_around_relational_operators = true +ij_php_spaces_around_shift_operators = true +ij_php_spaces_around_unary_operator = false +ij_php_spaces_around_var_within_brackets = false +ij_php_spaces_within_array_initializer_braces = false +ij_php_spaces_within_brackets = false +ij_php_spaces_within_catch_parentheses = false +ij_php_spaces_within_for_parentheses = false +ij_php_spaces_within_if_parentheses = false +ij_php_spaces_within_method_call_parentheses = false +ij_php_spaces_within_method_parentheses = false +ij_php_spaces_within_parentheses = false +ij_php_spaces_within_short_echo_tags = true +ij_php_spaces_within_switch_parentheses = false +ij_php_spaces_within_while_parentheses = false +ij_php_special_else_if_treatment = false +ij_php_subpackage_weight = 28 +ij_php_ternary_operation_signs_on_next_line = false +ij_php_ternary_operation_wrap = off +ij_php_throws_weight = 2 +ij_php_todo_weight = 28 +ij_php_unknown_tag_weight = 28 +ij_php_upper_case_boolean_const = false +ij_php_upper_case_null_const = false +ij_php_uses_weight = 28 +ij_php_var_weight = 28 +ij_php_variable_naming_style = mixed +ij_php_version_weight = 28 +ij_php_while_brace_force = never +ij_php_while_on_new_line = false + +[{*.dockerapp,*.yaml,*.yml}] +indent_size = 2 +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true + +[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,composer.lock,jest.config}] +indent_size = 2 +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = true +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.htm,*.html,*.sht,*.shtm,*.shtml}] +ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 +ij_html_align_attributes = true +ij_html_align_text = false +ij_html_attribute_wrap = normal +ij_html_block_comment_at_first_column = true +ij_html_do_not_align_children_of_min_lines = 0 +ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p +ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot +ij_html_enforce_quotes = false +ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var +ij_html_keep_blank_lines = 2 +ij_html_keep_indents_on_empty_lines = false +ij_html_keep_line_breaks = true +ij_html_keep_line_breaks_in_text = true +ij_html_keep_whitespaces = false +ij_html_keep_whitespaces_inside = span,pre,textarea +ij_html_line_comment_at_first_column = true +ij_html_new_line_after_last_attribute = never +ij_html_new_line_before_first_attribute = never +ij_html_quote_style = double +ij_html_remove_new_line_before_tags = br +ij_html_space_after_tag_name = false +ij_html_space_around_equality_in_attribute = false +ij_html_space_inside_empty_tag = false +ij_html_text_wrap = normal diff --git a/Makefile b/Makefile index cb88e669b0..f376fd3319 100644 --- a/Makefile +++ b/Makefile @@ -141,6 +141,8 @@ endif ## knora stack .PHONY: stack-up stack-up: build-all-images env-file ## starts the knora-stack: graphdb, sipi, redis, api, salsah1. + docker-compose -f docker/knora.docker-compose.yml up -d db + $(CURRENT_DIR)/webapi/scripts/wait-for-db.sh docker-compose -f docker/knora.docker-compose.yml up -d .PHONY: stack-up-ci @@ -165,6 +167,10 @@ stack-logs: ## prints out and follows the logs of the running knora-stack. stack-logs-db: ## prints out and follows the logs of the 'db' container running in knora-stack. docker-compose -f docker/knora.docker-compose.yml logs -f db +.PHONY: stack-logs-db-no-follow +stack-logs-db-no-follow: ## prints out the logs of the 'db' container running in knora-stack. + docker-compose -f docker/knora.docker-compose.yml logs db + .PHONY: stack-logs-sipi stack-logs-sipi: ## prints out and follows the logs of the 'sipi' container running in knora-stack. docker-compose -f docker/knora.docker-compose.yml logs -f sipi @@ -191,7 +197,11 @@ stack-logs-salsah1: ## prints out and follows the logs of the 'salsah1' containe .PHONY: stack-health stack-health: - curl 0.0.0.0:3333/health + curl -f 0.0.0.0:3333/health + +.PHONY: stack-status +stack-status: + docker-compose -f docker/knora.docker-compose.yml ps .PHONY: stack-down stack-down: ## stops the knora-stack. @@ -212,8 +222,25 @@ stack-without-api-and-sipi: stack-up ## starts the knora-stack without knora-api docker-compose -f docker/knora.docker-compose.yml stop api docker-compose -f docker/knora.docker-compose.yml stop sipi +.PHONY: test-only +test-only: stack-without-api init-db-test-unit ## runs only the supplied tests, e.g., make test-only TARGET="*.CORSSupportE2ESpec". + @echo $@ # print target name + docker run --rm \ + -v /tmp:/tmp:delegated \ + -v $(CURRENT_DIR):/src:delegated \ + -v $(HOME)/.ivy2:/root/.ivy2:delegated \ + --name=api \ + -e KNORA_WEBAPI_TRIPLESTORE_HOST=db \ + -e KNORA_WEBAPI_SIPI_EXTERNAL_HOST=sipi \ + -e KNORA_WEBAPI_SIPI_INTERNAL_HOST=sipi \ + -e KNORA_WEBAPI_CACHE_SERVICE_REDIS_HOST=redis \ + -e SBT_OPTS="-Xms2048M -Xmx2048M -Xss6M" \ + --network=docker_knora-net \ + daschswiss/scala-sbt sbt "webapi/testOnly $(TARGET)" + .PHONY: test-unit test-unit: stack-without-api init-db-test-unit ## runs the unit tests (equivalent to 'sbt webapi/testOnly -- -l org.knora.webapi.testing.tags.E2ETest'). + @echo $@ # print target name docker run --rm \ -v /tmp:/tmp \ -v $(CURRENT_DIR):/src \ @@ -228,10 +255,8 @@ test-unit: stack-without-api init-db-test-unit ## runs the unit tests (equivalen daschswiss/scala-sbt sbt 'webapi/testOnly -- -l org.knora.webapi.testing.tags.E2ETest' .PHONY: test-unit-ci -test-unit-ci: stack-without-api ## runs the unit tests (equivalent to 'sbt webapi/testOnly -- -l org.knora.webapi.testing.tags.E2ETest') with code-coverage reporting. +test-unit-ci: stack-without-api init-db-test-unit ## runs the unit tests (equivalent to 'sbt webapi/testOnly -- -l org.knora.webapi.testing.tags.E2ETest') with code-coverage reporting. @echo $@ # print target name - @sleep 5 - @$(MAKE) -f $(THIS_FILE) init-db-test-unit docker run --rm \ -v /tmp:/tmp \ -v $(CURRENT_DIR):/src \ @@ -247,6 +272,7 @@ test-unit-ci: stack-without-api ## runs the unit tests (equivalent to 'sbt webap .PHONY: test-e2e test-e2e: stack-without-api init-db-test-unit ## runs the e2e tests (equivalent to 'sbt webapi/testOnly -- -n org.knora.webapi.testing.tags.E2ETest'). + @echo $@ # print target name docker run --rm \ -v /tmp:/tmp \ -v $(CURRENT_DIR):/src \ @@ -261,10 +287,8 @@ test-e2e: stack-without-api init-db-test-unit ## runs the e2e tests (equivalent daschswiss/scala-sbt sbt 'webapi/testOnly -- -n org.knora.webapi.testing.tags.E2ETest' .PHONY: test-e2e-ci -test-e2e-ci: stack-without-api ## runs the e2e tests (equivalent to 'sbt webapi/testOnly -- -n org.knora.webapi.testing.tags.E2ETest') with code-coverage reporting. +test-e2e-ci: stack-without-api init-db-test-unit ## runs the e2e tests (equivalent to 'sbt webapi/testOnly -- -n org.knora.webapi.testing.tags.E2ETest') with code-coverage reporting. @echo $@ # print target name - @sleep 5 - @$(MAKE) -f $(THIS_FILE) init-db-test-unit docker run --rm \ -v /tmp:/tmp \ -v $(CURRENT_DIR):/src \ @@ -280,6 +304,7 @@ test-e2e-ci: stack-without-api ## runs the e2e tests (equivalent to 'sbt webapi/ .PHONY: test-it test-it: stack-without-api init-db-test-unit ## runs the integration tests (equivalent to 'sbt webapi/it'). + @echo $@ docker run --rm \ -v /tmp:/tmp \ -v $(CURRENT_DIR):/src \ @@ -294,10 +319,8 @@ test-it: stack-without-api init-db-test-unit ## runs the integration tests (equi daschswiss/scala-sbt sbt 'webapi/it:test' .PHONY: test-it-ci -test-it-ci: stack-without-api ## runs the integration tests (equivalent to 'sbt webapi/it:test') with code-coverage reporting. +test-it-ci: stack-without-api init-db-test-unit ## runs the integration tests (equivalent to 'sbt webapi/it:test') with code-coverage reporting. @echo $@ # print target name - @sleep 5 - @$(MAKE) -f $(THIS_FILE) init-db-test-unit docker run --rm \ -v /tmp:/tmp \ -v $(CURRENT_DIR):/src \ @@ -312,7 +335,8 @@ test-it-ci: stack-without-api ## runs the integration tests (equivalent to 'sbt daschswiss/scala-sbt sbt coverage webapi/it:test webapi/coverageReport .PHONY: test-all -test-all: stack-without-api ## runs the all tests (equivalent to 'sbt webapi/test'). +test-all: stack-without-api init-db-test-unit ## runs the all tests (equivalent to 'sbt webapi/test'). + @echo $@ # docker build -t webapi-test -f docker/knora-api-test.dockerfile webapi/build/test/target/universal docker run --rm \ -v /tmp:/tmp \ diff --git a/docker/knora-api-it.dockerfile b/docker/knora-api-it.dockerfile index 04e7c7d211..e6b3e6a262 100644 --- a/docker/knora-api-it.dockerfile +++ b/docker/knora-api-it.dockerfile @@ -11,6 +11,6 @@ WORKDIR /webapi-it EXPOSE 3333 -ENTRYPOINT ["bin/webapi-it] +ENTRYPOINT ["bin/webapi-it"] LABEL MAINTAINER="400790+subotic@users.noreply.github.com" diff --git a/docker/knora-api.dockerfile b/docker/knora-api.dockerfile index 729bb7a07d..c61e52f05c 100644 --- a/docker/knora-api.dockerfile +++ b/docker/knora-api.dockerfile @@ -18,6 +18,9 @@ COPY stage /webapi WORKDIR /webapi +# check every minute +HEALTHCHECK --interval=1m --timeout=1s CMD curl -f http://localhost:3333/health || exit 1 + EXPOSE 3333 #EXPOSE 10001 diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9cee3c8f55..a6261a9356 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -44,9 +44,9 @@ object Dependencies { lazy val knoraSalsah1Image = SettingKey[String]("the Knora Salsah1 Image") val Versions = Seq( - scalaVersion := "2.12.8", - akkaVersion := "2.6.4", - akkaHttpVersion := "10.1.11", + scalaVersion := "2.12.11", + akkaVersion := "2.6.5", + akkaHttpVersion := "10.1.12", jenaVersion := "3.4.0", metricsVersion := "4.0.1", sipiImage := "dhlabbasel/sipi:v2.0.1", @@ -61,7 +61,6 @@ object Dependencies { object Compile { // akka val akkaActor = Def.setting {"com.typesafe.akka" %% "akka-actor" % akkaVersion.value} - //val akkaAgent = Def.setting {"com.typesafe.akka" %% "akka-agent" % akkaVersion.value} val akkaStream = Def.setting {"com.typesafe.akka" %% "akka-stream" % akkaVersion.value} val akkaSlf4j = Def.setting {"com.typesafe.akka" %% "akka-slf4j" % akkaVersion.value} @@ -76,7 +75,7 @@ object Dependencies { // testing //CORS support - val akkaHttpCors = "ch.megard" %% "akka-http-cors" % "0.3.4" + val akkaHttpCors = "ch.megard" %% "akka-http-cors" % "1.0.0" // jena val jenaLibs = Def.setting {"org.apache.jena" % "apache-jena-libs" % jenaVersion.value exclude("org.slf4j", "slf4j-log4j12") exclude("commons-codec", "commons-codec")} @@ -151,7 +150,7 @@ object Dependencies { val akkaTestkit = Def.setting {"com.typesafe.akka" %% "akka-testkit" % akkaVersion.value % "test"} val akkaStreamTestkit = Def.setting {"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion.value % "test"} val akkaHttpTestkit = Def.setting {"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion.value % "test"} - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.4" % "test" + val scalaTest = "org.scalatest" %% "scalatest" % "3.1.2" % "test" // browser tests val selenium = "org.seleniumhq.selenium" % "selenium-java" % "3.4.0" % "test" @@ -161,7 +160,7 @@ object Dependencies { val akkaTestkit = Def.setting {"com.typesafe.akka" %% "akka-testkit" % akkaVersion.value % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it"} val akkaStreamTestkit = Def.setting {"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion.value % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it"} val akkaHttpTestkit = Def.setting {"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion.value % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it"} - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.4" % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it" + val scalaTest = "org.scalatest" %% "scalatest" % "3.1.2" % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it" val gatlingHighcharts = "io.gatling.highcharts" % "gatling-charts-highcharts"% "2.3.1" % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it" val gatlingTestFramework = "io.gatling" % "gatling-test-framework" % "2.3.1" % "test, it, gdbse, gdbse-it, gdbfree, gdbfree-it, tdb, fuseki, fuseki-it" @@ -171,7 +170,7 @@ object Dependencies { val akkaTestkit = Def.setting {"com.typesafe.akka" %% "akka-testkit" % akkaVersion.value} val akkaStreamTestkit = Def.setting {"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion.value} val akkaHttpTestkit = Def.setting {"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion.value} - val scalaTest = "org.scalatest" %% "scalatest" % "3.0.4" + val scalaTest = "org.scalatest" %% "scalatest" % "3.1.2" val gatlingHighcharts = "io.gatling.highcharts" % "gatling-charts-highcharts"% "2.3.1" val gatlingTestFramework = "io.gatling" % "gatling-test-framework" % "2.3.1" } @@ -182,7 +181,6 @@ object Dependencies { val salsahLibraryDependencies = l ++= Seq[sbt.ModuleID]( akkaActor.value, - //akkaAgent.value, akkaStream.value, akkaSlf4j.value, akkaHttp.value, @@ -197,7 +195,6 @@ object Dependencies { val webapiLibraryDependencies = l ++= Seq[sbt.ModuleID]( akkaActor.value, - //akkaAgent.value, akkaHttp.value, akkaHttpCirce, akkaHttpCors, diff --git a/salsah1/src/test/scala/org.knora.salsah/browser/SalsahSpec.scala b/salsah1/src/test/scala/org.knora.salsah/browser/SalsahSpec.scala index ef8830da75..bb382d854c 100644 --- a/salsah1/src/test/scala/org.knora.salsah/browser/SalsahSpec.scala +++ b/salsah1/src/test/scala/org.knora.salsah/browser/SalsahSpec.scala @@ -27,7 +27,8 @@ import akka.stream.Materializer import akka.util.Timeout import com.typesafe.config.ConfigFactory import org.knora.salsah.SettingsImpl -import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import scala.concurrent.duration._ import scala.concurrent.{Await, ExecutionContextExecutor} @@ -35,7 +36,7 @@ import scala.concurrent.{Await, ExecutionContextExecutor} /** * An abstract base class for Selenium tests of the SALSAH user interface. */ -abstract class SalsahSpec extends WordSpecLike with Matchers with RequestBuilding { +abstract class SalsahSpec extends AnyWordSpecLike with Matchers with RequestBuilding { implicit private val system = ActorSystem() diff --git a/webapi/scripts/wait-for-db.sh b/webapi/scripts/wait-for-db.sh new file mode 100755 index 0000000000..effb7e7b24 --- /dev/null +++ b/webapi/scripts/wait-for-db.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +#set -x + +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + + -h|--host) + HOST="$2" + shift # past argument + shift # past value + ;; + + -t|--timeout) + TIMEOUT="$2" + shift # past argument + shift # past value + ;; + + -n|--name) + NAME="$3" + shift # past argument + shift # past value + ;; + + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +if [[ -z "${HOST}" ]]; then + HOST="localhost:7200" +fi + +if [[ -z "${TIMEOUT}" ]]; then + TIMEOUT=360 +fi + +if [[ -z "${NAME}" ]]; then + NAME="knora-test-unit" +fi + +poll-db() { + # STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://${HOST}/repositories/${NAME}/health?) + STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://${HOST}/rest/repositories) + + if [ "${STATUS}" -eq 200 ]; then + echo "==> DB started" + return 0 + else + return 1 + fi +} + +attempt_counter=0 + +until poll-db; do + if [ ${attempt_counter} -eq ${TIMEOUT} ]; then + echo "Timed out waiting for DB to start" + exit 1 + fi + + attempt_counter=$((attempt_counter+1)) + sleep 1 +done \ No newline at end of file diff --git a/webapi/scripts/wait-for-knora.sh b/webapi/scripts/wait-for-knora.sh index faabb4d326..406dc189f0 100755 --- a/webapi/scripts/wait-for-knora.sh +++ b/webapi/scripts/wait-for-knora.sh @@ -8,20 +8,23 @@ do key="$1" case $key in + -h|--host) - HOST="$2" - shift # past argument - shift # past value - ;; + HOST="$2" + shift # past argument + shift # past value + ;; + -t|--timeout) - TIMEOUT="$2" - shift # past argument - shift # past value - ;; - *) # unknown option - POSITIONAL+=("$1") # save it in an array for later - shift # past argument - ;; + TIMEOUT="$2" + shift # past argument + shift # past value + ;; + + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; esac done set -- "${POSITIONAL[@]}" # restore positional parameters diff --git a/webapi/src/it/scala/org/knora/webapi/ITKnoraFakeSpec.scala b/webapi/src/it/scala/org/knora/webapi/ITKnoraFakeSpec.scala index f82a2c5b55..026d6b2e4c 100644 --- a/webapi/src/it/scala/org/knora/webapi/ITKnoraFakeSpec.scala +++ b/webapi/src/it/scala/org/knora/webapi/ITKnoraFakeSpec.scala @@ -19,24 +19,21 @@ package org.knora.webapi -import java.io.File -import java.nio.file.{Files, Paths} - -import akka.actor.{ActorRef, ActorSystem, Props} -import akka.event.LoggingAdapter +import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.client.RequestBuilding import akka.http.scaladsl.model.{HttpRequest, HttpResponse, StatusCodes} import akka.http.scaladsl.unmarshalling.Unmarshal import akka.stream.Materializer import com.typesafe.config.{Config, ConfigFactory} -import org.knora.webapi.app.{APPLICATION_MANAGER_ACTOR_NAME, ApplicationActor, LiveManagers} import org.knora.webapi.util.StringFormatter -import org.scalatest.{BeforeAndAfterAll, Matchers, Suite, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike +import org.scalatest.{BeforeAndAfterAll, Suite} import spray.json.{JsObject, _} import scala.concurrent.duration.{Duration, _} -import scala.concurrent.{Await, ExecutionContext, Future} +import scala.concurrent.{Await, ExecutionContext} import scala.languageFeature.postfixOps @@ -48,7 +45,7 @@ object ITKnoraFakeSpec { * This class can be used in End-to-End testing. It starts a Fake Knora server and * provides access to settings and logging. */ -class ITKnoraFakeSpec(_system: ActorSystem) extends Core with KnoraFakeCore with Suite with WordSpecLike with Matchers with BeforeAndAfterAll with RequestBuilding { +class ITKnoraFakeSpec(_system: ActorSystem) extends Core with KnoraFakeCore with Suite with AnyWordSpecLike with Matchers with BeforeAndAfterAll with RequestBuilding { /* constructors */ def this(name: String, config: Config) = this(ActorSystem(name, config.withFallback(ITKnoraFakeSpec.defaultConfig))) @@ -58,7 +55,7 @@ class ITKnoraFakeSpec(_system: ActorSystem) extends Core with KnoraFakeCore with /* needed by the core trait */ implicit lazy val system: ActorSystem = _system - implicit lazy val settings: SettingsImpl = Settings(system) + implicit lazy val settings: KnoraSettingsImpl = KnoraSettings(system) implicit val materializer: Materializer = Materializer.matFromSystem(system) implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) diff --git a/webapi/src/it/scala/org/knora/webapi/ITKnoraLiveSpec.scala b/webapi/src/it/scala/org/knora/webapi/ITKnoraLiveSpec.scala index 8920bc8219..7de34f7e0f 100644 --- a/webapi/src/it/scala/org/knora/webapi/ITKnoraLiveSpec.scala +++ b/webapi/src/it/scala/org/knora/webapi/ITKnoraLiveSpec.scala @@ -31,7 +31,9 @@ import org.knora.webapi.messages.app.appmessages.{AppStart, AppStop, SetAllowRel import org.knora.webapi.messages.store.triplestoremessages.{RdfDataObject, TriplestoreJsonProtocol} import org.knora.webapi.util.jsonld.{JsonLDDocument, JsonLDUtil} import org.knora.webapi.util.{StartupUtils, StringFormatter} -import org.scalatest.{BeforeAndAfterAll, Matchers, Suite, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike +import org.scalatest.{BeforeAndAfterAll, Suite} import spray.json.{JsObject, _} import scala.concurrent.duration.{Duration, _} @@ -46,7 +48,7 @@ object ITKnoraLiveSpec { * This class can be used in End-to-End testing. It starts the Knora server and * provides access to settings and logging. */ -class ITKnoraLiveSpec(_system: ActorSystem) extends Core with StartupUtils with Suite with WordSpecLike with Matchers with BeforeAndAfterAll with RequestBuilding with TriplestoreJsonProtocol with LazyLogging { +class ITKnoraLiveSpec(_system: ActorSystem) extends Core with StartupUtils with Suite with AnyWordSpecLike with Matchers with BeforeAndAfterAll with RequestBuilding with TriplestoreJsonProtocol with LazyLogging { /* constructors */ def this(name: String, config: Config) = this(ActorSystem(name, config.withFallback(ITKnoraLiveSpec.defaultConfig))) @@ -56,7 +58,7 @@ class ITKnoraLiveSpec(_system: ActorSystem) extends Core with StartupUtils with /* needed by the core trait (represents the KnoraTestCore trait)*/ implicit lazy val system: ActorSystem = _system - implicit lazy val settings: SettingsImpl = Settings(system) + implicit lazy val settings: KnoraSettingsImpl = KnoraSettings(system) implicit val materializer: Materializer = Materializer.matFromSystem(system) implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) diff --git a/webapi/src/main/resources/application.conf b/webapi/src/main/resources/application.conf index 420cb85aed..c9c37663d4 100644 --- a/webapi/src/main/resources/application.conf +++ b/webapi/src/main/resources/application.conf @@ -213,6 +213,55 @@ knora-blocking-dispatcher { throughput = 1 } +akka-http-cors { + + # If enabled, allow generic requests (that are outside the scope of the specification) + # to pass through the directive. Else, strict CORS filtering is applied and any + # invalid request will be rejected. + allow-generic-http-requests = yes + + # Indicates whether the resource supports user credentials. If enabled, the header + # `Access-Control-Allow-Credentials` is set in the response, indicating that the + # actual request can include user credentials. Examples of user credentials are: + # cookies, HTTP authentication or client-side certificates. + allow-credentials = yes + + # List of origins that the CORS filter must allow. Can also be set to `*` to allow + # access to the resource from any origin. Controls the content of the + # `Access-Control-Allow-Origin` response header: if parameter is `*` and credentials + # are not allowed, a `*` is set in `Access-Control-Allow-Origin`. Otherwise, the + # origins given in the `Origin` request header are echoed. + # + # Hostname starting with `*.` will match any sub-domain. + # The scheme and the port are always strictly matched. + # + # The actual or preflight request is rejected if any of the origins from the request + # is not allowed. + allowed-origins = "*" + + # List of request headers that can be used when making an actual request. Controls + # the content of the `Access-Control-Allow-Headers` header in a preflight response: + # if parameter is `*`, the headers from `Access-Control-Request-Headers` are echoed. + # Otherwise the parameter list is returned as part of the header. + allowed-headers = "*" + + # List of methods that can be used when making an actual request. The list is + # returned as part of the `Access-Control-Allow-Methods` preflight response header. + # + # The preflight request will be rejected if the `Access-Control-Request-Method` + # header's method is not part of the list. + allowed-methods = ["GET", "PUT", "POST", "DELETE", "HEAD", "OPTIONS"] + + # List of headers (other than simple response headers) that browsers are allowed to access. + # If not empty, this list is returned as part of the `Access-Control-Expose-Headers` + # header in the actual response. + exposed-headers = ["Server"] + + # When set, the amount of seconds the browser is allowed to cache the results of a preflight request. + # This value is returned as part of the `Access-Control-Max-Age` preflight response header. + # If `null`, the header is not added to the preflight response. + max-age = 1800 seconds +} app { diff --git a/webapi/src/main/scala/org/knora/webapi/KnoraExceptionHandler.scala b/webapi/src/main/scala/org/knora/webapi/KnoraExceptionHandler.scala index 771abd82cb..ae80e75278 100644 --- a/webapi/src/main/scala/org/knora/webapi/KnoraExceptionHandler.scala +++ b/webapi/src/main/scala/org/knora/webapi/KnoraExceptionHandler.scala @@ -17,7 +17,7 @@ object KnoraExceptionHandler extends LazyLogging { // A generic error message that we return to clients when an internal server error occurs. private val GENERIC_INTERNAL_SERVER_ERROR_MESSAGE = "The request could not be completed because of an internal server error." - def apply(settingsImpl: SettingsImpl): ExceptionHandler = ExceptionHandler { + def apply(settingsImpl: KnoraSettingsImpl): ExceptionHandler = ExceptionHandler { /* TODO: Find out which response format should be generated, by looking at what the client is requesting / accepting (issue #292) */ @@ -83,7 +83,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param ex the exception to be converted. * @return an [[HttpResponse]] in JSON format. */ - private def exceptionToJsonHttpResponseV1(ex: Throwable, settings: SettingsImpl): HttpResponse = { + private def exceptionToJsonHttpResponseV1(ex: Throwable, settings: KnoraSettingsImpl): HttpResponse = { // Get the API status code that corresponds to the exception. val apiStatus: ApiStatusCodesV1.Value = ApiStatusCodesV1.fromException(ex) @@ -116,7 +116,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param ex the exception to be converted. * @return an [[HttpResponse]] in JSON format. */ - private def exceptionToJsonHttpResponseV2(ex: Throwable, settings: SettingsImpl): HttpResponse = { + private def exceptionToJsonHttpResponseV2(ex: Throwable, settings: KnoraSettingsImpl): HttpResponse = { // Get the HTTP status code that corresponds to the exception. val httpStatus: StatusCode = ApiStatusCodesV2.fromException(ex) @@ -144,7 +144,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param ex the exception to be converted. * @return an [[HttpResponse]] in JSON format. */ - private def exceptionToJsonHttpResponseADM(ex: Throwable, settings: SettingsImpl): HttpResponse = { + private def exceptionToJsonHttpResponseADM(ex: Throwable, settings: KnoraSettingsImpl): HttpResponse = { // Get the HTTP status code that corresponds to the exception. val httpStatus: StatusCode = ApiStatusCodesV2.fromException(ex) @@ -167,7 +167,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param ex the exception to be converted. * @return an [[HttpResponse]] in HTML format. */ - private def exceptionToHtmlHttpResponseV1(ex: Throwable, settings: SettingsImpl): HttpResponse = { + private def exceptionToHtmlHttpResponseV1(ex: Throwable, settings: KnoraSettingsImpl): HttpResponse = { // Get the API status code that corresponds to the exception. val apiStatus: ApiStatusCodesV1.Value = ApiStatusCodesV1.fromException(ex) @@ -208,7 +208,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param ex the exception to be converted. * @return an [[HttpResponse]] in HTML format. */ - private def exceptionToHtmlHttpResponseV2(ex: Throwable, settings: SettingsImpl): HttpResponse = { + private def exceptionToHtmlHttpResponseV2(ex: Throwable, settings: KnoraSettingsImpl): HttpResponse = { // Get the HTTP status code that corresponds to the exception. val httpStatus: StatusCode = ApiStatusCodesV2.fromException(ex) @@ -241,7 +241,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param ex the exception to be converted. * @return an [[HttpResponse]] in HTML format. */ - private def exceptionToHtmlHttpResponseADM(ex: Throwable, settings: SettingsImpl): HttpResponse = { + private def exceptionToHtmlHttpResponseADM(ex: Throwable, settings: KnoraSettingsImpl): HttpResponse = { // Get the HTTP status code that corresponds to the exception. val httpStatus: StatusCode = ApiStatusCodesV2.fromException(ex) @@ -275,7 +275,7 @@ object KnoraExceptionHandler extends LazyLogging { * @param settings the application settings. * @return an error message suitable for clients. */ - private def makeClientErrorMessage(ex: Throwable, settings: SettingsImpl): String = { + private def makeClientErrorMessage(ex: Throwable, settings: KnoraSettingsImpl): String = { ex match { case rre: RequestRejectedException => rre.toString diff --git a/webapi/src/main/scala/org/knora/webapi/Settings.scala b/webapi/src/main/scala/org/knora/webapi/KnoraSettings.scala similarity index 97% rename from webapi/src/main/scala/org/knora/webapi/Settings.scala rename to webapi/src/main/scala/org/knora/webapi/KnoraSettings.scala index 094f482f3f..9b04aa99d5 100644 --- a/webapi/src/main/scala/org/knora/webapi/Settings.scala +++ b/webapi/src/main/scala/org/knora/webapi/KnoraSettings.scala @@ -33,7 +33,7 @@ import scala.concurrent.duration._ /** * Reads application settings that come from `application.conf`. */ -class SettingsImpl(config: Config) extends Extension { +class KnoraSettingsImpl(config: Config) extends Extension { // print config val printShortConfig: Boolean = config.getBoolean("app.print-short-config") @@ -230,15 +230,15 @@ class SettingsImpl(config: Config) extends Extension { } -object Settings extends ExtensionId[SettingsImpl] with ExtensionIdProvider { +object KnoraSettings extends ExtensionId[KnoraSettingsImpl] with ExtensionIdProvider { - override def lookup(): Settings.type = Settings + override def lookup(): KnoraSettings.type = KnoraSettings override def createExtension(system: ExtendedActorSystem) = - new SettingsImpl(system.settings.config) + new KnoraSettingsImpl(system.settings.config) /** * Java API: retrieve the Settings extension for the given system. */ - override def get(system: ActorSystem): SettingsImpl = super.get(system) + override def get(system: ActorSystem): KnoraSettingsImpl = super.get(system) } \ No newline at end of file diff --git a/webapi/src/main/scala/org/knora/webapi/SettingsConstants.scala b/webapi/src/main/scala/org/knora/webapi/KnoraSettingsConstants.scala similarity index 100% rename from webapi/src/main/scala/org/knora/webapi/SettingsConstants.scala rename to webapi/src/main/scala/org/knora/webapi/KnoraSettingsConstants.scala diff --git a/webapi/src/main/scala/org/knora/webapi/LiveCore.scala b/webapi/src/main/scala/org/knora/webapi/LiveCore.scala index bda483ce65..f97b379e3f 100644 --- a/webapi/src/main/scala/org/knora/webapi/LiveCore.scala +++ b/webapi/src/main/scala/org/knora/webapi/LiveCore.scala @@ -35,7 +35,7 @@ import scala.languageFeature.postfixOps trait Core { implicit val system: ActorSystem - implicit val settings: SettingsImpl + implicit val settings: KnoraSettingsImpl implicit val materializer: Materializer @@ -57,7 +57,7 @@ trait LiveCore extends Core { /** * The application's configuration. */ - implicit lazy val settings: SettingsImpl = Settings(system) + implicit lazy val settings: KnoraSettingsImpl = KnoraSettings(system) /** * Provides the actor materializer (akka-http) diff --git a/webapi/src/main/scala/org/knora/webapi/app/ApplicationActor.scala b/webapi/src/main/scala/org/knora/webapi/app/ApplicationActor.scala index 99a79af15e..42d170c181 100644 --- a/webapi/src/main/scala/org/knora/webapi/app/ApplicationActor.scala +++ b/webapi/src/main/scala/org/knora/webapi/app/ApplicationActor.scala @@ -1,16 +1,17 @@ package org.knora.webapi.app import akka.actor.SupervisorStrategy._ -import akka.actor.{Actor, ActorRef, ActorSystem, OneForOneStrategy, Props, Timers} +import akka.actor.{Actor, ActorRef, ActorSystem, OneForOneStrategy, Props, Stash, Timers} import akka.http.scaladsl.Http import akka.http.scaladsl.server.Directives._ -import akka.http.scaladsl.server.Route +import akka.http.scaladsl.server.{ExceptionHandler, RejectionHandler, Route} import akka.stream.Materializer import akka.util.Timeout +import ch.megard.akka.http.cors.scaladsl.CorsDirectives +import ch.megard.akka.http.cors.scaladsl.settings.CorsSettings import com.typesafe.scalalogging.LazyLogging import kamon.Kamon import org.knora.webapi._ -import org.knora.webapi.http.CORSSupport.CORS import org.knora.webapi.http.ServerVersion.addServerHeader import org.knora.webapi.messages.admin.responder.KnoraRequestADM import org.knora.webapi.messages.app.appmessages._ @@ -48,7 +49,7 @@ trait LiveManagers extends Managers { */ lazy val storeManager: ActorRef = context.actorOf( Props(new StoreManager(self) with LiveActorMaker) - .withDispatcher(KnoraDispatchers.KnoraActorDispatcher), + .withDispatcher(KnoraDispatchers.KnoraActorDispatcher), name = StoreManagerActorName ) @@ -57,7 +58,7 @@ trait LiveManagers extends Managers { */ lazy val responderManager: ActorRef = context.actorOf( Props(new ResponderManager(self) with LiveActorMaker) - .withDispatcher(KnoraDispatchers.KnoraActorDispatcher), + .withDispatcher(KnoraDispatchers.KnoraActorDispatcher), name = RESPONDER_MANAGER_ACTOR_NAME ) // #store-responder @@ -71,7 +72,7 @@ trait LiveManagers extends Managers { * the startup and shutdown sequence. Further, it forwards any messages meant * for responders or the store to the respective actor. */ -class ApplicationActor extends Actor with LazyLogging with AroundDirectives with Timers { +class ApplicationActor extends Actor with Stash with LazyLogging with AroundDirectives with Timers { this: Managers => private val log = akka.event.Logging(context.system, this.getClass) @@ -83,7 +84,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with /** * The application's configuration. */ - implicit val settings: SettingsImpl = Settings(system) + implicit val knoraSettings: KnoraSettingsImpl = KnoraSettings(system) /** * Provides the actor materializer (akka-http) @@ -98,7 +99,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with /** * Timeout definition */ - implicit protected val timeout: Timeout = settings.defaultTimeout + implicit protected val timeout: Timeout = knoraSettings.defaultTimeout /** * A user representing the Knora API server, used for initialisation on startup. @@ -139,14 +140,41 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with private var printConfigState = false private var ignoreRepository = true private var withIIIFService = true - private val withCacheService = settings.cacheServiceEnabled + private val withCacheService = knoraSettings.cacheServiceEnabled - def receive: PartialFunction[Any, Unit] = { + /** + * Startup of the ApplicationActor is a two step process: + * 1. Step: Start the http server and bind to ip and port. This is done with + * the "initializing" behaviour + * - Success: After a successful bind, go to step 2. + * - Failure: If bind fails, then retry up to 5 times before exiting. + * + * 2. Step: + * + */ + def receive: Receive = initializing() + + def initializing(): Receive = { /* Called from main. Initiates application startup. */ - case appStartMsg: AppStart => appStart(appStartMsg.ignoreRepository, appStartMsg.requiresIIIFService) + case appStartMsg: AppStart => + println("==> AppStart") + appStart(appStartMsg.ignoreRepository, appStartMsg.requiresIIIFService, appStartMsg.retryCnt) + case AppStop() => + println("==> AppStop") + appStop() + case AppReady() => + println("==> AppReady") + unstashAll() // unstash any messages, so that they can be processed + context.become(ready(), discardOld = true) + case _ => + stash() // stash any messages which we cannot handle in this state + } - case AppStop() => appStop() + def ready(): Receive = { + /* Usually only called from tests */ + case AppStop() => + appStop() /* Called from the "appStart" method. Entry point for startup sequence. */ case initStartUp: InitStartUp => @@ -163,9 +191,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with case SetAppState(value: AppState) => appState = value - logger.debug("appStateChanged - to state: {}", value) - value match { case AppStates.Stopped => // do nothing @@ -263,7 +289,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with case GetAllowReloadOverHTTPState() => logger.debug("ApplicationStateActor - GetAllowReloadOverHTTPState - value: {}", allowReloadOverHTTPState) - sender ! (allowReloadOverHTTPState | settings.allowReloadOverHTTP) + sender ! (allowReloadOverHTTPState | knoraSettings.allowReloadOverHTTP) case SetPrintConfigExtendedState(value) => logger.debug("ApplicationStateActor - SetPrintConfigExtendedState - value: {}", value) @@ -271,7 +297,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with case GetPrintConfigExtendedState() => logger.debug("ApplicationStateActor - GetPrintConfigExtendedState - value: {}", printConfigState) - sender ! (printConfigState | settings.printExtendedConfig) + sender ! (printConfigState | knoraSettings.printExtendedConfig) /* check repository request */ case CheckTriplestore() => @@ -301,7 +327,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with /* create caches request */ case CreateCaches() => - CacheUtil.createCaches(settings.caches) + CacheUtil.createCaches(knoraSettings.caches) self ! SetAppState(AppStates.CachesReady) case UpdateSearchIndex() => @@ -349,65 +375,87 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with case other => throw UnexpectedMessageException(s"ApplicationActor received an unexpected message $other of type ${other.getClass.getCanonicalName}") } + // Our rejection handler. Here we are using the default one from the CORS lib + val rejectionHandler: RejectionHandler = CorsDirectives.corsRejectionHandler.withFallback(RejectionHandler.default) + + // Our exception handler + val exceptionHandler: ExceptionHandler = KnoraExceptionHandler(KnoraSettings(system)) + + // Combining the two handlers for convenience + val handleErrors = handleRejections(rejectionHandler) & handleExceptions(exceptionHandler) + /** - * All routes composed together and CORS activated. + * All routes composed together and CORS activated based on the + * the configuration in application.conf (akka-http-cors). + * * ALL requests go through each of the routes in ORDER. * The FIRST matching route is used for handling a request. */ private val apiRoutes: Route = logDuration { addServerHeader { - CORS( - new HealthRoute(routeData).knoraApiPath ~ - new VersionRoute(routeData).knoraApiPath ~ - new RejectingRoute(routeData).knoraApiPath ~ - new ClientApiRoute(routeData).knoraApiPath ~ - new ResourcesRouteV1(routeData).knoraApiPath ~ - new ValuesRouteV1(routeData).knoraApiPath ~ - new StandoffRouteV1(routeData).knoraApiPath ~ - new ListsRouteV1(routeData).knoraApiPath ~ - new ResourceTypesRouteV1(routeData).knoraApiPath ~ - new SearchRouteV1(routeData).knoraApiPath ~ - new AuthenticationRouteV1(routeData).knoraApiPath ~ - new AssetsRouteV1(routeData).knoraApiPath ~ - new CkanRouteV1(routeData).knoraApiPath ~ - new UsersRouteV1(routeData).knoraApiPath ~ - new ProjectsRouteV1(routeData).knoraApiPath ~ - new OntologiesRouteV2(routeData).knoraApiPath ~ - new SearchRouteV2(routeData).knoraApiPath ~ - new ResourcesRouteV2(routeData).knoraApiPath ~ - new ValuesRouteV2(routeData).knoraApiPath ~ - new StandoffRouteV2(routeData).knoraApiPath ~ - new ListsRouteV2(routeData).knoraApiPath ~ - new AuthenticationRouteV2(routeData).knoraApiPath ~ - new GroupsRouteADM(routeData).knoraApiPath ~ - new ListsRouteADM(routeData).knoraApiPath ~ - new PermissionsRouteADM(routeData).knoraApiPath ~ - new ProjectsRouteADM(routeData).knoraApiPath ~ - new StoreRouteADM(routeData).knoraApiPath ~ - new UsersRouteADM(routeData).knoraApiPath ~ - new SipiRouteADM(routeData).knoraApiPath ~ - new SwaggerApiDocsRoute(routeData).knoraApiPath, - settings - ) + handleErrors { + CorsDirectives.cors(CorsSettings(system)) { + handleErrors { + new HealthRoute(routeData).knoraApiPath ~ + new VersionRoute(routeData).knoraApiPath ~ + new RejectingRoute(routeData).knoraApiPath ~ + new ClientApiRoute(routeData).knoraApiPath ~ + new ResourcesRouteV1(routeData).knoraApiPath ~ + new ValuesRouteV1(routeData).knoraApiPath ~ + new StandoffRouteV1(routeData).knoraApiPath ~ + new ListsRouteV1(routeData).knoraApiPath ~ + new ResourceTypesRouteV1(routeData).knoraApiPath ~ + new SearchRouteV1(routeData).knoraApiPath ~ + new AuthenticationRouteV1(routeData).knoraApiPath ~ + new AssetsRouteV1(routeData).knoraApiPath ~ + new CkanRouteV1(routeData).knoraApiPath ~ + new UsersRouteV1(routeData).knoraApiPath ~ + new ProjectsRouteV1(routeData).knoraApiPath ~ + new OntologiesRouteV2(routeData).knoraApiPath ~ + new SearchRouteV2(routeData).knoraApiPath ~ + new ResourcesRouteV2(routeData).knoraApiPath ~ + new ValuesRouteV2(routeData).knoraApiPath ~ + new StandoffRouteV2(routeData).knoraApiPath ~ + new ListsRouteV2(routeData).knoraApiPath ~ + new AuthenticationRouteV2(routeData).knoraApiPath ~ + new GroupsRouteADM(routeData).knoraApiPath ~ + new ListsRouteADM(routeData).knoraApiPath ~ + new PermissionsRouteADM(routeData).knoraApiPath ~ + new ProjectsRouteADM(routeData).knoraApiPath ~ + new StoreRouteADM(routeData).knoraApiPath ~ + new UsersRouteADM(routeData).knoraApiPath ~ + new SipiRouteADM(routeData).knoraApiPath ~ + new SwaggerApiDocsRoute(routeData).knoraApiPath + } + } + } } } // #start-api-server /** * Starts the Knora-API server. + * + * @param ignoreRepository if `true`, don't read anything from the repository on startup. + * @param requiresIIIFService if `true`, ensure that the IIIF service is started. + * @param retryCnt how many times was this command tried */ - def appStart(ignoreRepository: Boolean, requiresIIIFService: Boolean): Unit = { + def appStart(ignoreRepository: Boolean, requiresIIIFService: Boolean, retryCnt: Int): Unit = { val bindingFuture: Future[Http.ServerBinding] = Http() - .bindAndHandle( - Route.handlerFlow(apiRoutes), - settings.internalKnoraApiHost, - settings.internalKnoraApiPort - ) + .bindAndHandle( + Route.handlerFlow(apiRoutes), + knoraSettings.internalKnoraApiHost, + knoraSettings.internalKnoraApiPort + ) bindingFuture onComplete { case Success(_) => - if (settings.prometheusEndpoint) { + + // Transition to ready state + self ! AppReady() + + if (knoraSettings.prometheusEndpoint) { // Load Kamon monitoring Kamon.loadModules() } @@ -416,14 +464,24 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with self ! InitStartUp(ignoreRepository, requiresIIIFService) case Failure(ex) => - logger.error( - "Failed to bind to {}:{}! - {}", - settings.internalKnoraApiHost, - settings.internalKnoraApiPort, - ex.getMessage - ) - - appStop() + if (retryCnt < 5) { + logger.error( + "Failed to bind to {}:{}! - {} - retryCnt: {}", + knoraSettings.internalKnoraApiHost, + knoraSettings.internalKnoraApiPort, + ex.getMessage, + retryCnt + ) + self ! AppStart(ignoreRepository, requiresIIIFService, retryCnt + 1) + } else { + logger.error( + "Failed to bind to {}:{}! - {}", + knoraSettings.internalKnoraApiHost, + knoraSettings.internalKnoraApiPort, + ex.getMessage + ) + self ! AppStop() + } } } @@ -441,7 +499,7 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with super.postStop() logger.info("ApplicationActor - shutdown in progress, initiating post stop cleanup. Bye!") - if (settings.prometheusEndpoint) { + if (knoraSettings.prometheusEndpoint) { // Stop Kamon monitoring Kamon.stopModules() } @@ -468,30 +526,30 @@ class ApplicationActor extends Actor with LazyLogging with AroundDirectives with msg += "\n" - msg += s"Knora API Server started at http://${settings.internalKnoraApiHost}:${settings.internalKnoraApiPort}\n" + msg += s"Knora API Server started at http://${knoraSettings.internalKnoraApiHost}:${knoraSettings.internalKnoraApiPort}\n" msg += "----------------------------------------------------------------\n" - if (allowReloadOverHTTPState | settings.allowReloadOverHTTP) { + if (allowReloadOverHTTPState | knoraSettings.allowReloadOverHTTP) { msg += "WARNING: Resetting Triplestore Content over HTTP is turned ON.\n" msg += "----------------------------------------------------------------\n" } // which repository are we using - msg += s"DB-Name: ${settings.triplestoreDatabaseName}\n" - msg += s"DB-Type: ${settings.triplestoreType}\n" - msg += s"DB Server: ${settings.triplestoreHost}, DB Port: ${settings.triplestorePort}\n" + msg += s"DB-Name: ${knoraSettings.triplestoreDatabaseName}\n" + msg += s"DB-Type: ${knoraSettings.triplestoreType}\n" + msg += s"DB Server: ${knoraSettings.triplestoreHost}, DB Port: ${knoraSettings.triplestorePort}\n" if (printConfigState) { - msg += s"DB User: ${settings.triplestoreUsername}\n" - msg += s"DB Password: ${settings.triplestorePassword}\n" + msg += s"DB User: ${knoraSettings.triplestoreUsername}\n" + msg += s"DB Password: ${knoraSettings.triplestorePassword}\n" - msg += s"Swagger Json: ${settings.externalKnoraApiBaseUrl}/api-docs/swagger.json\n" - msg += s"Webapi internal URL: ${settings.internalKnoraApiBaseUrl}\n" - msg += s"Webapi external URL: ${settings.externalKnoraApiBaseUrl}\n" - msg += s"Sipi internal URL: ${settings.internalSipiBaseUrl}\n" - msg += s"Sipi external URL: ${settings.externalSipiBaseUrl}\n" + msg += s"Swagger Json: ${knoraSettings.externalKnoraApiBaseUrl}/api-docs/swagger.json\n" + msg += s"Webapi internal URL: ${knoraSettings.internalKnoraApiBaseUrl}\n" + msg += s"Webapi external URL: ${knoraSettings.externalKnoraApiBaseUrl}\n" + msg += s"Sipi internal URL: ${knoraSettings.internalSipiBaseUrl}\n" + msg += s"Sipi external URL: ${knoraSettings.externalSipiBaseUrl}\n" } msg += "================================================================\n" diff --git a/webapi/src/main/scala/org/knora/webapi/http/CORSSupport.scala b/webapi/src/main/scala/org/knora/webapi/http/CORSSupport.scala deleted file mode 100644 index f61d9d3e29..0000000000 --- a/webapi/src/main/scala/org/knora/webapi/http/CORSSupport.scala +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright © 2015-2019 the contributors (see Contributors.md). - * - * This file is part of Knora. - * - * Knora is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Knora is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with Knora. If not, see . - */ - -package org.knora.webapi.http - -import akka.http.scaladsl.model.HttpMethods._ -import akka.http.scaladsl.model.headers.HttpOriginRange -import akka.http.scaladsl.server.{Directives, RejectionHandler, Route} -import ch.megard.akka.http.cors.scaladsl.CorsDirectives -import ch.megard.akka.http.cors.scaladsl.CorsDirectives._ -import ch.megard.akka.http.cors.scaladsl.model.HttpHeaderRange -import ch.megard.akka.http.cors.scaladsl.settings.CorsSettings -import com.typesafe.scalalogging.LazyLogging -import org.knora.webapi.{KnoraExceptionHandler, SettingsImpl} - -import scala.collection.immutable.Seq - -object CORSSupport extends Directives with LazyLogging { - - val allowedMethods = Seq(GET, PUT, POST, DELETE, HEAD, OPTIONS) - val exposedHeaders = Seq("Server") - val age: Long = 30 * 60 - - val corsSettings = CorsSettings.defaultSettings. - withAllowGenericHttpRequests(true). - withAllowCredentials(true). - withAllowedOrigins(HttpOriginRange.*). - withAllowedHeaders(HttpHeaderRange.*). - withAllowedMethods(allowedMethods). - withExposedHeaders(exposedHeaders). - withMaxAge(Some(age)) - - /** - * Adds CORS support to a route. Also, any exceptions thrown inside the route are handled by - * the [[KnoraExceptionHandler]]. Finally, all rejections are handled by the [[CorsDirectives.corsRejectionHandler]] - * so that all responses (correct and failures) have the correct CORS headers attached. - * - * @param route the route for which CORS support is enabled - * @return the enabled route. - */ - def CORS(route: Route, settings: SettingsImpl): Route = { - handleRejections(CorsDirectives.corsRejectionHandler) { - cors(corsSettings) { - handleRejections(RejectionHandler.default) { - handleExceptions(KnoraExceptionHandler(settings)) { - route - } - } - } - } - } -} \ No newline at end of file diff --git a/webapi/src/main/scala/org/knora/webapi/messages/app/appmessages/ApplicationMessages.scala b/webapi/src/main/scala/org/knora/webapi/messages/app/appmessages/ApplicationMessages.scala index 4bf0776528..84b115f209 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/app/appmessages/ApplicationMessages.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/app/appmessages/ApplicationMessages.scala @@ -3,168 +3,194 @@ package org.knora.webapi.messages.app.appmessages sealed trait ApplicationRequest /** - * Start Application - * - * @param ignoreRepository if `true`, don't read anything from the repository on startup. - * @param requiresIIIFService if `true`, ensure that the IIIF service is started. - */ -case class AppStart(ignoreRepository: Boolean, requiresIIIFService: Boolean) extends ApplicationRequest + * Start Application + * + * @param ignoreRepository if `true`, don't read anything from the repository on startup. + * @param requiresIIIFService if `true`, ensure that the IIIF service is started. + * @param retryCnt how many times was this command tried + */ +case class AppStart(ignoreRepository: Boolean, requiresIIIFService: Boolean, retryCnt: Int = 0) extends ApplicationRequest /** - * Stop Application - */ + * After a successful bind, the ApplicationActor will receive this message and + * change his behaviour to ready. + */ +case class AppReady() extends ApplicationRequest + +/** + * Stop Application + */ case class AppStop() extends ApplicationRequest /** - * Check if actor is ready. - */ + * Check if actor is ready. + */ case class ActorReady() extends ApplicationRequest /** - * Response used to acknowledge that actor is ready. - */ + * Response used to acknowledge that actor is ready. + */ case class ActorReadyAck() /** - * Setter message for storing the LoadDemoData flag. - */ + * Setter message for storing the LoadDemoData flag. + */ case class SetLoadDemoDataState(value: Boolean) extends ApplicationRequest /** - * Getter message for retrieving the LoadDemoData flag value. - */ + * Getter message for retrieving the LoadDemoData flag value. + */ case class GetLoadDemoDataState() extends ApplicationRequest /** - * Setter message for storing the llowReloadOverHTTP flag. - */ + * Setter message for storing the llowReloadOverHTTP flag. + */ case class SetAllowReloadOverHTTPState(value: Boolean) extends ApplicationRequest /** - * Getter message for retrieving the llowReloadOverHTTP flag value. - */ + * Getter message for retrieving the llowReloadOverHTTP flag value. + */ case class GetAllowReloadOverHTTPState() extends ApplicationRequest /** - * Setter message for storing the rometheusReporter flag. - */ + * Setter message for storing the rometheusReporter flag. + */ case class SetPrometheusReporterState(value: Boolean) extends ApplicationRequest /** - * Getter message for retrieving the rometheusReporter flag value. - */ + * Getter message for retrieving the rometheusReporter flag value. + */ case class GetPrometheusReporterState() extends ApplicationRequest /** - * Setter message for storing the ZipkinReporter flag. - */ + * Setter message for storing the ZipkinReporter flag. + */ case class SetZipkinReporterState(value: Boolean) extends ApplicationRequest /** - * Getter message for retrieving the ZipkinReporter flag value. - */ + * Getter message for retrieving the ZipkinReporter flag value. + */ case class GetZipkinReporterState() extends ApplicationRequest /** - * Setter message for storing the JaegerReporter flag. - */ + * Setter message for storing the JaegerReporter flag. + */ case class SetJaegerReporterState(value: Boolean) extends ApplicationRequest /** - * Getter message for retrieving the JaegerReporter flag value. - */ + * Getter message for retrieving the JaegerReporter flag value. + */ case class GetJaegerReporterState() extends ApplicationRequest /** - * Setter message for storing the PrintConfigExtended flag. - */ + * Setter message for storing the PrintConfigExtended flag. + */ case class SetPrintConfigExtendedState(value: Boolean) extends ApplicationRequest /** - * Getter message for retrieving the PrintConfigExtended flag value. - */ + * Getter message for retrieving the PrintConfigExtended flag value. + */ case class GetPrintConfigExtendedState() extends ApplicationRequest /** - * Setter message for setting the current application state. - */ + * Setter message for setting the current application state. + */ case class SetAppState(value: AppState) extends ApplicationRequest /** - * Message for getting the current application state. - */ + * Message for getting the current application state. + */ case class GetAppState() extends ApplicationRequest /** - * Message for initiating the startup sequence. - * - * @param ignoreRepository if `true`, don't read anything from the repository on startup. - * @param requiresIIIFService if `true`, ensure that the IIIF service is started. - */ + * Message for initiating the startup sequence. + * + * @param ignoreRepository if `true`, don't read anything from the repository on startup. + * @param requiresIIIFService if `true`, ensure that the IIIF service is started. + */ case class InitStartUp(ignoreRepository: Boolean, requiresIIIFService: Boolean) extends ApplicationRequest /** - * Acknowledgment message for [[InitStartUp]]. - */ + * Acknowledgment message for [[InitStartUp]]. + */ case class InitStartUpAck() extends ApplicationRequest /** - * Message for checking whether the triplestore is available. Used only inside the actor itself. - */ + * Message for checking whether the triplestore is available. Used only inside the actor itself. + */ case class CheckTriplestore() extends ApplicationRequest /** - * Message for updating the repository to work the current version of Knora. Used only inside the actor itself. - */ + * Message for updating the repository to work the current version of Knora. Used only inside the actor itself. + */ case class UpdateRepository() extends ApplicationRequest /** - * Message for initiating cache creation. Used only inside the actor itself. - */ + * Message for initiating cache creation. Used only inside the actor itself. + */ case class CreateCaches() extends ApplicationRequest /** - * Message for updating the triplestore's full-text search index. Used only inside the actor itself. - */ + * Message for updating the triplestore's full-text search index. Used only inside the actor itself. + */ case class UpdateSearchIndex() extends ApplicationRequest /** - * Message for initiating loading of ontologies. Used only inside the actor itself. - */ + * Message for initiating loading of ontologies. Used only inside the actor itself. + */ case class LoadOntologies() extends ApplicationRequest /** - * Message for initiating IIIF Service checking. Used only inside the actor itself. - */ + * Message for initiating IIIF Service checking. Used only inside the actor itself. + */ case object CheckIIIFService extends ApplicationRequest /** - * Message for initiating Cache Service checking. Used only inside the actor itself. - */ + * Message for initiating Cache Service checking. Used only inside the actor itself. + */ case object CheckCacheService extends ApplicationRequest /** - * Application States at Startup - */ + * Application States at Startup + */ sealed trait AppState object AppStates { + case object Stopped extends AppState + case object StartingUp extends AppState + case object WaitingForTriplestore extends AppState + case object TriplestoreReady extends AppState + case object UpdatingRepository extends AppState + case object RepositoryUpToDate extends AppState + case object CreatingCaches extends AppState + case object CachesReady extends AppState + case object UpdatingSearchIndex extends AppState + case object SearchIndexReady extends AppState + case object LoadingOntologies extends AppState + case object OntologiesReady extends AppState + case object WaitingForIIIFService extends AppState + case object IIIFServiceReady extends AppState + case object WaitingForCacheService extends AppState + case object CacheServiceReady extends AppState + case object MaintenanceMode extends AppState + case object Running extends AppState + } diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraRequestV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraRequestV2.scala index 803a3889c8..d89286cfe6 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraRequestV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraRequestV2.scala @@ -24,7 +24,7 @@ import java.util.UUID import akka.actor.ActorRef import akka.event.LoggingAdapter import akka.util.Timeout -import org.knora.webapi.SettingsImpl +import org.knora.webapi.KnoraSettingsImpl import org.knora.webapi.messages.admin.responder.usersmessages.UserADM import org.knora.webapi.util.jsonld.JsonLDDocument @@ -61,7 +61,7 @@ trait KnoraJsonLDRequestReaderV2[C] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[C] } // #KnoraJsonLDRequestReaderV2 diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraResponseV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraResponseV2.scala index 630658cbe1..b6227b6814 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraResponseV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/KnoraResponseV2.scala @@ -37,7 +37,7 @@ trait KnoraResponseV2 { * @param targetSchema the Knora API schema to be used in the JSON-LD document. * @return a [[JsonLDDocument]] representing the response. */ - def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument + def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument } // #KnoraResponseV2 @@ -47,7 +47,7 @@ trait KnoraResponseV2 { * @param message the message to be returned. */ case class SuccessResponseV2(message: String) extends KnoraResponseV2 { - def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { val (ontologyPrefixExpansion, resultProp) = targetSchema match { case ApiV2Simple => (OntologyConstants.KnoraApiV2Simple.KnoraApiV2PrefixExpansion, OntologyConstants.KnoraApiV2Simple.Result) case ApiV2Complex => (OntologyConstants.KnoraApiV2Complex.KnoraApiV2PrefixExpansion, OntologyConstants.KnoraApiV2Complex.Result) diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/listsmessages/ListsMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/listsmessages/ListsMessagesV2.scala index a8cb73aa4a..9756c8a198 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/listsmessages/ListsMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/listsmessages/ListsMessagesV2.scala @@ -77,7 +77,7 @@ trait ListResponderResponseV2 { */ case class ListGetResponseV2(list: ListADM, userLang: String, fallbackLang: String) extends KnoraResponseV2 with ListResponderResponseV2 { - def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -173,7 +173,7 @@ case class NodeGetRequestV2(nodeIri: IRI, */ case class NodeGetResponseV2(node: ListNodeInfoADM, userLang: String, fallbackLang: String) extends KnoraResponseV2 with ListResponderResponseV2 { - def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/ontologymessages/OntologyMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/ontologymessages/OntologyMessagesV2.scala index 19aa679af2..09cb253bdf 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/ontologymessages/OntologyMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/ontologymessages/OntologyMessagesV2.scala @@ -92,7 +92,7 @@ object CreateOntologyRequestV2 extends KnoraJsonLDRequestReaderV2[CreateOntology requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[CreateOntologyRequestV2] = { Future { fromJsonLDSync( @@ -364,7 +364,7 @@ object CreatePropertyRequestV2 extends KnoraJsonLDRequestReaderV2[CreateProperty requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[CreatePropertyRequestV2] = { Future { fromJsonLDSync( @@ -458,7 +458,7 @@ object CreateClassRequestV2 extends KnoraJsonLDRequestReaderV2[CreateClassReques requestingUser: UserADM, storeManager: ActorRef, responderManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[CreateClassRequestV2] = { Future { fromJsonLDSync( @@ -533,7 +533,7 @@ object AddCardinalitiesToClassRequestV2 extends KnoraJsonLDRequestReaderV2[AddCa requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[AddCardinalitiesToClassRequestV2] = { Future { fromJsonLDSync( @@ -602,7 +602,7 @@ object ChangeCardinalitiesRequestV2 extends KnoraJsonLDRequestReaderV2[ChangeCar requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[ChangeCardinalitiesRequestV2] = { Future { fromJsonLDSync( @@ -710,7 +710,7 @@ object ChangePropertyLabelsOrCommentsRequestV2 extends KnoraJsonLDRequestReaderV requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[ChangePropertyLabelsOrCommentsRequestV2] = { Future { fromJsonLDSync( @@ -782,7 +782,7 @@ object ChangeClassLabelsOrCommentsRequestV2 extends KnoraJsonLDRequestReaderV2[C requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[ChangeClassLabelsOrCommentsRequestV2] = { Future { fromJsonLDSync( @@ -852,7 +852,7 @@ object ChangeOntologyMetadataRequestV2 extends KnoraJsonLDRequestReaderV2[Change requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[ChangeOntologyMetadataRequestV2] = { Future { fromJsonLDSync( @@ -1133,11 +1133,11 @@ case class ReadOntologyV2(ontologyMetadata: OntologyMetadataV2, ) } - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { toOntologySchema(targetSchema).generateJsonLD(targetSchema, settings) } - private def generateJsonLD(targetSchema: ApiV2Schema, settings: SettingsImpl): JsonLDDocument = { + private def generateJsonLD(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl): JsonLDDocument = { // Get the ontologies of all Knora entities mentioned in class definitions. val knoraOntologiesFromClasses: Set[SmartIri] = classes.values.flatMap { @@ -1449,7 +1449,7 @@ case class ReadOntologyMetadataV2(ontologies: Set[OntologyMetadataV2]) extends K ) } - private def generateJsonLD(targetSchema: ApiV2Schema, settings: SettingsImpl): JsonLDDocument = { + private def generateJsonLD(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl): JsonLDDocument = { val knoraApiOntologyPrefixExpansion = targetSchema match { case ApiV2Simple => OntologyConstants.KnoraApiV2Simple.KnoraApiV2PrefixExpansion case ApiV2Complex => OntologyConstants.KnoraApiV2Complex.KnoraApiV2PrefixExpansion @@ -1471,7 +1471,7 @@ case class ReadOntologyMetadataV2(ontologies: Set[OntologyMetadataV2]) extends K JsonLDDocument(body = body, context = context) } - def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { toOntologySchema(targetSchema).generateJsonLD(targetSchema, settings) } } @@ -1765,7 +1765,7 @@ sealed trait EntityInfoContentV2 { * @param userLang the language in which the object should to be returned. * @return the requested predicate and object. */ - def getPredicateAndStringLiteralObjectWithLang(predicateIri: SmartIri, settings: SettingsImpl, userLang: String): Option[(SmartIri, String)] = { + def getPredicateAndStringLiteralObjectWithLang(predicateIri: SmartIri, settings: KnoraSettingsImpl, userLang: String): Option[(SmartIri, String)] = { getPredicateStringLiteralObject( predicateIri = predicateIri, preferredLangs = Some(userLang, settings.fallbackLanguage) @@ -2028,7 +2028,7 @@ sealed trait ReadEntityInfoV2 { * @param settings the application settings. * @return a JSON-LD object representing the entity. */ - def toJsonLDWithSingleLanguage(targetSchema: ApiV2Schema, userLang: String, settings: SettingsImpl): JsonLDObject = { + def toJsonLDWithSingleLanguage(targetSchema: ApiV2Schema, userLang: String, settings: KnoraSettingsImpl): JsonLDObject = { val label: Option[(IRI, JsonLDString)] = entityInfoContent.getPredicateAndStringLiteralObjectWithLang(OntologyConstants.Rdfs.Label.toSmartIri, settings, userLang).map { case (k: SmartIri, v: String) => (k.toString, JsonLDString(v)) } diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala index db0d247710..e9b20a4d9b 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala @@ -109,7 +109,7 @@ case class ResourceVersionHistoryResponseV2(history: Seq[ResourceHistoryEntry]) * @param targetSchema the Knora API schema to be used in the JSON-LD document. * @return a [[JsonLDDocument]] representing the response. */ - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance if (targetSchema != ApiV2Complex) { @@ -187,7 +187,7 @@ case class ResourceTEIGetResponseV2(header: TEIHeader, body: TEIBody) { * @param headerXSLT XSLT to be applied to the resource's metadata in RDF/XML. * */ -case class TEIHeader(headerInfo: ReadResourceV2, headerXSLT: Option[String], settings: SettingsImpl) { +case class TEIHeader(headerInfo: ReadResourceV2, headerXSLT: Option[String], settings: KnoraSettingsImpl) { def toXML: String = { @@ -335,7 +335,7 @@ case class ReadResourceV2(resourceIri: IRI, ) } - def toJsonLD(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDObject = { + def toJsonLD(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDObject = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance if (!resourceClassIri.getOntologySchema.contains(targetSchema)) { @@ -517,7 +517,7 @@ object CreateResourceRequestV2 extends KnoraJsonLDRequestReaderV2[CreateResource requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[CreateResourceRequestV2] = { // #getGeneralInstance implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -675,7 +675,7 @@ object UpdateResourceMetadataRequestV2 extends KnoraJsonLDRequestReaderV2[Update requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[UpdateResourceMetadataRequestV2] = { Future { fromJsonLDSync( @@ -766,7 +766,7 @@ object DeleteOrEraseResourceRequestV2 extends KnoraJsonLDRequestReaderV2[DeleteO requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[DeleteOrEraseResourceRequestV2] = { Future { fromJsonLDSync( @@ -836,7 +836,7 @@ case class ReadResourcesSequenceV2(resources: Seq[ReadResourceV2], } // #generateJsonLD - private def generateJsonLD(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + private def generateJsonLD(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { // #generateJsonLD implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -898,7 +898,7 @@ case class ReadResourcesSequenceV2(resources: Seq[ReadResourceV2], } // #toJsonLDDocument - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption] = Set.empty): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption] = Set.empty): JsonLDDocument = { toOntologySchema(targetSchema).generateJsonLD( targetSchema = targetSchema, settings = settings, @@ -1036,7 +1036,7 @@ case class GraphEdgeV2(source: IRI, propertyIri: SmartIri, target: IRI) extends * @param edges the edges in the graph. */ case class GraphDataGetResponseV2(nodes: Seq[GraphNodeV2], edges: Seq[GraphEdgeV2], ontologySchema: OntologySchema) extends KnoraResponseV2 with KnoraReadV2[GraphDataGetResponseV2] { - private def generateJsonLD(targetSchema: ApiV2Schema, settings: SettingsImpl): JsonLDDocument = { + private def generateJsonLD(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance val sortedNodesInTargetSchema: Seq[GraphNodeV2] = nodes.map(_.toOntologySchema(targetSchema)).sortBy(_.resourceIri) @@ -1108,7 +1108,7 @@ case class GraphDataGetResponseV2(nodes: Seq[GraphNodeV2], edges: Seq[GraphEdgeV JsonLDDocument(body = body, context = context) } - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { toOntologySchema(targetSchema).generateJsonLD(targetSchema, settings) } diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/searchmessages/SearchMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/searchmessages/SearchMessagesV2.scala index 5e2781320e..f7d8b407bc 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/searchmessages/SearchMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/searchmessages/SearchMessagesV2.scala @@ -25,7 +25,7 @@ import org.knora.webapi.messages.v2.responder.resourcemessages._ import org.knora.webapi.responders.v2.search.ConstructQuery import org.knora.webapi.util.SmartIri import org.knora.webapi.util.jsonld.{JsonLDDocument, JsonLDInt, JsonLDObject, JsonLDString} -import org.knora.webapi.{ApiV2Complex, ApiV2Schema, IRI, OntologyConstants, SchemaOption, SettingsImpl} +import org.knora.webapi.{ApiV2Complex, ApiV2Schema, IRI, OntologyConstants, SchemaOption, KnoraSettingsImpl} /** * An abstract trait for messages that can be sent to `SearchResponderV2`. @@ -130,7 +130,7 @@ case class SearchResourceByLabelRequestV2(searchValue: String, * Represents the number of resources found by a search query. */ case class ResourceCountV2(numberOfResources: Int) extends KnoraResponseV2 { - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { JsonLDDocument( body = JsonLDObject(Map( OntologyConstants.SchemaOrg.NumberOfItems -> JsonLDInt(numberOfResources) diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/standoffmessages/StandoffMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/standoffmessages/StandoffMessagesV2.scala index 9bfa96b313..8a89895595 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/standoffmessages/StandoffMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/standoffmessages/StandoffMessagesV2.scala @@ -81,7 +81,7 @@ case class GetStandoffResponseV2(valueIri: IRI, * @param targetSchema the Knora API schema to be used in the JSON-LD document. * @return a [[JsonLDDocument]] representing the response. */ - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { if (targetSchema != ApiV2Complex) { throw AssertionException(s"Standoff is available only in the complex schema") } @@ -142,7 +142,7 @@ object CreateMappingRequestMetadataV2 extends KnoraJsonLDRequestReaderV2[CreateM requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[CreateMappingRequestMetadataV2] = { Future { fromJsonLDSync( @@ -190,7 +190,7 @@ case class CreateMappingRequestXMLV2(xml: String) extends StandoffResponderReque */ case class CreateMappingResponseV2(mappingIri: IRI, label: String, projectIri: SmartIri) extends KnoraResponseV2 { - def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance diff --git a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala index de0d8c6157..92111cec0b 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/v2/responder/valuemessages/ValueMessagesV2.scala @@ -84,7 +84,7 @@ object CreateValueRequestV2 extends KnoraJsonLDRequestReaderV2[CreateValueReques requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[CreateValueRequestV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -146,7 +146,7 @@ case class CreateValueResponseV2(valueIri: IRI, valueType: SmartIri, valueUUID: UUID, projectADM: ProjectADM) extends KnoraResponseV2 with UpdateResultInProject { - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance if (targetSchema != ApiV2Complex) { @@ -204,7 +204,7 @@ object UpdateValueRequestV2 extends KnoraJsonLDRequestReaderV2[UpdateValueReques requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[UpdateValueRequestV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -289,7 +289,7 @@ case class UpdateValueResponseV2(valueIri: IRI, valueType: SmartIri, valueUUID: UUID, projectADM: ProjectADM) extends KnoraResponseV2 with UpdateResultInProject { - override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { + override def toJsonLDDocument(targetSchema: ApiV2Schema, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDDocument = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance if (targetSchema != ApiV2Complex) { @@ -354,7 +354,7 @@ object DeleteValueRequestV2 extends KnoraJsonLDRequestReaderV2[DeleteValueReques requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[DeleteValueRequestV2] = { Future { fromJsonLDSync( @@ -553,7 +553,7 @@ sealed trait ReadValueV2 extends IOValueV2 { * @param settings the application settings. * @return a JSON-LD representation of this value. */ - def toJsonLD(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + def toJsonLD(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance val valueContentAsJsonLD = valueContent.toJsonLDValue( @@ -650,7 +650,7 @@ case class ReadTextValueV2(valueIri: IRI, copy(valueContent = valueContent.toOntologySchema(targetSchema)) } - override def toJsonLD(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLD(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance val valueAsJsonLDValue: JsonLDValue = super.toJsonLD( @@ -886,7 +886,7 @@ sealed trait ValueContentV2 extends KnoraContentV2[ValueContentV2] { * @param settings the configuration options. * @return a [[JsonLDValue]] that can be used to generate JSON-LD representing this value. */ - def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue + def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue /** * Undoes the SPARQL-escaping of strings in this [[ValueContentV2]]. @@ -937,7 +937,7 @@ trait ValueContentReaderV2[C <: ValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[C] protected def getComment(jsonLDObject: JsonLDObject)(implicit stringFormatter: StringFormatter): Option[String] = { @@ -964,7 +964,7 @@ object ValueContentV2 extends ValueContentReaderV2[ValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[ValueContentV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -1073,7 +1073,7 @@ case class DateValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): DateValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.datatypeValueToJsonLDObject( @@ -1173,7 +1173,7 @@ object DateValueContentV2 extends ValueContentReaderV2[DateValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[DateValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -1336,7 +1336,7 @@ case class TextValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): TextValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => valueHasLanguage match { @@ -1545,7 +1545,7 @@ object TextValueContentV2 extends ValueContentReaderV2[TextValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[TextValueContentV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -1621,7 +1621,7 @@ case class IntegerValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): IntegerValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDInt(valueHasInteger) @@ -1673,7 +1673,7 @@ object IntegerValueContentV2 extends ValueContentReaderV2[IntegerValueContentV2] requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[IntegerValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -1709,7 +1709,7 @@ case class DecimalValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): DecimalValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { val decimalValueAsJsonLDObject = JsonLDUtil.datatypeValueToJsonLDObject( value = valueHasDecimal.toString, datatype = OntologyConstants.Xsd.Decimal.toSmartIri @@ -1765,7 +1765,7 @@ object DecimalValueContentV2 extends ValueContentReaderV2[DecimalValueContentV2] requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[DecimalValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -1805,7 +1805,7 @@ case class BooleanValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): BooleanValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDBoolean(valueHasBoolean) @@ -1854,7 +1854,7 @@ object BooleanValueContentV2 extends ValueContentReaderV2[BooleanValueContentV2] requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[BooleanValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -1890,7 +1890,7 @@ case class GeomValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): GeomValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.datatypeValueToJsonLDObject( @@ -1948,7 +1948,7 @@ object GeomValueContentV2 extends ValueContentReaderV2[GeomValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[GeomValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -1987,7 +1987,7 @@ case class IntervalValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): IntervalValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.datatypeValueToJsonLDObject( @@ -2057,7 +2057,7 @@ object IntervalValueContentV2 extends ValueContentReaderV2[IntervalValueContentV requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[IntervalValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -2104,7 +2104,7 @@ case class TimeValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): TimeValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.datatypeValueToJsonLDObject( @@ -2168,7 +2168,7 @@ object TimeValueContentV2 extends ValueContentReaderV2[TimeValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[TimeValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -2210,7 +2210,7 @@ case class HierarchicalListValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): HierarchicalListValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => listNodeLabel match { @@ -2276,7 +2276,7 @@ object HierarchicalListValueContentV2 extends ValueContentReaderV2[HierarchicalL requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[HierarchicalListValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -2317,7 +2317,7 @@ case class ColorValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): ColorValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.datatypeValueToJsonLDObject( @@ -2375,7 +2375,7 @@ object ColorValueContentV2 extends ValueContentReaderV2[ColorValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[ColorValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -2411,7 +2411,7 @@ case class UriValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): UriValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { val uriAsJsonLDObject = JsonLDUtil.datatypeValueToJsonLDObject( value = valueHasUri, datatype = OntologyConstants.Xsd.Uri.toSmartIri @@ -2470,7 +2470,7 @@ object UriValueContentV2 extends ValueContentReaderV2[UriValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[UriValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -2511,7 +2511,7 @@ case class GeonameValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): GeonameValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.datatypeValueToJsonLDObject( @@ -2569,7 +2569,7 @@ object GeonameValueContentV2 extends ValueContentReaderV2[GeonameValueContentV2] requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[GeonameValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } @@ -2611,7 +2611,7 @@ object FileValueWithSipiMetadata { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[FileValueWithSipiMetadata] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -2682,7 +2682,7 @@ case class StillImageFileValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): StillImageFileValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { val fileUrl: String = s"${settings.externalSipiIIIFGetUrl}/${projectADM.shortcode}/${fileValue.internalFilename}/full/$dimX,$dimY/0/default.jpg" targetSchema match { @@ -2733,7 +2733,7 @@ object StillImageFileValueContentV2 extends ValueContentReaderV2[StillImageFileV requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[StillImageFileValueContentV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -2780,7 +2780,7 @@ case class DocumentFileValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): DocumentFileValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { val fileUrl: String = s"${settings.externalSipiBaseUrl}/${projectADM.shortcode}/${fileValue.internalFilename}" targetSchema match { @@ -2834,7 +2834,7 @@ object DocumentFileValueContentV2 extends ValueContentReaderV2[DocumentFileValue requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[DocumentFileValueContentV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -2876,7 +2876,7 @@ case class TextFileValueContentV2(ontologySchema: OntologySchema, override def toOntologySchema(targetSchema: OntologySchema): TextFileValueContentV2 = copy(ontologySchema = targetSchema) - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { val fileUrl: String = s"${settings.externalSipiBaseUrl}/${projectADM.shortcode}/${fileValue.internalFilename}" targetSchema match { @@ -2919,7 +2919,7 @@ object TextFileValueContentV2 extends ValueContentReaderV2[TextFileValueContentV requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[TextFileValueContentV2] = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance @@ -2981,7 +2981,7 @@ case class LinkValueContentV2(ontologySchema: OntologySchema, ) } - override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: SettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { + override def toJsonLDValue(targetSchema: ApiV2Schema, projectADM: ProjectADM, settings: KnoraSettingsImpl, schemaOptions: Set[SchemaOption]): JsonLDValue = { targetSchema match { case ApiV2Simple => JsonLDUtil.iriToJsonLDObject(referredResourceIri) @@ -3049,7 +3049,7 @@ object LinkValueContentV2 extends ValueContentReaderV2[LinkValueContentV2] { requestingUser: UserADM, responderManager: ActorRef, storeManager: ActorRef, - settings: SettingsImpl, + settings: KnoraSettingsImpl, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[LinkValueContentV2] = { Future(fromJsonLDObjectSync(jsonLDObject)) } diff --git a/webapi/src/main/scala/org/knora/webapi/responders/Responder.scala b/webapi/src/main/scala/org/knora/webapi/responders/Responder.scala index 5cbf1dba7e..fc52fbdcbf 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/Responder.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/Responder.scala @@ -76,7 +76,7 @@ abstract class Responder(responderData: ResponderData) extends LazyLogging { /** * The application settings. */ - protected val settings: SettingsImpl = Settings(system) + protected val settings: KnoraSettingsImpl = KnoraSettings(system) /** * The main application actor. diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v1/ValueUtilV1.scala b/webapi/src/main/scala/org/knora/webapi/responders/v1/ValueUtilV1.scala index a58c01ff91..7bc49a293d 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v1/ValueUtilV1.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v1/ValueUtilV1.scala @@ -39,7 +39,7 @@ import scala.concurrent.{ExecutionContext, Future} /** * Converts data from SPARQL query results into [[ApiValueV1]] objects. */ -class ValueUtilV1(private val settings: SettingsImpl) { +class ValueUtilV1(private val settings: KnoraSettingsImpl) { private val stringFormatter = StringFormatter.getGeneralInstance diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/FullTextMainQueryGenerator.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/FullTextMainQueryGenerator.scala index 414e37570b..bc4e1db1ca 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/FullTextMainQueryGenerator.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/FullTextMainQueryGenerator.scala @@ -78,7 +78,7 @@ object FullTextMainQueryGenerator { * @param schemaOptions the schema options submitted with the request. * @return a [[ConstructQuery]]. */ - def createMainQuery(resourceIris: Set[IRI], valueObjectIris: Set[IRI], targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption], settings: SettingsImpl): ConstructQuery = { + def createMainQuery(resourceIris: Set[IRI], valueObjectIris: Set[IRI], targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption], settings: KnoraSettingsImpl): ConstructQuery = { implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance import FullTextSearchConstants._ diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/mainquery/GravsearchMainQueryGenerator.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/mainquery/GravsearchMainQueryGenerator.scala index ac3da70fed..e0c542ebc3 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/mainquery/GravsearchMainQueryGenerator.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/mainquery/GravsearchMainQueryGenerator.scala @@ -219,7 +219,7 @@ object GravsearchMainQueryGenerator { * @param schemaOptions the schema options submitted with the request. * @return the main [[ConstructQuery]] query to be executed. */ - def createMainQuery(mainResourceIris: Set[IriRef], dependentResourceIris: Set[IriRef], valueObjectIris: Set[IRI], targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption], settings: SettingsImpl): ConstructQuery = { + def createMainQuery(mainResourceIris: Set[IriRef], dependentResourceIris: Set[IriRef], valueObjectIris: Set[IRI], targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption], settings: KnoraSettingsImpl): ConstructQuery = { import GravsearchConstants._ implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformer.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformer.scala index 4e9bc5aba4..18da024899 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformer.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformer.scala @@ -36,7 +36,7 @@ import org.knora.webapi.responders.v2.search.gravsearch.types._ class NonTriplestoreSpecificGravsearchToPrequeryTransformer(constructClause: ConstructClause, typeInspectionResult: GravsearchTypeInspectionResult, querySchema: ApiV2Schema, - settings: SettingsImpl) + settings: KnoraSettingsImpl) extends AbstractPrequeryGenerator( constructClause = constructClause, typeInspectionResult = typeInspectionResult, diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/types/GravsearchTypeInspector.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/types/GravsearchTypeInspector.scala index 489897b2d7..c5e5279f03 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/types/GravsearchTypeInspector.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/search/gravsearch/types/GravsearchTypeInspector.scala @@ -24,7 +24,7 @@ import akka.util.Timeout import org.knora.webapi.messages.admin.responder.usersmessages.UserADM import org.knora.webapi.responders.ResponderData import org.knora.webapi.responders.v2.search._ -import org.knora.webapi.{KnoraDispatchers, Settings, SettingsImpl} +import org.knora.webapi.{KnoraDispatchers, KnoraSettings, KnoraSettingsImpl} import scala.concurrent.{ExecutionContext, Future} @@ -40,7 +40,7 @@ abstract class GravsearchTypeInspector(protected val nextInspector: Option[Gravs responderData: ResponderData) { protected val system: ActorSystem = responderData.system - protected val settings: SettingsImpl = Settings(system) + protected val settings: KnoraSettingsImpl = KnoraSettings(system) protected implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) protected implicit val timeout: Timeout = settings.defaultTimeout diff --git a/webapi/src/main/scala/org/knora/webapi/routing/Authenticator.scala b/webapi/src/main/scala/org/knora/webapi/routing/Authenticator.scala index 4cf68c94ed..5366de7066 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/Authenticator.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/Authenticator.scala @@ -68,7 +68,7 @@ trait Authenticator { */ def doLoginV1(requestContext: RequestContext)(implicit system: ActorSystem, responderManager: ActorRef, executionContext: ExecutionContext): Future[HttpResponse] = { - val settings = Settings(system) + val settings = KnoraSettings(system) val credentials: Option[KnoraCredentialsV2] = extractCredentialsV2(requestContext) @@ -110,7 +110,7 @@ trait Authenticator { for { authenticated <- authenticateCredentialsV2(Some(credentials)) // will throw exception if not valid and thus trigger the correct response - settings = Settings(system) + settings = KnoraSettings(system) userADM <- getUserByIdentifier(credentials.identifier) @@ -134,7 +134,7 @@ trait Authenticator { def presentLoginFormV2(requestContext: RequestContext)(implicit system: ActorSystem, executionContext: ExecutionContext): Future[HttpResponse] = { - val settings = Settings(system) + val settings = KnoraSettings(system) val apiUrl = settings.externalKnoraApiBaseUrl @@ -254,7 +254,7 @@ trait Authenticator { val credentials = extractCredentialsV2(requestContext) - val settings = Settings(system) + val settings = KnoraSettings(system) val cookieDomain = Some(settings.cookieDomain) credentials match { @@ -322,7 +322,7 @@ trait Authenticator { @deprecated("Please use: getUserADM()", "Knora v1.7.0") def getUserProfileV1(requestContext: RequestContext)(implicit system: ActorSystem, responderManager: ActorRef, executionContext: ExecutionContext): Future[UserProfileV1] = { - val settings = Settings(system) + val settings = KnoraSettings(system) val credentials: Option[KnoraCredentialsV2] = extractCredentialsV2(requestContext) @@ -356,7 +356,7 @@ trait Authenticator { */ def getUserADM(requestContext: RequestContext)(implicit system: ActorSystem, responderManager: ActorRef, executionContext: ExecutionContext): Future[UserADM] = { - val settings = Settings(system) + val settings = KnoraSettings(system) val credentials: Option[KnoraCredentialsV2] = extractCredentialsV2(requestContext) @@ -418,7 +418,7 @@ object Authenticator { def authenticateCredentialsV2(credentials: Option[KnoraCredentialsV2])(implicit system: ActorSystem, responderManager: ActorRef, executionContext: ExecutionContext): Future[Boolean] = { for { - settings <- FastFuture.successful(Settings(system)) + settings <- FastFuture.successful(KnoraSettings(system)) result <- credentials match { case Some(passCreds: KnoraPasswordCredentialsV2) => { @@ -645,7 +645,7 @@ object Authenticator { */ private def getUserADMThroughCredentialsV2(credentials: Option[KnoraCredentialsV2])(implicit system: ActorSystem, responderManager: ActorRef, executionContext: ExecutionContext): Future[UserADM] = { - val settings = Settings(system) + val settings = KnoraSettings(system) for { authenticated <- authenticateCredentialsV2(credentials) diff --git a/webapi/src/main/scala/org/knora/webapi/routing/KnoraRoute.scala b/webapi/src/main/scala/org/knora/webapi/routing/KnoraRoute.scala index a82a09fa09..dab0adb4c1 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/KnoraRoute.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/KnoraRoute.scala @@ -25,7 +25,7 @@ import akka.http.scaladsl.server.Route import akka.stream.Materializer import akka.util.Timeout import org.knora.webapi.util.StringFormatter -import org.knora.webapi.{KnoraDispatchers, Settings, SettingsImpl} +import org.knora.webapi.{KnoraDispatchers, KnoraSettings, KnoraSettingsImpl} import scala.concurrent.ExecutionContext @@ -46,7 +46,7 @@ case class KnoraRouteData(system: ActorSystem, abstract class KnoraRoute(routeData: KnoraRouteData) { implicit protected val system: ActorSystem = routeData.system - implicit protected val settings: SettingsImpl = Settings(system) + implicit protected val settings: KnoraSettingsImpl = KnoraSettings(system) implicit protected val timeout: Timeout = settings.defaultTimeout implicit protected val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) implicit protected val materializer: Materializer = Materializer.matFromSystem(system) diff --git a/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilADM.scala b/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilADM.scala index 03f0ba9f34..12677a3083 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilADM.scala @@ -50,7 +50,7 @@ object RouteUtilADM { */ def runJsonRoute(requestMessageF: Future[KnoraRequestADM], requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter) (implicit timeout: Timeout, executionContext: ExecutionContext): Future[RouteResult] = { diff --git a/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV1.scala b/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV1.scala index 979a34d4ef..e2bbb1a1d7 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV1.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV1.scala @@ -56,7 +56,7 @@ object RouteUtilV1 { */ def runJsonRoute(requestMessage: KnoraRequestV1, requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter) (implicit timeout: Timeout, executionContext: ExecutionContext): Future[RouteResult] = { @@ -109,7 +109,7 @@ object RouteUtilV1 { */ def runJsonRouteWithFuture[RequestMessageT <: KnoraRequestV1](requestMessageF: Future[RequestMessageT], requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter) (implicit timeout: Timeout, executionContext: ExecutionContext): Future[RouteResult] = { @@ -142,7 +142,7 @@ object RouteUtilV1 { def runHtmlRoute[RequestMessageT <: KnoraRequestV1, ReplyMessageT <: KnoraResponseV1 : ClassTag](requestMessageF: Future[RequestMessageT], viewHandler: (ReplyMessageT, ActorRef) => String, requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter) (implicit timeout: Timeout, executionContext: ExecutionContext): Future[RouteResult] = { @@ -204,7 +204,7 @@ object RouteUtilV1 { mappingIri: IRI, acceptStandoffLinksToClientIDs: Boolean, userProfile: UserADM, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter)(implicit timeout: Timeout, executionContext: ExecutionContext): Future[TextWithStandoffTagsV2] = { diff --git a/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV2.scala b/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV2.scala index 7dd1d60a9f..affc835319 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/RouteUtilV2.scala @@ -192,7 +192,7 @@ object RouteUtilV2 { */ private def runRdfRoute(requestMessage: KnoraRequestV2, requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter, targetSchema: ApiV2Schema, @@ -252,7 +252,7 @@ object RouteUtilV2 { */ def runTEIXMLRoute(requestMessageF: Future[KnoraRequestV2], requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter, targetSchema: ApiV2Schema) @@ -301,7 +301,7 @@ object RouteUtilV2 { */ def runRdfRouteWithFuture(requestMessageF: Future[KnoraRequestV2], requestContext: RequestContext, - settings: SettingsImpl, + settings: KnoraSettingsImpl, responderManager: ActorRef, log: LoggingAdapter, targetSchema: ApiV2Schema, @@ -387,7 +387,7 @@ object RouteUtilV2 { responseMediaType: MediaType.NonBinary, targetSchema: ApiV2Schema, schemaOptions: Set[SchemaOption], - settings: SettingsImpl): HttpResponse = { + settings: KnoraSettingsImpl): HttpResponse = { // Find the most specific media type that is compatible with the one requested. val specificMediaType = RdfMediaTypes.toMostSpecificMediaType(responseMediaType) diff --git a/webapi/src/main/scala/org/knora/webapi/store/StoreManager.scala b/webapi/src/main/scala/org/knora/webapi/store/StoreManager.scala index 0ccee5df68..0135703576 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/StoreManager.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/StoreManager.scala @@ -55,7 +55,7 @@ class StoreManager(appActor: ActorRef) extends Actor with ActorLogging { /** * The Knora settings. */ - protected val settings: SettingsImpl = Settings(system) + protected val settings: KnoraSettingsImpl = KnoraSettings(system) /** * Starts the Triplestore Manager Actor diff --git a/webapi/src/main/scala/org/knora/webapi/store/cacheservice/CacheServiceManager.scala b/webapi/src/main/scala/org/knora/webapi/store/cacheservice/CacheServiceManager.scala index f3112e6c1c..d5b4738bea 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/cacheservice/CacheServiceManager.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/cacheservice/CacheServiceManager.scala @@ -51,7 +51,7 @@ class CacheServiceManager extends Actor with ActorLogging with LazyLogging with /** * The Knora settings. */ - protected val s: SettingsImpl = Settings(context.system) + protected val s: KnoraSettingsImpl = KnoraSettings(context.system) /** * The Redis Client Pool diff --git a/webapi/src/main/scala/org/knora/webapi/store/iiif/SipiConnector.scala b/webapi/src/main/scala/org/knora/webapi/store/iiif/SipiConnector.scala index 504e581d99..769708c12b 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/iiif/SipiConnector.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/iiif/SipiConnector.scala @@ -39,7 +39,7 @@ import org.knora.webapi.messages.v2.responder.SuccessResponseV2 import org.knora.webapi.routing.JWTHelper import org.knora.webapi.util.ActorUtil.{handleUnexpectedMessage, try2Message} import org.knora.webapi.util.{SipiUtil, StringFormatter} -import org.knora.webapi.{BadRequestException, KnoraDispatchers, NotImplementedException, Settings, SipiException} +import org.knora.webapi.{BadRequestException, KnoraDispatchers, NotImplementedException, KnoraSettings, SipiException} import spray.json._ import scala.concurrent.ExecutionContext @@ -53,7 +53,7 @@ class SipiConnector extends Actor with ActorLogging { implicit val system: ActorSystem = context.system implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) - private val settings = Settings(system) + private val settings = KnoraSettings(system) implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala index a6bfe457e2..742f5d44a6 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala @@ -42,7 +42,7 @@ import scala.concurrent.ExecutionContext class TriplestoreManager(appActor: ActorRef) extends Actor with ActorLogging { this: ActorMaker => - private val settings = Settings(context.system) + private val settings = KnoraSettings(context.system) protected implicit val executionContext: ExecutionContext = context.system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) private var storeActorRef: ActorRef = _ diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/embedded/JenaTDBActor.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/embedded/JenaTDBActor.scala index 39e5e4e0e3..1e84c3ee4c 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/embedded/JenaTDBActor.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/embedded/JenaTDBActor.scala @@ -48,7 +48,7 @@ class JenaTDBActor extends Actor with ActorLogging { private val system = context.system private implicit val executionContext = system.dispatcher - private val settings = Settings(system) + private val settings = KnoraSettings(system) private val persist = settings.tripleStoreConfig.getBoolean("embedded-jena-tdb.persisted") diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/GraphProtocolAccessor.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/GraphProtocolAccessor.scala index b95e3a8d01..65d61b47a0 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/GraphProtocolAccessor.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/GraphProtocolAccessor.scala @@ -82,7 +82,7 @@ object GraphProtocolAccessor { private def execute(method: String, graphName: String, filepath: String)(implicit _system: ActorSystem, materializer: Materializer): StatusCode = { val log = akka.event.Logging(_system, this.getClass) - val settings = Settings(_system) + val settings = KnoraSettings(_system) implicit val executionContext: ExecutionContext = _system.dispatchers.lookup(KnoraDispatchers.KnoraBlockingDispatcher) log.debug("GraphProtocolAccessor - execute started") diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala index 918fab7d66..396e655942 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala @@ -70,7 +70,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat private val mimeTypeApplicationTrig = "application/trig" private implicit val system: ActorSystem = context.system - private val settings = Settings(system) + private val settings = KnoraSettings(system) implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraBlockingDispatcher) private implicit val materializer: Materializer = Materializer.matFromSystem(system) override val log: LoggingAdapter = akka.event.Logging(system, this.getClass.getName) @@ -823,7 +823,6 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat triplestoreResponseTry.recover { case tre: TriplestoreResponseException => throw tre - case e: Exception => log.error(e, s"Failed to connect to triplestore, SPARQL query was:\n$sparql") throw TriplestoreConnectionException(s"Failed to connect to triplestore", e, log) diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdater.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdater.scala index 9c4e5d64dc..c4ac545b2a 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdater.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdater.scala @@ -15,7 +15,7 @@ import org.eclipse.rdf4j.rio.{RDFFormat, RDFParser, Rio} import org.knora.webapi.messages.store.triplestoremessages._ import org.knora.webapi.store.triplestore.upgrade.RepositoryUpdatePlan.PluginForKnoraBaseVersion import org.knora.webapi.util.{FileUtil, StringFormatter} -import org.knora.webapi.{InconsistentTriplestoreDataException, KnoraDispatchers, SettingsImpl} +import org.knora.webapi.{InconsistentTriplestoreDataException, KnoraDispatchers, KnoraSettingsImpl} import scala.collection.JavaConverters._ import scala.concurrent.{ExecutionContext, Future} @@ -29,7 +29,7 @@ import scala.concurrent.{ExecutionContext, Future} */ class RepositoryUpdater(system: ActorSystem, appActor: ActorRef, - settings: SettingsImpl) extends LazyLogging { + settings: KnoraSettingsImpl) extends LazyLogging { private val knoraBaseVersionQuery = """PREFIX knora-base: diff --git a/webapi/src/main/scala/org/knora/webapi/util/ConstructResponseUtilV2.scala b/webapi/src/main/scala/org/knora/webapi/util/ConstructResponseUtilV2.scala index 988af56bbb..3b76b091e9 100644 --- a/webapi/src/main/scala/org/knora/webapi/util/ConstructResponseUtilV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/util/ConstructResponseUtilV2.scala @@ -947,7 +947,7 @@ object ConstructResponseUtilV2 { versionDate: Option[Instant], responderManager: ActorRef, targetSchema: ApiV2Schema, - settings: SettingsImpl, + settings: KnoraSettingsImpl, requestingUser: UserADM)(implicit stringFormatter: StringFormatter, timeout: Timeout, executionContext: ExecutionContext): Future[LinkValueContentV2] = { val referredResourceIri: IRI = if (valueObject.isIncomingLink) { valueObject.requireIriObject(OntologyConstants.Rdf.Subject.toSmartIri) @@ -1009,7 +1009,7 @@ object ConstructResponseUtilV2 { versionDate: Option[Instant] = None, responderManager: ActorRef, targetSchema: ApiV2Schema, - settings: SettingsImpl, + settings: KnoraSettingsImpl, requestingUser: UserADM)(implicit stringFormatter: StringFormatter, timeout: Timeout, executionContext: ExecutionContext): Future[ValueContentV2] = { // every knora-base:Value (any of its subclasses) has a string representation, but it is not necessarily returned with text values. val valueObjectValueHasString: Option[String] = valueObject.maybeStringObject(OntologyConstants.KnoraBase.ValueHasString.toSmartIri) @@ -1187,7 +1187,7 @@ object ConstructResponseUtilV2 { versionDate: Option[Instant], responderManager: ActorRef, targetSchema: ApiV2Schema, - settings: SettingsImpl, + settings: KnoraSettingsImpl, requestingUser: UserADM)(implicit stringFormatter: StringFormatter, timeout: Timeout, executionContext: ExecutionContext): Future[ReadResourceV2] = { def getDeletionInfo(rdfData: RdfData): Option[DeletionInfo] = { val isDeleted: Boolean = rdfData.requireBooleanObject(OntologyConstants.KnoraBase.IsDeleted.toSmartIri) @@ -1342,7 +1342,7 @@ object ConstructResponseUtilV2 { versionDate: Option[Instant], responderManager: ActorRef, targetSchema: ApiV2Schema, - settings: SettingsImpl, + settings: KnoraSettingsImpl, requestingUser: UserADM)(implicit stringFormatter: StringFormatter, timeout: Timeout, executionContext: ExecutionContext): Future[ReadResourcesSequenceV2] = { val visibleResourceIris: Seq[IRI] = orderByResourceIri.filter(resourceIri => mainResourcesAndValueRdfData.resources.keySet.contains(resourceIri)) diff --git a/webapi/src/main/scala/org/knora/webapi/util/FileUtil.scala b/webapi/src/main/scala/org/knora/webapi/util/FileUtil.scala index 4bc7be1fdd..890a6ff203 100644 --- a/webapi/src/main/scala/org/knora/webapi/util/FileUtil.scala +++ b/webapi/src/main/scala/org/knora/webapi/util/FileUtil.scala @@ -25,7 +25,7 @@ import java.nio.file.{Files, Paths} import java.util.zip.{ZipEntry, ZipOutputStream} import com.typesafe.scalalogging.Logger -import org.knora.webapi.{FileWriteException, NotFoundException, SettingsImpl} +import org.knora.webapi.{FileWriteException, NotFoundException, KnoraSettingsImpl} import resource._ import scala.io.{BufferedSource, Codec, Source} @@ -136,7 +136,7 @@ object FileUtil { * @param binaryData the binary file data to be saved. * @return the location where the file has been written to. */ - def saveFileToTmpLocation(settings: SettingsImpl, binaryData: Array[Byte]): File = { + def saveFileToTmpLocation(settings: KnoraSettingsImpl, binaryData: Array[Byte]): File = { val fileName = createTempFile(settings) // write given file to disk @@ -152,7 +152,7 @@ object FileUtil { * @param fileExtension the extension to be used for the temporary file name, if any, * @return the location where the file has been written to. */ - def createTempFile(settings: SettingsImpl, fileExtension: Option[String] = None): File = { + def createTempFile(settings: KnoraSettingsImpl, fileExtension: Option[String] = None): File = { // check if the location for writing temporary files exists if (!Files.exists(Paths.get(settings.tmpDataDir))) { diff --git a/webapi/src/main/scala/org/knora/webapi/util/StringFormatter.scala b/webapi/src/main/scala/org/knora/webapi/util/StringFormatter.scala index 27b3b63043..05bf8c2872 100644 --- a/webapi/src/main/scala/org/knora/webapi/util/StringFormatter.scala +++ b/webapi/src/main/scala/org/knora/webapi/util/StringFormatter.scala @@ -302,7 +302,7 @@ object StringFormatter { * * @param settings the application settings. */ - def init(settings: SettingsImpl): Unit = { + def init(settings: KnoraSettingsImpl): Unit = { this.synchronized { generalInstance match { case Some(_) => () @@ -661,7 +661,7 @@ object IriConversions { /** * Handles string parsing, formatting, conversion, and validation. */ -class StringFormatter private(val maybeSettings: Option[SettingsImpl] = None, maybeKnoraHostAndPort: Option[String] = None, initForTest: Boolean = false) { +class StringFormatter private(val maybeSettings: Option[KnoraSettingsImpl] = None, maybeKnoraHostAndPort: Option[String] = None, initForTest: Boolean = false) { import StringFormatter._ diff --git a/webapi/src/main/scala/org/knora/webapi/util/standoff/StandoffTagUtilV2.scala b/webapi/src/main/scala/org/knora/webapi/util/standoff/StandoffTagUtilV2.scala index 1ba8087175..846e7ce9e1 100644 --- a/webapi/src/main/scala/org/knora/webapi/util/standoff/StandoffTagUtilV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/util/standoff/StandoffTagUtilV2.scala @@ -1129,7 +1129,7 @@ object StandoffTagUtilV2 { * @return a tuple containing the minimum start index and maximum start index, or `(None, None)` if standoff * is not being queried with text values. */ - def getStandoffMinAndMaxStartIndexesForTextValueQuery(queryStandoff: Boolean, settings: SettingsImpl): (Option[Int], Option[Int]) = { + def getStandoffMinAndMaxStartIndexesForTextValueQuery(queryStandoff: Boolean, settings: KnoraSettingsImpl): (Option[Int], Option[Int]) = { if (queryStandoff) { // Yes. Get the first page of standoff with each text value. (Some(0), Some(settings.standoffPerPage - 1)) diff --git a/webapi/src/test/resources/logback-test.xml b/webapi/src/test/resources/logback-test.xml index 8fdc8a26d9..de7c78ce0a 100644 --- a/webapi/src/test/resources/logback-test.xml +++ b/webapi/src/test/resources/logback-test.xml @@ -52,6 +52,9 @@ + + + @@ -107,6 +110,9 @@ + + + @@ -122,7 +128,7 @@ - + diff --git a/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala b/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala index f130f2c55e..7eb20a8721 100644 --- a/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/CoreSpec.scala @@ -33,10 +33,12 @@ import org.knora.webapi.messages.store.triplestoremessages.{RdfDataObject, Reset import org.knora.webapi.messages.v1.responder.ontologymessages.LoadOntologiesRequest import org.knora.webapi.responders.ResponderData import org.knora.webapi.util.{StartupUtils, StringFormatter} -import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import scala.concurrent.duration._ -import scala.concurrent.{Await, ExecutionContext, Future} +import scala.concurrent.{Await, ExecutionContext} import scala.language.postfixOps object CoreSpec { @@ -61,7 +63,7 @@ object CoreSpec { } } -abstract class CoreSpec(_system: ActorSystem) extends TestKit(_system) with Core with StartupUtils with WordSpecLike with Matchers with BeforeAndAfterAll with ImplicitSender { +abstract class CoreSpec(_system: ActorSystem) extends TestKit(_system) with Core with StartupUtils with AnyWordSpecLike with Matchers with BeforeAndAfterAll with ImplicitSender { /* constructors - individual tests can override the configuration by giving their own */ def this(name: String, config: Config) = this(ActorSystem(name, ConfigFactory.load(config.withFallback(CoreSpec.defaultConfig)))) @@ -70,7 +72,7 @@ abstract class CoreSpec(_system: ActorSystem) extends TestKit(_system) with Core def this() = this(ActorSystem(CoreSpec.getCallerName(getClass), ConfigFactory.load())) /* needed by the core trait */ - implicit lazy val settings: SettingsImpl = Settings(system) + implicit lazy val settings: KnoraSettingsImpl = KnoraSettings(system) implicit val materializer: Materializer = Materializer.matFromSystem(system) implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) diff --git a/webapi/src/test/scala/org/knora/webapi/E2ESimSpec.scala b/webapi/src/test/scala/org/knora/webapi/E2ESimSpec.scala index f6f3bd5eca..92fa560cc5 100644 --- a/webapi/src/test/scala/org/knora/webapi/E2ESimSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/E2ESimSpec.scala @@ -64,7 +64,7 @@ abstract class E2ESimSpec(_system: ActorSystem) extends Simulation with Core wit /* needed by the core trait */ implicit lazy val system: ActorSystem = _system - implicit lazy val settings: SettingsImpl = Settings(system) + implicit lazy val settings: KnoraSettingsImpl = KnoraSettings(system) implicit val materializer: Materializer = Materializer.matFromSystem(system) implicit val executionContext: ExecutionContext = system.dispatchers.defaultGlobalDispatcher diff --git a/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala b/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala index 4afedd262b..80ea832d04 100644 --- a/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/E2ESpec.scala @@ -37,7 +37,9 @@ import org.knora.webapi.messages.app.appmessages.{AppStart, AppStop, SetAllowRel import org.knora.webapi.messages.store.triplestoremessages.{RdfDataObject, TriplestoreJsonProtocol} import org.knora.webapi.util.jsonld.{JsonLDDocument, JsonLDUtil} import org.knora.webapi.util.{FileUtil, StartupUtils, StringFormatter} -import org.scalatest.{BeforeAndAfterAll, Matchers, Suite, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike +import org.scalatest.{BeforeAndAfterAll, Suite} import resource.managed import spray.json._ @@ -54,7 +56,7 @@ object E2ESpec { * This class can be used in End-to-End testing. It starts the Knora-API server * and provides access to settings and logging. */ -class E2ESpec(_system: ActorSystem) extends Core with StartupUtils with TriplestoreJsonProtocol with Suite with WordSpecLike with Matchers with BeforeAndAfterAll with RequestBuilding with LazyLogging { +class E2ESpec(_system: ActorSystem) extends Core with StartupUtils with TriplestoreJsonProtocol with Suite with AnyWordSpecLike with Matchers with BeforeAndAfterAll with RequestBuilding with LazyLogging { /* constructors */ def this(name: String, config: Config) = this(ActorSystem(name, config.withFallback(E2ESpec.defaultConfig))) @@ -68,7 +70,7 @@ class E2ESpec(_system: ActorSystem) extends Core with StartupUtils with Triplest /* needed by the core trait */ implicit lazy val system: ActorSystem = _system - implicit lazy val settings: SettingsImpl = Settings(system) + implicit lazy val settings: KnoraSettingsImpl = KnoraSettings(system) implicit val materializer: Materializer = Materializer.matFromSystem(system) implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) diff --git a/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala b/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala index f3eb418231..4404f1ea43 100644 --- a/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/R2RSpec.scala @@ -21,22 +21,25 @@ package org.knora.webapi import java.io.{File, StringReader} -import akka.pattern.ask import akka.actor.{ActorRef, ActorSystem, Props} import akka.http.scaladsl.model.HttpResponse import akka.http.scaladsl.server.ExceptionHandler import akka.http.scaladsl.testkit.ScalatestRouteTest +import akka.pattern.ask import akka.util.Timeout import com.typesafe.scalalogging.LazyLogging import org.eclipse.rdf4j.model.Model import org.eclipse.rdf4j.rio.{RDFFormat, Rio} import org.knora.webapi.app.{APPLICATION_MANAGER_ACTOR_NAME, ApplicationActor, LiveManagers} +import org.knora.webapi.messages.app.appmessages.AppReady import org.knora.webapi.messages.store.triplestoremessages.{RdfDataObject, ResetRepositoryContent} import org.knora.webapi.messages.v1.responder.ontologymessages.LoadOntologiesRequest import org.knora.webapi.routing.KnoraRouteData import org.knora.webapi.util.jsonld.{JsonLDDocument, JsonLDUtil} import org.knora.webapi.util.{CacheUtil, FileUtil, StringFormatter} -import org.scalatest.{BeforeAndAfterAll, Matchers, Suite, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike +import org.scalatest.{BeforeAndAfterAll, Suite} import scala.concurrent.duration._ import scala.concurrent.{Await, Future} @@ -44,11 +47,11 @@ import scala.language.postfixOps /** * Created by subotic on 08.12.15. */ -class R2RSpec extends Suite with ScalatestRouteTest with WordSpecLike with Matchers with BeforeAndAfterAll with LazyLogging { +class R2RSpec extends Suite with ScalatestRouteTest with AnyWordSpecLike with Matchers with BeforeAndAfterAll with LazyLogging { def actorRefFactory: ActorSystem = system - val settings: SettingsImpl = Settings(system) + val settings: KnoraSettingsImpl = KnoraSettings(system) StringFormatter.initForTest() implicit val knoraExceptionHandler: ExceptionHandler = KnoraExceptionHandler(settings) @@ -69,6 +72,8 @@ class R2RSpec extends Suite with ScalatestRouteTest with WordSpecLike with Match lazy val rdfDataObjects = List.empty[RdfDataObject] override def beforeAll { + // changes the state and behaviour of the ApplicationActor to Ready + appActor ! AppReady() CacheUtil.createCaches(settings.caches) loadTestData(rdfDataObjects) } diff --git a/webapi/src/test/scala/org/knora/webapi/e2e/v1/CORSSupportV1E2ESpec.scala b/webapi/src/test/scala/org/knora/webapi/e2e/CORSSupportE2ESpec.scala similarity index 58% rename from webapi/src/test/scala/org/knora/webapi/e2e/v1/CORSSupportV1E2ESpec.scala rename to webapi/src/test/scala/org/knora/webapi/e2e/CORSSupportE2ESpec.scala index f37473b036..eb90c0ccec 100644 --- a/webapi/src/test/scala/org/knora/webapi/e2e/v1/CORSSupportV1E2ESpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/e2e/CORSSupportE2ESpec.scala @@ -17,82 +17,62 @@ * License along with Knora. If not, see . */ -package org.knora.webapi.e2e.v1 +package org.knora.webapi.e2e import akka.actor.ActorSystem import akka.http.scaladsl.model.HttpMethods._ -import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.model.headers.{`Access-Control-Allow-Methods`, _} +import akka.http.scaladsl.model.{HttpResponse, StatusCodes} import akka.http.scaladsl.testkit.RouteTestTimeout -import akka.http.scaladsl.unmarshalling.Unmarshal import com.typesafe.config.ConfigFactory import org.knora.webapi.E2ESpec -import org.knora.webapi.http.CORSSupport -import org.knora.webapi.messages.store.triplestoremessages.{RdfDataObject, TriplestoreJsonProtocol} -import org.knora.webapi.testing.tags.E2ETest +import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject -import scala.concurrent.Await -import scala.concurrent.duration._ - -object CORSSupportV1E2ESpec { +object CORSSupportE2ESpec { val config = ConfigFactory.parseString( """ - akka.loglevel = "DEBUG" - akka.stdout-loglevel = "DEBUG" + akka.loglevel = "DEBUG" + akka.stdout-loglevel = "DEBUG" """.stripMargin) } /** - * End-to-end test specification for testing [[CORSSupport]]. - */ -@E2ETest -class CORSSupportV1E2ESpec extends E2ESpec(CORSSupportV1E2ESpec.config) with TriplestoreJsonProtocol { + * End-to-end test specification for testing [[CORSSupport]]. + */ +class CORSSupportE2ESpec extends E2ESpec(CORSSupportE2ESpec.config) { - /* set the timeout for the route test */ implicit def default(implicit system: ActorSystem) = RouteTestTimeout(settings.defaultTimeout) - private val exampleOrigin = HttpOrigin("http://example.com") - private val corsSettings = CORSSupport.corsSettings - override lazy val rdfDataObjects = List( - RdfDataObject(path = "_test_data/all_data/incunabula-data.ttl", name = "http://www.knora.org/data/0803/incunabula"), - RdfDataObject(path = "_test_data/demo_data/images-demo-data.ttl", name = "http://www.knora.org/data/00FF/images") + RdfDataObject(path = "_test_data/all_data/anything-data.ttl", name = "http://www.knora.org/data/0001/anything") ) - "A Route with enabled CORS support " should { - - "accept valid pre-flight requests" in { - - val request = Options(baseApiUrl + "/v1/authenticate") ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) - val response = singleAwaitingRequest(request) + val exampleOrigin = HttpOrigin("http://example.com") - response.status should equal(StatusCodes.OK) + "A Route with enabled CORS support" should { - val headersMinusDate = response.headers.filter(Date => false) + "accept valid pre-flight requests" in { + val request = Options(baseApiUrl + s"/admin/projects") ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) + val response: HttpResponse = singleAwaitingRequest(request) + response.status shouldBe StatusCodes.OK response.headers should contain allElementsOf Seq( `Access-Control-Allow-Origin`(exampleOrigin), - `Access-Control-Allow-Methods`(corsSettings.allowedMethods), - //`Access-Control-Allow-Headers`("Origin, X-Requested-With, Content-Type, Accept, Authorization"), + `Access-Control-Allow-Methods`(List(GET, PUT, POST, DELETE, HEAD, OPTIONS)), `Access-Control-Max-Age`(1800), `Access-Control-Allow-Credentials`(true) ) } - "reject pre-flight requests with invalid method" in { - val invalidMethod = PATCH - val request = Options(baseApiUrl + "/v1/authenticate") ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(invalidMethod) - val response = singleAwaitingRequest(request) - - val entity = Await.result(Unmarshal(response.entity).to[String], 1.seconds) - - response.status should equal(StatusCodes.BadRequest) - entity should equal("CORS: invalid method 'PATCH'") + "reject requests with invalid method" in { + val request = Options(baseApiUrl + s"/admin/projects") ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(PATCH) + val response: HttpResponse = singleAwaitingRequest(request) + responseToString(response) shouldEqual "CORS: invalid method 'PATCH'" + response.status shouldBe StatusCodes.BadRequest } "send `Access-Control-Allow-Origin` header when the Knora resource is found " in { - val request = Get(baseApiUrl + "/v1/resources/" + java.net.URLEncoder.encode("http://rdfh.ch/00FF/0cb8286054d5", "utf-8")) ~> Origin(exampleOrigin) + val request = Get(baseApiUrl + "/v1/resources/" + java.net.URLEncoder.encode("http://rdfh.ch/0001/55UrkgTKR2SEQgnsLWI9mg", "utf-8")) ~> Origin(exampleOrigin) val response = singleAwaitingRequest(request) - response.status should equal(StatusCodes.OK) response.headers should contain allElementsOf Seq( `Access-Control-Allow-Origin`(exampleOrigin) @@ -102,7 +82,6 @@ class CORSSupportV1E2ESpec extends E2ESpec(CORSSupportV1E2ESpec.config) with Tri "send `Access-Control-Allow-Origin` header when the Knora resource is NOT found " in { val request = Get(baseApiUrl + "/v1/resources/" + java.net.URLEncoder.encode("http://rdfh.ch/0803/nonexistent", "utf-8")) ~> Origin(exampleOrigin) val response = singleAwaitingRequest(request) - response.status should equal(StatusCodes.NotFound) response.headers should contain allElementsOf Seq( `Access-Control-Allow-Origin`(exampleOrigin) @@ -112,7 +91,6 @@ class CORSSupportV1E2ESpec extends E2ESpec(CORSSupportV1E2ESpec.config) with Tri "send `Access-Control-Allow-Origin` header when the api endpoint route is NOT found " in { val request = Get(baseApiUrl + "/NotFound") ~> Origin(exampleOrigin) val response = singleAwaitingRequest(request) - response.status should equal(StatusCodes.NotFound) response.headers should contain allElementsOf Seq( `Access-Control-Allow-Origin`(exampleOrigin) diff --git a/webapi/src/test/scala/org/knora/webapi/http/CORSSupportV1R2RSpec.scala b/webapi/src/test/scala/org/knora/webapi/http/CORSSupportV1R2RSpec.scala deleted file mode 100644 index c5208c5fda..0000000000 --- a/webapi/src/test/scala/org/knora/webapi/http/CORSSupportV1R2RSpec.scala +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2015-2019 the contributors (see Contributors.md). - * - * This file is part of Knora. - * - * Knora is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Knora is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with Knora. If not, see . - */ - -package org.knora.webapi.http - -import akka.actor.ActorSystem -import akka.http.scaladsl.model.HttpMethods._ -import akka.http.scaladsl.model.StatusCodes -import akka.http.scaladsl.model.headers.{`Access-Control-Allow-Methods`, _} -import akka.http.scaladsl.server.Route -import akka.http.scaladsl.testkit.RouteTestTimeout -import org.knora.webapi.R2RSpec -import org.knora.webapi.http.CORSSupport.CORS -import org.knora.webapi.http.ServerVersion.addServerHeader -import org.knora.webapi.routing.v1.ResourcesRouteV1 - -/** - * End-to-end test specification for testing [[CORSSupport]]. - */ -class CORSSupportV1R2RSpec extends R2RSpec { - - /* get the path of the route we want to test */ - private val sealedResourcesRoute = Route.seal(new ResourcesRouteV1(routeData).knoraApiPath) - - implicit def default(implicit system: ActorSystem) = RouteTestTimeout(settings.defaultTimeout) - - val exampleOrigin = HttpOrigin("http://example.com") - val corsSettings = CORSSupport.corsSettings - - "A Route with enabled CORS support" should { - - "accept valid pre-flight requests" in { - - Options() ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(GET) ~> { - addServerHeader(CORS(sealedResourcesRoute, settings)) - } ~> check { - responseAs[String] shouldBe empty - status shouldBe StatusCodes.OK - response.headers should contain allElementsOf Seq( - `Access-Control-Allow-Origin`(exampleOrigin), - `Access-Control-Allow-Methods`(CORSSupport.allowedMethods), - // `Access-Control-Allow-Headers`(CORSSupport.exposedHeaders), - `Access-Control-Max-Age`(1800), - `Access-Control-Allow-Credentials`(true) - ) - } - } - - "reject pre-flight requests with invalid method" in { - - val invalidMethod = PATCH - Options() ~> Origin(exampleOrigin) ~> `Access-Control-Request-Method`(invalidMethod) ~> { - CORS(sealedResourcesRoute, settings) - } ~> check { - status shouldBe StatusCodes.BadRequest - entityAs[String] should equal("CORS: invalid method 'PATCH'") - } - } - - } -} diff --git a/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListsMessagesADMSpec.scala b/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListsMessagesADMSpec.scala index dc8abc4361..f78602f135 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListsMessagesADMSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/listsmessages/ListsMessagesADMSpec.scala @@ -22,13 +22,14 @@ package org.knora.webapi.messages.admin.responder.listsmessages import org.knora.webapi.messages.store.triplestoremessages.{StringLiteralSequenceV2, StringLiteralV2} import org.knora.webapi.responders.admin.ListsResponderADM._ import org.knora.webapi.{BadRequestException, SharedListsTestDataADM, SharedTestDataADM} -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import spray.json._ /** * This spec is used to test 'ListAdminMessages'. */ -class ListsMessagesADMSpec extends WordSpecLike with Matchers with ListADMJsonProtocol { +class ListsMessagesADMSpec extends AnyWordSpecLike with Matchers with ListADMJsonProtocol { val exampleListIri = "http://rdfh.ch/lists/00FF/abcd" diff --git a/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/permissionsmessages/PermissionsMessagesADMSpec.scala b/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/permissionsmessages/PermissionsMessagesADMSpec.scala index 6216ed52c0..cea5a6ea8f 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/permissionsmessages/PermissionsMessagesADMSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/permissionsmessages/PermissionsMessagesADMSpec.scala @@ -23,12 +23,13 @@ import org.knora.webapi.SharedOntologyTestDataADM._ import org.knora.webapi.SharedTestDataV1._ import org.knora.webapi._ import org.knora.webapi.messages.v1.responder.usermessages.UsersResponderRequestV1 -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike /** * This spec is used to test subclasses of the [[UsersResponderRequestV1]] class. */ -class PermissionsMessagesADMSpec extends WordSpecLike with Matchers { +class PermissionsMessagesADMSpec extends AnyWordSpecLike with Matchers { "querying the user's 'PermissionsDataADM' with 'hasPermissionFor'" should { diff --git a/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala b/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala index cef5f6c0e0..e22a42de64 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala @@ -22,14 +22,15 @@ package org.knora.webapi.messages.admin.responder.usersmessages import org.knora.webapi._ import org.knora.webapi.messages.admin.responder.permissionsmessages.{PermissionDataType, PermissionsDataADM} import org.knora.webapi.util.StringFormatter -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder /** * This spec is used to test subclasses of the [[org.knora.webapi.messages.v1.responder.usermessages.UsersResponderRequestV1]] class. */ -class UsersMessagesADMSpec extends WordSpecLike with Matchers { +class UsersMessagesADMSpec extends AnyWordSpecLike with Matchers { private val id = SharedTestDataADM.rootUser.id private val username = SharedTestDataADM.rootUser.username diff --git a/webapi/src/test/scala/org/knora/webapi/messages/store/triplestoremessages/TriplestoreMessagesSpec.scala b/webapi/src/test/scala/org/knora/webapi/messages/store/triplestoremessages/TriplestoreMessagesSpec.scala index 394df3e38b..4d5f0f93ef 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/store/triplestoremessages/TriplestoreMessagesSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/store/triplestoremessages/TriplestoreMessagesSpec.scala @@ -20,13 +20,14 @@ package org.knora.webapi.messages.store.triplestoremessages import org.knora.webapi.messages.admin.responder.listsmessages._ -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import spray.json._ /** * This spec is used to test 'ListAdminMessages'. */ -class TriplestoreMessagesSpec extends WordSpecLike with Matchers with ListADMJsonProtocol { +class TriplestoreMessagesSpec extends AnyWordSpecLike with Matchers with ListADMJsonProtocol { "Conversion from case class to JSON and back" should { diff --git a/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/permissionmessages/PermissionMessagesV1Spec.scala b/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/permissionmessages/PermissionMessagesV1Spec.scala index 8e3a71f2fd..2861bdb8a3 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/permissionmessages/PermissionMessagesV1Spec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/permissionmessages/PermissionMessagesV1Spec.scala @@ -5,12 +5,13 @@ import org.knora.webapi.SharedTestDataV1._ import org.knora.webapi._ import org.knora.webapi.messages.admin.responder.permissionsmessages.ResourceCreateOperation import org.knora.webapi.messages.v1.responder.usermessages.UsersResponderRequestV1 -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike /** * This spec is used to test subclasses of the [[UsersResponderRequestV1]] class. */ -class PermissionMessagesV1Spec extends WordSpecLike with Matchers { +class PermissionMessagesV1Spec extends AnyWordSpecLike with Matchers { "querying the user's 'PermissionProfileV1' with 'hasPermissionFor'" should { diff --git a/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/usermessages/UserMessagesV1Spec.scala b/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/usermessages/UserMessagesV1Spec.scala index d29ff2ae9f..1b598599ab 100644 --- a/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/usermessages/UserMessagesV1Spec.scala +++ b/webapi/src/test/scala/org/knora/webapi/messages/v1/responder/usermessages/UserMessagesV1Spec.scala @@ -22,14 +22,15 @@ package org.knora.webapi.messages.v1.responder.usermessages import org.knora.webapi._ import org.knora.webapi.messages.admin.responder.permissionsmessages import org.knora.webapi.messages.admin.responder.permissionsmessages.PermissionDataType -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder /** * This spec is used to test subclasses of the [[UsersResponderRequestV1]] class. */ -class UserMessagesV1Spec extends WordSpecLike with Matchers { +class UserMessagesV1Spec extends AnyWordSpecLike with Matchers { private val lang = SharedTestDataV1.rootUser.userData.lang private val user_id = SharedTestDataV1.rootUser.userData.user_id diff --git a/webapi/src/test/scala/org/knora/webapi/responders/IriLockerSpec.scala b/webapi/src/test/scala/org/knora/webapi/responders/IriLockerSpec.scala index 1b94ce243b..eedb7d676c 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/IriLockerSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/IriLockerSpec.scala @@ -3,7 +3,8 @@ package org.knora.webapi.responders import java.util.UUID import org.knora.webapi.{ApplicationLockException, IRI} -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import scala.concurrent.duration._ import scala.concurrent.{Await, Future} @@ -11,7 +12,7 @@ import scala.concurrent.{Await, Future} /** * Tests [[IriLocker]]. */ -class IriLockerSpec extends WordSpec with Matchers { +class IriLockerSpec extends AnyWordSpecLike with Matchers { import scala.concurrent.ExecutionContext.Implicits.global diff --git a/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecContextData.scala b/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecContextData.scala index 2bd8811568..b289efc3fa 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecContextData.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecContextData.scala @@ -22,7 +22,7 @@ package org.knora.webapi.responders.v1 import java.io.File import akka.actor.ActorSystem -import org.knora.webapi.Settings +import org.knora.webapi.KnoraSettings import org.knora.webapi.messages.v1.responder.resourcemessages._ import org.knora.webapi.util.FileUtil import spray.json.{JsValue, JsonParser} @@ -31,7 +31,7 @@ object ResourcesResponderV1SpecContextData { implicit lazy val system = ActorSystem("webapi") - val settings = Settings(system) + val settings = KnoraSettings(system) /* diff --git a/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecFullData.scala b/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecFullData.scala index 85f1abf159..f35a201b60 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecFullData.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/v1/ResourcesResponderV1SpecFullData.scala @@ -20,7 +20,7 @@ package org.knora.webapi.responders.v1 import akka.actor.ActorSystem -import org.knora.webapi.{Settings, SettingsImpl} +import org.knora.webapi.{KnoraSettings, KnoraSettingsImpl} import org.knora.webapi.messages.v1.responder.resourcemessages._ import org.knora.webapi.messages.v1.responder.valuemessages._ import org.knora.webapi.messages.v2.responder.standoffmessages.{MappingXMLtoStandoff, XMLTag} @@ -30,7 +30,7 @@ object ResourcesResponderV1SpecFullData { implicit lazy val system: ActorSystem = ActorSystem("webapi") - val settings: SettingsImpl = Settings(system) + val settings: KnoraSettingsImpl = KnoraSettings(system) // The expected response to a "full" resource request for a book. val expectedBookResourceFullResponse = ResourceFullResponseV1( diff --git a/webapi/src/test/scala/org/knora/webapi/responders/v2/ResourcesResponderV2Spec.scala b/webapi/src/test/scala/org/knora/webapi/responders/v2/ResourcesResponderV2Spec.scala index 78c9bb71e5..cf3e6be8b5 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/v2/ResourcesResponderV2Spec.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/v2/ResourcesResponderV2Spec.scala @@ -1885,7 +1885,7 @@ class ResourcesResponderV2Spec extends CoreSpec() with ImplicitSender { apiRequestID = UUID.randomUUID ) - expectMsgClass(classOf[ReadResourcesSequenceV2]) + expectMsgClass(timeout,(classOf[ReadResourcesSequenceV2])) } "accept custom value permissions that would give the requesting user a higher permission on a value than the default if the user is a project admin" in { diff --git a/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToCountPrequeryTransformerSpec.scala b/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToCountPrequeryTransformerSpec.scala index 5e60bde56c..5134f363e3 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToCountPrequeryTransformerSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToCountPrequeryTransformerSpec.scala @@ -7,7 +7,7 @@ import org.knora.webapi.responders.v2.search.gravsearch.types.{GravsearchTypeIns import org.knora.webapi.responders.v2.search.gravsearch.{GravsearchParser, GravsearchQueryChecker} import org.knora.webapi.util.IriConversions._ import org.knora.webapi.util.StringFormatter -import org.knora.webapi.{AssertionException, CoreSpec, SettingsImpl, SharedTestDataADM} +import org.knora.webapi.{AssertionException, CoreSpec, KnoraSettingsImpl, SharedTestDataADM} import scala.concurrent.Await import scala.concurrent.duration._ @@ -18,7 +18,7 @@ private object CountQueryHandler { val anythingUser: UserADM = SharedTestDataADM.anythingAdminUser - def transformQuery(query: String, responderData: ResponderData, settings: SettingsImpl): SelectQuery = { + def transformQuery(query: String, responderData: ResponderData, settings: KnoraSettingsImpl): SelectQuery = { val constructQuery = GravsearchParser.parseQuery(query) diff --git a/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformerSpec.scala b/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformerSpec.scala index 9c77e17c06..a4a328a235 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformerSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/v2/search/gravsearch/prequery/NonTriplestoreSpecificGravsearchToPrequeryTransformerSpec.scala @@ -7,7 +7,7 @@ import org.knora.webapi.responders.v2.search.gravsearch.types.{GravsearchTypeIns import org.knora.webapi.responders.v2.search.gravsearch.{GravsearchParser, GravsearchQueryChecker} import org.knora.webapi.util.IriConversions._ import org.knora.webapi.util.StringFormatter -import org.knora.webapi.{AssertionException, CoreSpec, SettingsImpl, SharedTestDataADM} +import org.knora.webapi.{AssertionException, CoreSpec, KnoraSettingsImpl, SharedTestDataADM} import scala.concurrent.Await import scala.concurrent.duration._ @@ -19,7 +19,7 @@ private object QueryHandler { val anythingUser: UserADM = SharedTestDataADM.anythingAdminUser - def transformQuery(query: String, responderData: ResponderData, settings: SettingsImpl): SelectQuery = { + def transformQuery(query: String, responderData: ResponderData, settings: KnoraSettingsImpl): SelectQuery = { val constructQuery = GravsearchParser.parseQuery(query) diff --git a/webapi/src/test/scala/org/knora/webapi/store/iiif/MockSipiConnector.scala b/webapi/src/test/scala/org/knora/webapi/store/iiif/MockSipiConnector.scala index e67f1cb78e..be649dfdc2 100644 --- a/webapi/src/test/scala/org/knora/webapi/store/iiif/MockSipiConnector.scala +++ b/webapi/src/test/scala/org/knora/webapi/store/iiif/MockSipiConnector.scala @@ -27,7 +27,7 @@ import org.knora.webapi.messages.store.sipimessages._ import org.knora.webapi.messages.v1.responder.valuemessages.StillImageFileValueV1 import org.knora.webapi.messages.v2.responder.SuccessResponseV2 import org.knora.webapi.util.ActorUtil._ -import org.knora.webapi.{BadRequestException, KnoraDispatchers, Settings, SipiException} +import org.knora.webapi.{BadRequestException, KnoraDispatchers, KnoraSettings, SipiException} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success, Try} @@ -69,7 +69,7 @@ class MockSipiConnector extends Actor with ActorLogging { implicit val system: ActorSystem = context.system implicit val executionContext: ExecutionContext = system.dispatchers.lookup(KnoraDispatchers.KnoraActorDispatcher) - val settings = Settings(system) + val settings = KnoraSettings(system) def receive = { diff --git a/webapi/src/test/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginSpec.scala b/webapi/src/test/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginSpec.scala index 8d65d138f9..2b5834d12f 100644 --- a/webapi/src/test/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginSpec.scala @@ -30,7 +30,8 @@ import org.eclipse.rdf4j.rio.{RDFFormat, RDFParser, Rio} import org.eclipse.rdf4j.sail.memory.MemoryStore import org.knora.webapi.messages.store.triplestoremessages.{SparqlSelectResponse, SparqlSelectResponseBody, SparqlSelectResponseHeader, VariableResultsRow} import org.knora.webapi.util.ErrorHandlingMap -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import scala.collection.JavaConverters._ import scala.collection.mutable.ArrayBuffer @@ -38,7 +39,7 @@ import scala.collection.mutable.ArrayBuffer /** * Provides helper methods for specs that test upgrade plugins. */ -abstract class UpgradePluginSpec extends WordSpecLike with Matchers { +abstract class UpgradePluginSpec extends AnyWordSpecLike with Matchers { /** * Parses a TriG file and returns it as an RDF4J [[Model]]. * diff --git a/webapi/src/test/scala/org/knora/webapi/util/jsonld/JsonLDUtilSpec.scala b/webapi/src/test/scala/org/knora/webapi/util/jsonld/JsonLDUtilSpec.scala index 30fa2996ee..f5f6110261 100644 --- a/webapi/src/test/scala/org/knora/webapi/util/jsonld/JsonLDUtilSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/util/jsonld/JsonLDUtilSpec.scala @@ -20,13 +20,14 @@ package org.knora.webapi.util.jsonld import org.knora.webapi.util.StringFormatter -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import spray.json.{JsValue, JsonParser} /** * Tests [[JsonLDUtil]]. */ -class JsonLDUtilSpec extends WordSpecLike with Matchers { +class JsonLDUtilSpec extends AnyWordSpecLike with Matchers { StringFormatter.initForTest()