From bdbd24f5ddffba86ed72fed12f6157c2e7245c73 Mon Sep 17 00:00:00 2001 From: Marcello Rocha Date: Wed, 24 Jul 2024 10:52:14 +0200 Subject: [PATCH] Rename Snitch --- .../storages/app/common/storages/injector.rb | 28 ++++++++++++ .../managed_folder_identifier/nextcloud.rb | 25 +++++++++++ .../managed_folder_identifier/one_drive.rb | 25 +++++++++++ .../common/storages/peripherals/registry.rb | 2 +- .../nextcloud/add_user_to_group_command.rb | 2 +- .../nextcloud/file_ids_query.rb | 2 +- .../nextcloud/group_users_query.rb | 2 +- .../internal/propfind_query_legacy.rb | 2 +- .../remove_user_from_group_command.rb | 2 +- .../nextcloud/rename_file_command.rb | 2 +- .../nextcloud/set_permissions_command.rb | 2 +- .../result_data/copy_template_folder.rb | 30 +++++++++++++ .../storages/app/common/storages/snitch.rb | 18 -------- .../app/common/storages/tagged_logging.rb | 43 +++++++++++++++++++ ...ud_group_folder_properties_sync_service.rb | 2 +- 15 files changed, 160 insertions(+), 27 deletions(-) delete mode 100644 modules/storages/app/common/storages/snitch.rb create mode 100644 modules/storages/app/common/storages/tagged_logging.rb diff --git a/modules/storages/app/common/storages/injector.rb b/modules/storages/app/common/storages/injector.rb index d8d5b6dce41..44cc4c6ce32 100644 --- a/modules/storages/app/common/storages/injector.rb +++ b/modules/storages/app/common/storages/injector.rb @@ -1,5 +1,33 @@ # frozen_string_literal: true +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + require "dry/auto_inject" module Storages diff --git a/modules/storages/app/common/storages/peripherals/managed_folder_identifier/nextcloud.rb b/modules/storages/app/common/storages/peripherals/managed_folder_identifier/nextcloud.rb index 5ca9c05ecb4..fe422b89e30 100644 --- a/modules/storages/app/common/storages/peripherals/managed_folder_identifier/nextcloud.rb +++ b/modules/storages/app/common/storages/peripherals/managed_folder_identifier/nextcloud.rb @@ -1,6 +1,31 @@ # frozen_string_literal: true #-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. #++ module Storages diff --git a/modules/storages/app/common/storages/peripherals/managed_folder_identifier/one_drive.rb b/modules/storages/app/common/storages/peripherals/managed_folder_identifier/one_drive.rb index e81c3ac99e1..166b4ea6b59 100644 --- a/modules/storages/app/common/storages/peripherals/managed_folder_identifier/one_drive.rb +++ b/modules/storages/app/common/storages/peripherals/managed_folder_identifier/one_drive.rb @@ -1,6 +1,31 @@ # frozen_string_literal: true #-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. #++ module Storages diff --git a/modules/storages/app/common/storages/peripherals/registry.rb b/modules/storages/app/common/storages/peripherals/registry.rb index dc91fbfd13f..cd2b1e072af 100644 --- a/modules/storages/app/common/storages/peripherals/registry.rb +++ b/modules/storages/app/common/storages/peripherals/registry.rb @@ -36,7 +36,7 @@ module Storages extend Dry::Container::Mixin class Resolver < Dry::Container::Resolver - include Snitch + include TaggedLogging def call(container, key) with_tagged_logger("Registry") do info "Resolving #{key}" diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb index 7289dcf4da6..cdd87d06f2b 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/add_user_to_group_command.rb @@ -33,7 +33,7 @@ module Storages module StorageInteraction module Nextcloud class AddUserToGroupCommand - include Snitch + include TaggedLogging def initialize(storage) @storage = storage diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_ids_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_ids_query.rb index 8b5e3c60868..8e5a3ae2e76 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_ids_query.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/file_ids_query.rb @@ -33,7 +33,7 @@ module Storages module StorageInteraction module Nextcloud class FileIdsQuery - include Snitch + include TaggedLogging def self.call(storage:, path:) new(storage).call(path:) end diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb index d97c2acf4c7..edd47508fc5 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb @@ -33,7 +33,7 @@ module Storages module StorageInteraction module Nextcloud class GroupUsersQuery - include Snitch + include TaggedLogging using ServiceResultRefinements def self.call(storage:, group: storage.group) diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query_legacy.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query_legacy.rb index 6b04c969db0..9e30b2fd653 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query_legacy.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query_legacy.rb @@ -34,7 +34,7 @@ module Storages module Nextcloud module Internal class PropfindQueryLegacy - include Snitch + include TaggedLogging def self.call(storage:, depth:, path:, props:) new(storage).call(depth:, path:, props:) end diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb index 623e8f5eb1d..032f49aac7b 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/remove_user_from_group_command.rb @@ -33,7 +33,7 @@ module Storages module StorageInteraction module Nextcloud class RemoveUserFromGroupCommand - include Snitch + include TaggedLogging def self.call(storage:, user:, group: storage.group) new(storage).call(user:, group:) end diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb index aa0f6e1ef15..95b686d1860 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/rename_file_command.rb @@ -33,7 +33,7 @@ module Storages module StorageInteraction module Nextcloud class RenameFileCommand - include Snitch + include TaggedLogging def self.call(storage:, auth_strategy:, file_id:, name:) new(storage).call(auth_strategy:, file_id:, name:) diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb index 8c3754f6f1b..ed0c5b4d82b 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/set_permissions_command.rb @@ -33,7 +33,7 @@ module Storages module StorageInteraction module Nextcloud class SetPermissionsCommand - include Snitch + include TaggedLogging using ServiceResultRefinements SUCCESS_XPATH = "/d:multistatus/d:response/d:propstat[d:status[text() = 'HTTP/1.1 200 OK']]/d:prop/nc:acl-list" diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/result_data/copy_template_folder.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/result_data/copy_template_folder.rb index efacc4cb360..61369c34b3c 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/result_data/copy_template_folder.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/result_data/copy_template_folder.rb @@ -1,3 +1,33 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + module Storages module Peripherals module StorageInteraction diff --git a/modules/storages/app/common/storages/snitch.rb b/modules/storages/app/common/storages/snitch.rb deleted file mode 100644 index 536f66e53a2..00000000000 --- a/modules/storages/app/common/storages/snitch.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -#-- copyright -#++ - -module Storages - module Snitch - delegate :info, :error, to: :logger - - def with_tagged_logger(tag = self.class, &) - logger.tagged(*tag, &) - end - - def logger - Rails.logger - end - end -end diff --git a/modules/storages/app/common/storages/tagged_logging.rb b/modules/storages/app/common/storages/tagged_logging.rb new file mode 100644 index 00000000000..35d04a03fd9 --- /dev/null +++ b/modules/storages/app/common/storages/tagged_logging.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +module Storages + module TaggedLogging + delegate :info, :error, to: :logger + + def with_tagged_logger(tag = self.class, &) + logger.tagged(*tag, &) + end + + def logger + Rails.logger + end + end +end diff --git a/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb b/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb index e4fde415a7d..c1cafd66329 100644 --- a/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb +++ b/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb @@ -32,7 +32,7 @@ module Storages class NextcloudGroupFolderPropertiesSyncService extend ActiveModel::Naming extend ActiveModel::Translation - include Snitch + include TaggedLogging using Peripherals::ServiceResultRefinements