From f35317a6679f722abe987c87ad91a73adea48852 Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Tue, 16 May 2023 11:30:42 +0200 Subject: [PATCH 1/5] INTERNAL: Api example files moved --- .../apiTestExamples.http => ApiCallExamples/internalAPI.http} | 0 .../{soap examples/origamSoap.http => ApiCallExamples/soap.http} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename model-tests/{ApiExamples/apiTestExamples.http => ApiCallExamples/internalAPI.http} (100%) rename model-tests/{soap examples/origamSoap.http => ApiCallExamples/soap.http} (100%) diff --git a/model-tests/ApiExamples/apiTestExamples.http b/model-tests/ApiCallExamples/internalAPI.http similarity index 100% rename from model-tests/ApiExamples/apiTestExamples.http rename to model-tests/ApiCallExamples/internalAPI.http diff --git a/model-tests/soap examples/origamSoap.http b/model-tests/ApiCallExamples/soap.http similarity index 100% rename from model-tests/soap examples/origamSoap.http rename to model-tests/ApiCallExamples/soap.http From ffc11871ca477feab5721b0e41dcd9d8a892c8ee Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Tue, 16 May 2023 12:14:03 +0200 Subject: [PATCH 2/5] NEW: WorkQueue commands can be executed from API --- .../Origam.Server/Common/SessionManager.cs | 2 +- .../Controller/WorkQueueController.cs | 88 +++++++++++++++++++ backend/Origam.Services/IWorkQueueService.cs | 2 +- .../WorkQueue/WorkQueueService.cs | 15 ++-- model-tests/ApiCallExamples/workQueueAPI.http | 38 ++++++++ 5 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 backend/Origam.Server/Controller/WorkQueueController.cs create mode 100644 model-tests/ApiCallExamples/workQueueAPI.http diff --git a/backend/Origam.Server/Common/SessionManager.cs b/backend/Origam.Server/Common/SessionManager.cs index 3f8e2fc728..2d893e4878 100644 --- a/backend/Origam.Server/Common/SessionManager.cs +++ b/backend/Origam.Server/Common/SessionManager.cs @@ -124,7 +124,7 @@ public SessionStore GetSession(Guid sessionFormIdentifier, bool rootSession) .GetOrAdd( sessionFormIdentifier, guid => throw new SessionExpiredException() - ); + ); if (ss == null) { diff --git a/backend/Origam.Server/Controller/WorkQueueController.cs b/backend/Origam.Server/Controller/WorkQueueController.cs new file mode 100644 index 0000000000..bb3dd6cdde --- /dev/null +++ b/backend/Origam.Server/Controller/WorkQueueController.cs @@ -0,0 +1,88 @@ +#region license + +/* +Copyright 2005 - 2023 Advantage Solutions, s. r. o. + +This file is part of ORIGAM (http://www.origam.org). + +ORIGAM 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 3 of the License, or +(at your option) any later version. + +ORIGAM 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 ORIGAM. If not, see . +*/ + +#endregion + +using System; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Origam.Service.Core; +using Origam.Workbench.Services; + +namespace Origam.Server.Controller; + +[ApiController] +public class WorkQueueController : ControllerBase +{ + private static readonly log4net.ILog log + = log4net.LogManager.GetLogger( + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + [HttpPost] + [Route("workQueue/{workQueueName}/{commandName}")] + public IActionResult CreateSessionAsync(string workQueueName, + string commandName, [FromQuery] [Required] Guid workQueueEntryId) + { + if (log.IsDebugEnabled) + { + log.Debug("Processing: " + HttpContext.Request.GetDisplayUrl()); + } + HttpContext.Response.ContentType = "application/json"; + try + { + IWorkQueueService workQueueService = + ServiceManager.Services.GetService(); + workQueueService.HandleAction(workQueueName, commandName, + workQueueEntryId); + return Ok(); + } + catch (Exception ex) + { + if (log.IsErrorEnabled) + { + log.Error(ex.Message, ex); + } + string output; + if (ex is RuleException ruleException) + { + output = String.Format( + "{{\"Message\" : {0}, \"RuleResult\" : {1}}}", + JsonConvert.SerializeObject(ruleException.Message), + JsonConvert.SerializeObject(ruleException.RuleResult)); + } + else if (ex is ArgumentOutOfRangeException argumentException) + { + output = String.Format( + "{{\"Message\" : {0}, \"ParamName\" : {1}, \"ActualValue\" : {2}}}", + JsonConvert.SerializeObject(argumentException.Message), + JsonConvert.SerializeObject(argumentException.ParamName), + JsonConvert.SerializeObject(argumentException.ActualValue)); + } + else + { + output = JsonConvert.SerializeObject(ex); + } + return BadRequest(output); + } + } +} \ No newline at end of file diff --git a/backend/Origam.Services/IWorkQueueService.cs b/backend/Origam.Services/IWorkQueueService.cs index cf8b9aea5f..8e926b2739 100644 --- a/backend/Origam.Services/IWorkQueueService.cs +++ b/backend/Origam.Services/IWorkQueueService.cs @@ -54,7 +54,7 @@ public interface IWorkQueueService : IWorkbenchService void HandleAction(Guid queueId, string queueClass, DataTable selectedRows, Guid commandType, string command, string param1, string param2, object errorQueueId); - void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, string transactionId); + void HandleAction(string workQueueName, string commandName, Guid queueEntryId); IDataDocument GenerateNotificationMessage( Guid notificationTemplateId , IXmlContainer notificationSource diff --git a/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs b/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs index abb9efbefa..c3d694589e 100644 --- a/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs +++ b/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs @@ -901,10 +901,9 @@ private static void CheckSelectedRowsCountPositive(int count) } } - public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, string transactionId) + public void HandleAction(string workQueueName, string commandName, Guid queueEntryId) { - // get info about queue (from command) - Guid queueId = workQueueUtils.GetQueueId(commandId); + Guid queueId = workQueueUtils.GetQueueId(workQueueName); // get all queue data from database (no entries) WorkQueueData queue = GetQueue(queueId); // extract WorkQueueClass name and construct WorkQueueClass from name @@ -913,7 +912,7 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, // authorize access from API IOrigamAuthorizationProvider auth = SecurityManager.GetAuthorizationProvider(); - if (calledFromApi && (queueRow.IsApiAccessRolesNull() || !auth.Authorize(SecurityManager.CurrentPrincipal, queueRow.ApiAccessRoles))) + if (queueRow.IsApiAccessRolesNull() || !auth.Authorize(SecurityManager.CurrentPrincipal, queueRow.ApiAccessRoles)) { throw new RuleException( String.Format(ResourceUtils.GetString("ErrorWorkQueueApiNotAuthorized"), @@ -925,7 +924,7 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, WorkQueueData.WorkQueueCommandRow commandRow = null; foreach (WorkQueueData.WorkQueueCommandRow cmd in queue.WorkQueueCommand.Rows) { - if (cmd.Id == commandId) + if (cmd.Text == commandName) { commandRow = cmd; } @@ -935,11 +934,11 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, { throw new RuleException( String.Format(ResourceUtils.GetString("ErrorWorkQueueCommandNotAuthorized"), - commandId, queueId), + commandName, queueId), RuleExceptionSeverity.High, "commandId", ""); } // fetch a single queue entry - DataSet queueEntryDS = FetchSingleQueueEntry(wqc, queueEntryId, transactionId); + DataSet queueEntryDS = FetchSingleQueueEntry(wqc, queueEntryId, null); // call handle action HandleAction(queueRow, queueRow.WorkQueueClass, queueEntryDS.Tables[0], @@ -949,7 +948,7 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, commandRow.IsParam2Null() ? null : commandRow.Param2, true, commandRow.IsrefErrorWorkQueueIdNull() ? (object)null : (object)commandRow.refErrorWorkQueueId, - transactionId); + null); } public DataRow GetNextItem(string workQueueName, string transactionId, diff --git a/model-tests/ApiCallExamples/workQueueAPI.http b/model-tests/ApiCallExamples/workQueueAPI.http new file mode 100644 index 0000000000..2e5cc218a1 --- /dev/null +++ b/model-tests/ApiCallExamples/workQueueAPI.http @@ -0,0 +1,38 @@ +# Input file for Visual Studio Code REST client: +# https://marketplace.visualstudio.com/items?itemName=humao.rest-client +# +# - instal the client +# - set @port variable +# - insert the following into the database +# +# INSERT [dbo].[WorkQueue] ([refRemovalOrigamStateMachineEventTypeId], [RemovalNewValue], [RemovalOldValue], [ReferenceCode], [CreationNewValue], [CreationFieldName], [CreationOldValue], [WorkQueueClass], [Roles], [refCreationOrigamStateMachineEventTypeId], [Name], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [IsActive], [refWorkQueueExternalSourceTypeId], [ExternalSourceUserName], [ExternalSourcePassword], [ExternalSourceConnection], [ExternalSourceLastMessage], [ExternalSourceLastTime], [ExternalSourceState], [IsErrorQueue], [RemovalFieldName], [ReverseLookupFieldValues], [CreationCondition], [RemovalCondition], [IsMessageCountDisplayed], [ApiAccessRoles], [QueueProcessor], [refWorkQueueRetryTypeId], [RetryIntervalSeconds], [MaxRetries], [ExponentialRetryBase], [ThrottlingIntervalSeconds], [ThrottlingItemsPerInterval] ,[EnableThrottling]) +# VALUES (NULL, NULL, NULL, N'TestQueue1', NULL, NULL, NULL, N'TestQueue1', N'*', NULL, N'TestQueue1', N'827f974b-ca7c-4c75-9420-c58ab400ac8f', NULL, N'751bd582-2604-4259-b560-6afb8a772fca', getdate(), NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, '69460BCF-81D4-4A97-94F7-5A391D16F771', 30, 3, 2, 60, 10, 0) +# INSERT [dbo].[WorkQueueCommand] ([Param1], [refWorkQueueId], [refWorkQueueCommandTypeId], [Text], [Param2], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [Command], [AutoProcessingConditionXPath], [refErrorWorkQueueId], [IsAutoProcessed], [SortOrder], [IsDefault], [IsAutoProcessedWithErrors], [Roles]) +# VALUES (NULL, N'751bd582-2604-4259-b560-6afb8a772fca', N'8d4117e0-590b-4495-9fd3-de46d9e768af', N'Delete', NULL, N'827f974b-ca7c-4c75-9420-c58ab400ac8f', NULL, N'6c0212dc-6a53-4b0f-a812-b9ff8987d7f1', getdate(), NULL, NULL, NULL, NULL, 1, 1, 0, 0, N'*') + + + +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'33015714-c7d3-4ab5-8c2a-a1cccc2b7f8f', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'2fb0244e-edf8-4702-87c1-1120e2ce2040', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'2568523f-5c02-4e4c-8261-c8913a72eb1f', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'68fa2a98-418a-4c25-b1f7-d7a6a49d554e', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'bd9cd879-7540-4601-9a9c-85169537f2b5', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'e0092d42-bc61-40f0-a270-239f5716286d', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'60b75b58-bea3-4316-b4d4-726efda675ed', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'f58d222b-7378-49a3-ba60-22ca4db17ff0', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'341493be-7a44-4d38-9c9b-77db1e9be283', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0f12e815-f643-4143-9b13-3c179354b53b', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0f0342e2-cce3-4b3b-81a2-ccbf37ba2c87', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'31be390c-b9ec-4a43-8b9d-15ecb0c248c0', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# +# - click "Send Request" over the request you want to send + +@port = 44357 + + +# Should delete the work queue entry, +# Change "API Access Roles" in Settings -> General -> Work Queues to "*" if you get authorization error +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=e0092d42-bc61-40f0-a270-239f5716286d + +### +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=2568523f-5c02-4e4c-8261-c8913a72eb1f + +### +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=341493be-7a44-4d38-9c9b-77db1e9be283 + +### +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=31be390c-b9ec-4a43-8b9d-15ecb0c248c0 + + From f32ab8f49498d7228b08ae73fe95743a184d2902 Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Tue, 16 May 2023 12:14:03 +0200 Subject: [PATCH 3/5] NEW: WorkQueue commands can be executed from API --- .../Origam.Server/Common/SessionManager.cs | 2 +- .../Controller/WorkQueueController.cs | 88 +++++++++++++++++++ .../IApplicationBuilderExtensions.cs | 14 +++ backend/Origam.Server/Startup.cs | 1 + backend/Origam.Services/IWorkQueueService.cs | 2 +- .../WorkQueue/WorkQueueService.cs | 15 ++-- model-tests/ApiCallExamples/workQueueAPI.http | 40 +++++++++ 7 files changed, 152 insertions(+), 10 deletions(-) create mode 100644 backend/Origam.Server/Controller/WorkQueueController.cs create mode 100644 model-tests/ApiCallExamples/workQueueAPI.http diff --git a/backend/Origam.Server/Common/SessionManager.cs b/backend/Origam.Server/Common/SessionManager.cs index 3f8e2fc728..2d893e4878 100644 --- a/backend/Origam.Server/Common/SessionManager.cs +++ b/backend/Origam.Server/Common/SessionManager.cs @@ -124,7 +124,7 @@ public SessionStore GetSession(Guid sessionFormIdentifier, bool rootSession) .GetOrAdd( sessionFormIdentifier, guid => throw new SessionExpiredException() - ); + ); if (ss == null) { diff --git a/backend/Origam.Server/Controller/WorkQueueController.cs b/backend/Origam.Server/Controller/WorkQueueController.cs new file mode 100644 index 0000000000..bb3dd6cdde --- /dev/null +++ b/backend/Origam.Server/Controller/WorkQueueController.cs @@ -0,0 +1,88 @@ +#region license + +/* +Copyright 2005 - 2023 Advantage Solutions, s. r. o. + +This file is part of ORIGAM (http://www.origam.org). + +ORIGAM 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 3 of the License, or +(at your option) any later version. + +ORIGAM 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 ORIGAM. If not, see . +*/ + +#endregion + +using System; +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Origam.Service.Core; +using Origam.Workbench.Services; + +namespace Origam.Server.Controller; + +[ApiController] +public class WorkQueueController : ControllerBase +{ + private static readonly log4net.ILog log + = log4net.LogManager.GetLogger( + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + + [HttpPost] + [Route("workQueue/{workQueueName}/{commandName}")] + public IActionResult CreateSessionAsync(string workQueueName, + string commandName, [FromQuery] [Required] Guid workQueueEntryId) + { + if (log.IsDebugEnabled) + { + log.Debug("Processing: " + HttpContext.Request.GetDisplayUrl()); + } + HttpContext.Response.ContentType = "application/json"; + try + { + IWorkQueueService workQueueService = + ServiceManager.Services.GetService(); + workQueueService.HandleAction(workQueueName, commandName, + workQueueEntryId); + return Ok(); + } + catch (Exception ex) + { + if (log.IsErrorEnabled) + { + log.Error(ex.Message, ex); + } + string output; + if (ex is RuleException ruleException) + { + output = String.Format( + "{{\"Message\" : {0}, \"RuleResult\" : {1}}}", + JsonConvert.SerializeObject(ruleException.Message), + JsonConvert.SerializeObject(ruleException.RuleResult)); + } + else if (ex is ArgumentOutOfRangeException argumentException) + { + output = String.Format( + "{{\"Message\" : {0}, \"ParamName\" : {1}, \"ActualValue\" : {2}}}", + JsonConvert.SerializeObject(argumentException.Message), + JsonConvert.SerializeObject(argumentException.ParamName), + JsonConvert.SerializeObject(argumentException.ActualValue)); + } + else + { + output = JsonConvert.SerializeObject(ex); + } + return BadRequest(output); + } + } +} \ No newline at end of file diff --git a/backend/Origam.Server/IApplicationBuilderExtensions.cs b/backend/Origam.Server/IApplicationBuilderExtensions.cs index 2376111ed5..5d4cb7707b 100644 --- a/backend/Origam.Server/IApplicationBuilderExtensions.cs +++ b/backend/Origam.Server/IApplicationBuilderExtensions.cs @@ -107,6 +107,20 @@ public static void UseCustomSpa(this IApplicationBuilder app, string pathToClien apiBranch.UseMiddleware(); }); } + public static void UseWorkQueueApi(this IApplicationBuilder app) + { + app.MapWhen( + context => context.Request.Path.ToString().StartsWith("/workQueue"), + apiBranch => + { + apiBranch.UseMiddleware(); + apiBranch.UseMvc(routes => + { + routes.MapRoute("default", "{controller}/{action=Index}/{id?}"); + }); + } + ); + } private static bool IsRestrictedUserApiRoute( StartUpConfiguration startUpConfiguration, HttpContext context) diff --git a/backend/Origam.Server/Startup.cs b/backend/Origam.Server/Startup.cs index 851cb3e75d..920e500710 100644 --- a/backend/Origam.Server/Startup.cs +++ b/backend/Origam.Server/Startup.cs @@ -319,6 +319,7 @@ var authenticationPostProcessor app.UseIdentityServer(); app.UseMiddleware(); app.UseUserApi(startUpConfiguration, identityServerConfig); + app.UseWorkQueueApi(); app.UseAuthentication(); app.UseHttpsRedirection(); if (startUpConfiguration.EnableSoapInterface) diff --git a/backend/Origam.Services/IWorkQueueService.cs b/backend/Origam.Services/IWorkQueueService.cs index cf8b9aea5f..8e926b2739 100644 --- a/backend/Origam.Services/IWorkQueueService.cs +++ b/backend/Origam.Services/IWorkQueueService.cs @@ -54,7 +54,7 @@ public interface IWorkQueueService : IWorkbenchService void HandleAction(Guid queueId, string queueClass, DataTable selectedRows, Guid commandType, string command, string param1, string param2, object errorQueueId); - void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, string transactionId); + void HandleAction(string workQueueName, string commandName, Guid queueEntryId); IDataDocument GenerateNotificationMessage( Guid notificationTemplateId , IXmlContainer notificationSource diff --git a/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs b/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs index abb9efbefa..c3d694589e 100644 --- a/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs +++ b/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs @@ -901,10 +901,9 @@ private static void CheckSelectedRowsCountPositive(int count) } } - public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, string transactionId) + public void HandleAction(string workQueueName, string commandName, Guid queueEntryId) { - // get info about queue (from command) - Guid queueId = workQueueUtils.GetQueueId(commandId); + Guid queueId = workQueueUtils.GetQueueId(workQueueName); // get all queue data from database (no entries) WorkQueueData queue = GetQueue(queueId); // extract WorkQueueClass name and construct WorkQueueClass from name @@ -913,7 +912,7 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, // authorize access from API IOrigamAuthorizationProvider auth = SecurityManager.GetAuthorizationProvider(); - if (calledFromApi && (queueRow.IsApiAccessRolesNull() || !auth.Authorize(SecurityManager.CurrentPrincipal, queueRow.ApiAccessRoles))) + if (queueRow.IsApiAccessRolesNull() || !auth.Authorize(SecurityManager.CurrentPrincipal, queueRow.ApiAccessRoles)) { throw new RuleException( String.Format(ResourceUtils.GetString("ErrorWorkQueueApiNotAuthorized"), @@ -925,7 +924,7 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, WorkQueueData.WorkQueueCommandRow commandRow = null; foreach (WorkQueueData.WorkQueueCommandRow cmd in queue.WorkQueueCommand.Rows) { - if (cmd.Id == commandId) + if (cmd.Text == commandName) { commandRow = cmd; } @@ -935,11 +934,11 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, { throw new RuleException( String.Format(ResourceUtils.GetString("ErrorWorkQueueCommandNotAuthorized"), - commandId, queueId), + commandName, queueId), RuleExceptionSeverity.High, "commandId", ""); } // fetch a single queue entry - DataSet queueEntryDS = FetchSingleQueueEntry(wqc, queueEntryId, transactionId); + DataSet queueEntryDS = FetchSingleQueueEntry(wqc, queueEntryId, null); // call handle action HandleAction(queueRow, queueRow.WorkQueueClass, queueEntryDS.Tables[0], @@ -949,7 +948,7 @@ public void HandleAction(Guid queueEntryId, Guid commandId, bool calledFromApi, commandRow.IsParam2Null() ? null : commandRow.Param2, true, commandRow.IsrefErrorWorkQueueIdNull() ? (object)null : (object)commandRow.refErrorWorkQueueId, - transactionId); + null); } public DataRow GetNextItem(string workQueueName, string transactionId, diff --git a/model-tests/ApiCallExamples/workQueueAPI.http b/model-tests/ApiCallExamples/workQueueAPI.http new file mode 100644 index 0000000000..29c77ff000 --- /dev/null +++ b/model-tests/ApiCallExamples/workQueueAPI.http @@ -0,0 +1,40 @@ +# Input file for Visual Studio Code REST client: +# https://marketplace.visualstudio.com/items?itemName=humao.rest-client +# +# - instal the client +# - set @port variable +# - insert the following into the database +# +# INSERT [dbo].[WorkQueue] ([refRemovalOrigamStateMachineEventTypeId], [RemovalNewValue], [RemovalOldValue], [ReferenceCode], [CreationNewValue], [CreationFieldName], [CreationOldValue], [WorkQueueClass], [Roles], [refCreationOrigamStateMachineEventTypeId], [Name], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [IsActive], [refWorkQueueExternalSourceTypeId], [ExternalSourceUserName], [ExternalSourcePassword], [ExternalSourceConnection], [ExternalSourceLastMessage], [ExternalSourceLastTime], [ExternalSourceState], [IsErrorQueue], [RemovalFieldName], [ReverseLookupFieldValues], [CreationCondition], [RemovalCondition], [IsMessageCountDisplayed], [ApiAccessRoles], [QueueProcessor], [refWorkQueueRetryTypeId], [RetryIntervalSeconds], [MaxRetries], [ExponentialRetryBase], [ThrottlingIntervalSeconds], [ThrottlingItemsPerInterval] ,[EnableThrottling]) +# VALUES (NULL, NULL, NULL, N'TestQueue1', NULL, NULL, NULL, N'TestQueue1', N'*', NULL, N'TestQueue1', N'827f974b-ca7c-4c75-9420-c58ab400ac8f', NULL, N'751bd582-2604-4259-b560-6afb8a772fca', getdate(), NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, NULL, NULL, 1, NULL, NULL, '69460BCF-81D4-4A97-94F7-5A391D16F771', 30, 3, 2, 60, 10, 0) +# INSERT [dbo].[WorkQueueCommand] ([Param1], [refWorkQueueId], [refWorkQueueCommandTypeId], [Text], [Param2], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [Command], [AutoProcessingConditionXPath], [refErrorWorkQueueId], [IsAutoProcessed], [SortOrder], [IsDefault], [IsAutoProcessedWithErrors], [Roles]) +# VALUES (NULL, N'751bd582-2604-4259-b560-6afb8a772fca', N'8d4117e0-590b-4495-9fd3-de46d9e768af', N'Delete', NULL, N'827f974b-ca7c-4c75-9420-c58ab400ac8f', NULL, N'6c0212dc-6a53-4b0f-a812-b9ff8987d7f1', getdate(), NULL, NULL, NULL, NULL, 1, 1, 0, 0, N'*') +# +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'33015714-c7d3-4ab5-8c2a-a1cccc2b7f8f', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'2fb0244e-edf8-4702-87c1-1120e2ce2040', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'2568523f-5c02-4e4c-8261-c8913a72eb1f', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'68fa2a98-418a-4c25-b1f7-d7a6a49d554e', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'bd9cd879-7540-4601-9a9c-85169537f2b5', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'e0092d42-bc61-40f0-a270-239f5716286d', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'60b75b58-bea3-4316-b4d4-726efda675ed', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'f58d222b-7378-49a3-ba60-22ca4db17ff0', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'341493be-7a44-4d38-9c9b-77db1e9be283', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# INSERT [dbo].[WorkQueueEntry] ([b5], [d8], [b1], [g6], [i5], [c2], [s9], [b8], [g5], [g14], [g15], [d2], [c3], [g20], [blob1], [d9], [g11], [g17], [g8], [g18], [s3], [refRel1Id], [b10], [d6], [d1], [c6], [refLockedByBusinessPartnerId], [refRel2Id], [refRel4Id], [f8], [f5], [d5], [f9], [refRel7Id], [refRel5Id], [i2], [refRel3Id], [ErrorText], [m4], [g10], [s2], [b3], [b2], [c5], [m3], [i4], [b6], [g3], [d10], [g7], [f3], [i6], [g2], [m5], [m2], [refId], [s5], [d3], [f7], [b4], [g12], [i8], [c7], [g9], [f10], [b9], [f6], [s4], [d7], [c4], [s8], [i7], [c1], [f2], [i3], [c10], [s7], [s1], [i9], [i1], [g4], [f4], [refWorkQueueId], [m1], [g19], [g13], [c9], [refRel6Id], [f1], [s6], [c8], [g1], [s10], [b7], [i10], [IsLocked], [g16], [d4], [RecordCreatedBy], [RecordUpdatedBy], [Id], [RecordCreated], [RecordUpdated], [AttemptCount], [InRetry]) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(N'2023-02-06T17:46:52.000' AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0f12e815-f643-4143-9b13-3c179354b53b', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'751BD582-2604-4259-B560-6AFB8A772FCA', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0f0342e2-cce3-4b3b-81a2-ccbf37ba2c87', NULL, NULL, NULL, 0, NULL, NULL, N'56052d2e-0460-4325-a123-1725c1b9c940', NULL, N'31be390c-b9ec-4a43-8b9d-15ecb0c248c0', CAST(N'2023-02-06T17:46:52.643' AS DateTime), NULL, 0, 0) +# +# - click "Send Request" over the request you want to send + +@port = 44357 + + +# Should delete the work queue entry, +# Get the token from your browser after you login +# Change "API Access Roles" in Settings -> General -> Work Queues to "*" if you get authorization error +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=e0092d42-bc61-40f0-a270-239f5716286d +Authorization: Bearer CCF034CE5393A8F7D8308431DAF0708B83BF368750571CCDEB787CB3FAC62937 + +### +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=2568523f-5c02-4e4c-8261-c8913a72eb1f +Authorization: Bearer 81D6D08664B8A5037DDCC92AC75DEDD829BBB4EDBD61AAAF3F961A7C686C1077 +### +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=341493be-7a44-4d38-9c9b-77db1e9be283 +Authorization: Bearer 81D6D08664B8A5037DDCC92AC75DEDD829BBB4EDBD61AAAF3F961A7C686C1077 + +### +POST https://localhost:{{port}}/workQueue/TestQueue1/Delete/?workQueueEntryId=31be390c-b9ec-4a43-8b9d-15ecb0c248c0 +Authorization: Bearer 81D6D08664B8A5037DDCC92AC75DEDD829BBB4EDBD61AAAF3F961A7C686C1077 + + From 3daaaede87d75c94ebf2e473182d0546dd43c1cb Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Tue, 16 May 2023 15:58:17 +0200 Subject: [PATCH 4/5] INTERNAL: Parameters renamed --- backend/Origam.Server/Controller/WorkQueueController.cs | 8 ++++---- backend/Origam.Services/IWorkQueueService.cs | 2 +- backend/Origam.Workflow/WorkQueue/WorkQueueService.cs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/Origam.Server/Controller/WorkQueueController.cs b/backend/Origam.Server/Controller/WorkQueueController.cs index bb3dd6cdde..6e3dec968e 100644 --- a/backend/Origam.Server/Controller/WorkQueueController.cs +++ b/backend/Origam.Server/Controller/WorkQueueController.cs @@ -39,9 +39,9 @@ public class WorkQueueController : ControllerBase System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); [HttpPost] - [Route("workQueue/{workQueueName}/{commandName}")] - public IActionResult CreateSessionAsync(string workQueueName, - string commandName, [FromQuery] [Required] Guid workQueueEntryId) + [Route("workQueue/{workQueueCode}/{commandText}")] + public IActionResult CreateSessionAsync(string workQueueCode, + string commandText, [FromQuery] [Required] Guid workQueueEntryId) { if (log.IsDebugEnabled) { @@ -52,7 +52,7 @@ public class WorkQueueController : ControllerBase { IWorkQueueService workQueueService = ServiceManager.Services.GetService(); - workQueueService.HandleAction(workQueueName, commandName, + workQueueService.HandleAction(workQueueCode, commandText, workQueueEntryId); return Ok(); } diff --git a/backend/Origam.Services/IWorkQueueService.cs b/backend/Origam.Services/IWorkQueueService.cs index 8e926b2739..47933d346c 100644 --- a/backend/Origam.Services/IWorkQueueService.cs +++ b/backend/Origam.Services/IWorkQueueService.cs @@ -54,7 +54,7 @@ public interface IWorkQueueService : IWorkbenchService void HandleAction(Guid queueId, string queueClass, DataTable selectedRows, Guid commandType, string command, string param1, string param2, object errorQueueId); - void HandleAction(string workQueueName, string commandName, Guid queueEntryId); + void HandleAction(string workQueueCode, string commandText, Guid queueEntryId); IDataDocument GenerateNotificationMessage( Guid notificationTemplateId , IXmlContainer notificationSource diff --git a/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs b/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs index c3d694589e..c02f5dc5e4 100644 --- a/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs +++ b/backend/Origam.Workflow/WorkQueue/WorkQueueService.cs @@ -901,9 +901,9 @@ private static void CheckSelectedRowsCountPositive(int count) } } - public void HandleAction(string workQueueName, string commandName, Guid queueEntryId) + public void HandleAction(string workQueueCode, string commandText, Guid queueEntryId) { - Guid queueId = workQueueUtils.GetQueueId(workQueueName); + Guid queueId = workQueueUtils.GetQueueId(workQueueCode); // get all queue data from database (no entries) WorkQueueData queue = GetQueue(queueId); // extract WorkQueueClass name and construct WorkQueueClass from name @@ -924,7 +924,7 @@ public void HandleAction(string workQueueName, string commandName, Guid queueEnt WorkQueueData.WorkQueueCommandRow commandRow = null; foreach (WorkQueueData.WorkQueueCommandRow cmd in queue.WorkQueueCommand.Rows) { - if (cmd.Text == commandName) + if (cmd.Text == commandText) { commandRow = cmd; } @@ -934,7 +934,7 @@ public void HandleAction(string workQueueName, string commandName, Guid queueEnt { throw new RuleException( String.Format(ResourceUtils.GetString("ErrorWorkQueueCommandNotAuthorized"), - commandName, queueId), + commandText, queueId), RuleExceptionSeverity.High, "commandId", ""); } // fetch a single queue entry From ef65d45c60c5a824ce08fefda0ba9e14fd8a78fd Mon Sep 17 00:00:00 2001 From: Petr Hrehorovsky <83349812+washibana@users.noreply.github.com> Date: Wed, 17 May 2023 15:41:55 +0200 Subject: [PATCH 5/5] workQueueAPI.http - fixed typo --- model-tests/ApiCallExamples/workQueueAPI.http | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model-tests/ApiCallExamples/workQueueAPI.http b/model-tests/ApiCallExamples/workQueueAPI.http index e97589d395..20945bbc96 100644 --- a/model-tests/ApiCallExamples/workQueueAPI.http +++ b/model-tests/ApiCallExamples/workQueueAPI.http @@ -1,7 +1,7 @@ # Input file for Visual Studio Code REST client: # https://marketplace.visualstudio.com/items?itemName=humao.rest-client # -# - instal the client +# - install the client # - set @port variable # - insert the following into the database #