OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
All command and queries migrated
Marcello Rochad505ec6388dd
diff --git a/modules/storages/app/common/storages/peripherals/registry.rb b/modules/storages/app/common/storages/peripherals/registry.rbindex 32b687d8db3..d981961b139 100644--- a/modules/storages/app/common/storages/peripherals/registry.rb+++ b/modules/storages/app/common/storages/peripherals/registry.rb@@ -5,5 +5,6 @@ module StoragesendRegistry.import StorageInteraction::Nextcloud::Queries+ Registry.import StorageInteraction::Nextcloud::Commandsendenddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud.rbindex 108cf84aea1..dd2cbe4454b 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud.rb@@ -44,6 +44,19 @@ module Storagesregister(:upload_link_query, UploadLinkQuery)endend++ Commands = Dry::Container::Namespace.new('commands') do+ namespace('nextcloud') do+ register(:delete_entity_command, Internal::DeleteEntityCommand)+ register(:add_user_to_group_command, AddUserToGroupCommand)+ register(:copy_template_folder_command, CopyTemplateFolderCommand)+ register(:create_folder_command, CreateFolderCommand)+ register(:delete_folder_command, DeleteFolderCommand)+ register(:set_permissions_command, SetPermissionsCommand)+ register(:remove_user_from_group_command, RemoveUserFromGroupCommand)+ register(:rename_file_command, RenameFileCommand)+ end+ endendendenddiff --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.rbindex c396e4585c9..67ecdd2bb2d 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@@ -36,6 +36,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloudend# rubocop:disable Metrics/AbcSize+ def self.call(storage:, user:, group: storage.group)+ new(storage).call(user:, group:)+ end+def call(user:, group: @group)response = Util.http(@uri).post(Util.join_uri_path(@uri, 'ocs/v1.php/cloud/users', CGI.escapeURIComponent(user), 'groups'),diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rbindex 5957746bbc3..ddda8a14381 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb@@ -36,6 +36,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud@password = storage.passwordend+ def self.call(storage:, source_path:, destination_path:)+ new(storage).call(source_path:, destination_path:)+ end+def call(source_path:, destination_path:)validate_inputs(source_path, destination_path) >>build_origin_paths >>diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rbindex 92411b1205a..a309f9c31f4 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/create_folder_command.rb@@ -36,6 +36,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud@password = storage.passwordend+ def self.call(storage:, folder_path:)+ new(storage).call(folder_path:)+ end+# rubocop:disable Metrics/AbcSizedef call(folder_path:)response = Util.http(@uri).mkcol(diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/delete_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/delete_folder_command.rbindex 78117222220..4bd735295e8 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/delete_folder_command.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/delete_folder_command.rb@@ -32,6 +32,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud@delegate = Internal::DeleteEntityCommand.new(storage)end+ def self.call(storage:, location:)+ new(storage).call(location:)+ end+def call(location:)@delegate.call(location:)enddiff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rbindex da930005c6c..08013648406 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/delete_entity_command.rb@@ -37,6 +37,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internal@password = storage.passwordend+ def self.call(storage:, location:)+ new(storage).call(location:)+ end+def call(location:)response = UTIL.http(@uri).delete(UTIL.join_uri_path(@base_path, UTIL.escape_path(location)),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.rbindex 619946c55a1..7bc4a2b3d83 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@@ -35,6 +35,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud@group = storage.groupend+ def self.call(storage:, user:, group: storage.group)+ new(storage).call(user:, group:)+ end+# rubocop:disable Metrics/AbcSizedef call(user:, group: @group)response = Util.http(@uri).delete(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.rbindex fa61398218e..2626a9dcea5 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@@ -37,6 +37,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud@password = storage.passwordend+ def self.call(storage:, source:, target:)+ new(storage).call(source:, target:)+ end+def call(source:, target:)response = Util.http(@uri).move(Util.join_uri_path(@base_path, Util.escape_path(source)),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.rbindex add141ff236..2ce10695d95 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@@ -36,6 +36,10 @@ module Storages::Peripherals::StorageInteraction::Nextcloud@password = storage.passwordend+ def self.call(storage:, path:, permissions:)+ new(storage).call(path:, permissions:)+ end+# rubocop:disable Metrics/AbcSizedef call(path:, permissions:)raise ArgumentError if path.blank?diff --git a/modules/storages/app/common/storages/peripherals/storage_requests.rb b/modules/storages/app/common/storages/peripherals/storage_requests.rbindex 0f62d6f16af..af0071cc819 100644--- a/modules/storages/app/common/storages/peripherals/storage_requests.rb+++ b/modules/storages/app/common/storages/peripherals/storage_requests.rb@@ -28,42 +28,26 @@module Storages::Peripheralsclass StorageRequests- COMMANDS = %i[- set_permissions_command- create_folder_command- add_user_to_group_command- delete_folder_command- remove_user_from_group_command- rename_file_command- copy_template_folder_command- ].freeze-def initialize(storage:)@storage = storageend- #+# def self.call(storage:, operation:, **)# Registry.resolve("queries.#{storage.short_provider_type}.#{operation}").call(storage:, **)# end- COMMANDS.each do |request|- define_method(request) do- clazz = "::Storages::Peripherals::StorageInteraction::" \- "#{@storage.short_provider_type.capitalize}::#{request.to_s.classify}".constantize- clazz.new(@storage).method(:call).to_proc- end- end-privatedef method_missing(name, *args)- Registry.resolve("queries.#{@storage.short_provider_type}.#{name}")+ resource_type = name.to_s.split('_').last.pluralize+ Registry.resolve("#{resource_type}.#{@storage.short_provider_type}.#{name}")rescue Dry::Container::KeyErrorsuperenddef respond_to_missing?(name)- !!Registry.resolve("queries.#{@storage.short_provider_type}.#{name}")+ resource_type = name.to_s.split('_').last.pluralize+ !!Registry.resolve("#{resource_type}.#{@storage.short_provider_type}.#{name}")rescue Dry::Container::KeyErrorsuperenddiff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rbindex 49c96b997ac..db212e97d8e 100644--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb@@ -482,7 +482,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'adds user to the group' doresult = subject.add_user_to_group_command- .call(user: origin_user_id)+ .call(storage:, user: origin_user_id)expect(result).to be_successexpect(result.message).to eq("User has been added successfully")end@@ -526,7 +526,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'removes user from the group' doresult = subject.remove_user_from_group_command- .call(user: origin_user_id)+ .call(storage:, user: origin_user_id)expect(result).to be_successexpect(result.message).to eq("User has been removed from group")end@@ -586,7 +586,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'creates a folder and responds with a success' doresult = subject.create_folder_command- .call(folder_path:)+ .call(storage:, folder_path:)expect(result).to be_successexpect(result.message).to eq("Folder was successfully created.")end@@ -613,7 +613,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'does not create a folder and responds with a success' doresult = subject.create_folder_command- .call(folder_path:)+ .call(storage:, folder_path:)expect(result).to be_successexpect(result.message).to eq("Folder already exists.")end@@ -640,7 +640,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'does not create a folder and responds with a failure' doresult = subject.create_folder_command- .call(folder_path:)+ .call(storage:, folder_path:)expect(result).to be_failureexpect(result.result).to eq(:conflict)expect(result.errors.log_message).to eq('Parent node does not exist')@@ -746,7 +746,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'returns success when permissions can be set' doresult = subject.set_permissions_command- .call(path:, permissions:)+ .call(storage:, path:, permissions:)expect(result).to be_successendend@@ -774,7 +774,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'returns failure' doresult = subject.set_permissions_command- .call(path:, permissions:)+ .call(storage:, path:, permissions:)expect(result).to be_failureendend@@ -802,7 +802,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'returns failure' doresult = subject.set_permissions_command- .call(path:, permissions:)+ .call(storage:, path:, permissions:)expect(result).to be_failureendend@@ -813,7 +813,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doexpect dosubject.set_permissions_command- .call(path: nil, permissions:)+ .call(storage:, path: nil, permissions:)end.to raise_error(ArgumentError)end@@ -966,7 +966,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'moves the file' doresult = subject.rename_file_command- .call(source: 'OpenProject/asd', target: 'OpenProject/qwe')+ .call(storage:, source: 'OpenProject/asd', target: 'OpenProject/qwe')expect(result).to be_successendend@@ -983,7 +983,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'deletes the folder' doresult = subject.delete_folder_command- .call(location: 'OpenProject/Folder 1')+ .call(storage:, location: 'OpenProject/Folder 1')expect(result).to be_successendend